Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 3 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #ifndef mozilla_dom_indexeddb_serializationhelpers_h__ |
michael@0 | 6 | #define mozilla_dom_indexeddb_serializationhelpers_h__ |
michael@0 | 7 | |
michael@0 | 8 | #include "ipc/IPCMessageUtils.h" |
michael@0 | 9 | |
michael@0 | 10 | #include "mozilla/dom/indexedDB/DatabaseInfo.h" |
michael@0 | 11 | #include "mozilla/dom/indexedDB/Key.h" |
michael@0 | 12 | #include "mozilla/dom/indexedDB/KeyPath.h" |
michael@0 | 13 | #include "mozilla/dom/indexedDB/IDBCursor.h" |
michael@0 | 14 | #include "mozilla/dom/indexedDB/IDBTransaction.h" |
michael@0 | 15 | |
michael@0 | 16 | namespace IPC { |
michael@0 | 17 | |
michael@0 | 18 | template <> |
michael@0 | 19 | struct ParamTraits<mozilla::dom::quota::PersistenceType> : |
michael@0 | 20 | public ContiguousEnumSerializer< |
michael@0 | 21 | mozilla::dom::quota::PersistenceType, |
michael@0 | 22 | mozilla::dom::quota::PERSISTENCE_TYPE_PERSISTENT, |
michael@0 | 23 | mozilla::dom::quota::PERSISTENCE_TYPE_INVALID> |
michael@0 | 24 | { }; |
michael@0 | 25 | |
michael@0 | 26 | template <> |
michael@0 | 27 | struct ParamTraits<mozilla::dom::indexedDB::Key> |
michael@0 | 28 | { |
michael@0 | 29 | typedef mozilla::dom::indexedDB::Key paramType; |
michael@0 | 30 | |
michael@0 | 31 | static void Write(Message* aMsg, const paramType& aParam) |
michael@0 | 32 | { |
michael@0 | 33 | WriteParam(aMsg, aParam.mBuffer); |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | static bool Read(const Message* aMsg, void** aIter, paramType* aResult) |
michael@0 | 37 | { |
michael@0 | 38 | return ReadParam(aMsg, aIter, &aResult->mBuffer); |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | static void Log(const paramType& aParam, std::wstring* aLog) |
michael@0 | 42 | { |
michael@0 | 43 | LogParam(aParam.mBuffer, aLog); |
michael@0 | 44 | } |
michael@0 | 45 | }; |
michael@0 | 46 | |
michael@0 | 47 | template <> |
michael@0 | 48 | struct ParamTraits<mozilla::dom::indexedDB::KeyPath::KeyPathType> : |
michael@0 | 49 | public ContiguousEnumSerializer< |
michael@0 | 50 | mozilla::dom::indexedDB::KeyPath::KeyPathType, |
michael@0 | 51 | mozilla::dom::indexedDB::KeyPath::NONEXISTENT, |
michael@0 | 52 | mozilla::dom::indexedDB::KeyPath::ENDGUARD> |
michael@0 | 53 | { }; |
michael@0 | 54 | |
michael@0 | 55 | template <> |
michael@0 | 56 | struct ParamTraits<mozilla::dom::indexedDB::KeyPath> |
michael@0 | 57 | { |
michael@0 | 58 | typedef mozilla::dom::indexedDB::KeyPath paramType; |
michael@0 | 59 | |
michael@0 | 60 | static void Write(Message* aMsg, const paramType& aParam) |
michael@0 | 61 | { |
michael@0 | 62 | WriteParam(aMsg, aParam.mType); |
michael@0 | 63 | WriteParam(aMsg, aParam.mStrings); |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | static bool Read(const Message* aMsg, void** aIter, paramType* aResult) |
michael@0 | 67 | { |
michael@0 | 68 | return ReadParam(aMsg, aIter, &aResult->mType) && |
michael@0 | 69 | ReadParam(aMsg, aIter, &aResult->mStrings); |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | static void Log(const paramType& aParam, std::wstring* aLog) |
michael@0 | 73 | { |
michael@0 | 74 | LogParam(aParam.mStrings, aLog); |
michael@0 | 75 | } |
michael@0 | 76 | }; |
michael@0 | 77 | |
michael@0 | 78 | template <> |
michael@0 | 79 | struct ParamTraits<mozilla::dom::indexedDB::IDBCursor::Direction> : |
michael@0 | 80 | public ContiguousEnumSerializer< |
michael@0 | 81 | mozilla::dom::indexedDB::IDBCursor::Direction, |
michael@0 | 82 | mozilla::dom::indexedDB::IDBCursor::NEXT, |
michael@0 | 83 | mozilla::dom::indexedDB::IDBCursor::DIRECTION_INVALID> |
michael@0 | 84 | { }; |
michael@0 | 85 | |
michael@0 | 86 | template <> |
michael@0 | 87 | struct ParamTraits<mozilla::dom::indexedDB::IDBTransaction::Mode> : |
michael@0 | 88 | public ContiguousEnumSerializer< |
michael@0 | 89 | mozilla::dom::indexedDB::IDBTransaction::Mode, |
michael@0 | 90 | mozilla::dom::indexedDB::IDBTransaction::READ_ONLY, |
michael@0 | 91 | mozilla::dom::indexedDB::IDBTransaction::MODE_INVALID> |
michael@0 | 92 | { }; |
michael@0 | 93 | |
michael@0 | 94 | template <> |
michael@0 | 95 | struct ParamTraits<mozilla::dom::indexedDB::IndexInfo> |
michael@0 | 96 | { |
michael@0 | 97 | typedef mozilla::dom::indexedDB::IndexInfo paramType; |
michael@0 | 98 | |
michael@0 | 99 | static void Write(Message* aMsg, const paramType& aParam) |
michael@0 | 100 | { |
michael@0 | 101 | WriteParam(aMsg, aParam.name); |
michael@0 | 102 | WriteParam(aMsg, aParam.id); |
michael@0 | 103 | WriteParam(aMsg, aParam.keyPath); |
michael@0 | 104 | WriteParam(aMsg, aParam.unique); |
michael@0 | 105 | WriteParam(aMsg, aParam.multiEntry); |
michael@0 | 106 | } |
michael@0 | 107 | |
michael@0 | 108 | static bool Read(const Message* aMsg, void** aIter, paramType* aResult) |
michael@0 | 109 | { |
michael@0 | 110 | return ReadParam(aMsg, aIter, &aResult->name) && |
michael@0 | 111 | ReadParam(aMsg, aIter, &aResult->id) && |
michael@0 | 112 | ReadParam(aMsg, aIter, &aResult->keyPath) && |
michael@0 | 113 | ReadParam(aMsg, aIter, &aResult->unique) && |
michael@0 | 114 | ReadParam(aMsg, aIter, &aResult->multiEntry); |
michael@0 | 115 | } |
michael@0 | 116 | |
michael@0 | 117 | static void Log(const paramType& aParam, std::wstring* aLog) |
michael@0 | 118 | { |
michael@0 | 119 | LogParam(aParam.name, aLog); |
michael@0 | 120 | LogParam(aParam.id, aLog); |
michael@0 | 121 | LogParam(aParam.keyPath, aLog); |
michael@0 | 122 | LogParam(aParam.unique, aLog); |
michael@0 | 123 | LogParam(aParam.multiEntry, aLog); |
michael@0 | 124 | } |
michael@0 | 125 | }; |
michael@0 | 126 | |
michael@0 | 127 | template <> |
michael@0 | 128 | struct ParamTraits<mozilla::dom::indexedDB::ObjectStoreInfoGuts> |
michael@0 | 129 | { |
michael@0 | 130 | typedef mozilla::dom::indexedDB::ObjectStoreInfoGuts paramType; |
michael@0 | 131 | |
michael@0 | 132 | static void Write(Message* aMsg, const paramType& aParam) |
michael@0 | 133 | { |
michael@0 | 134 | WriteParam(aMsg, aParam.name); |
michael@0 | 135 | WriteParam(aMsg, aParam.id); |
michael@0 | 136 | WriteParam(aMsg, aParam.keyPath); |
michael@0 | 137 | WriteParam(aMsg, aParam.autoIncrement); |
michael@0 | 138 | WriteParam(aMsg, aParam.indexes); |
michael@0 | 139 | } |
michael@0 | 140 | |
michael@0 | 141 | static bool Read(const Message* aMsg, void** aIter, paramType* aResult) |
michael@0 | 142 | { |
michael@0 | 143 | return ReadParam(aMsg, aIter, &aResult->name) && |
michael@0 | 144 | ReadParam(aMsg, aIter, &aResult->id) && |
michael@0 | 145 | ReadParam(aMsg, aIter, &aResult->keyPath) && |
michael@0 | 146 | ReadParam(aMsg, aIter, &aResult->autoIncrement) && |
michael@0 | 147 | ReadParam(aMsg, aIter, &aResult->indexes); |
michael@0 | 148 | } |
michael@0 | 149 | |
michael@0 | 150 | static void Log(const paramType& aParam, std::wstring* aLog) |
michael@0 | 151 | { |
michael@0 | 152 | LogParam(aParam.name, aLog); |
michael@0 | 153 | LogParam(aParam.id, aLog); |
michael@0 | 154 | LogParam(aParam.keyPath, aLog); |
michael@0 | 155 | LogParam(aParam.autoIncrement, aLog); |
michael@0 | 156 | LogParam(aParam.indexes, aLog); |
michael@0 | 157 | } |
michael@0 | 158 | }; |
michael@0 | 159 | |
michael@0 | 160 | template <> |
michael@0 | 161 | struct ParamTraits<mozilla::dom::indexedDB::DatabaseInfoGuts> |
michael@0 | 162 | { |
michael@0 | 163 | typedef mozilla::dom::indexedDB::DatabaseInfoGuts paramType; |
michael@0 | 164 | |
michael@0 | 165 | static void Write(Message* aMsg, const paramType& aParam) |
michael@0 | 166 | { |
michael@0 | 167 | WriteParam(aMsg, aParam.name); |
michael@0 | 168 | WriteParam(aMsg, aParam.group); |
michael@0 | 169 | WriteParam(aMsg, aParam.origin); |
michael@0 | 170 | WriteParam(aMsg, aParam.version); |
michael@0 | 171 | WriteParam(aMsg, aParam.persistenceType); |
michael@0 | 172 | WriteParam(aMsg, aParam.nextObjectStoreId); |
michael@0 | 173 | WriteParam(aMsg, aParam.nextIndexId); |
michael@0 | 174 | } |
michael@0 | 175 | |
michael@0 | 176 | static bool Read(const Message* aMsg, void** aIter, paramType* aResult) |
michael@0 | 177 | { |
michael@0 | 178 | return ReadParam(aMsg, aIter, &aResult->name) && |
michael@0 | 179 | ReadParam(aMsg, aIter, &aResult->group) && |
michael@0 | 180 | ReadParam(aMsg, aIter, &aResult->origin) && |
michael@0 | 181 | ReadParam(aMsg, aIter, &aResult->version) && |
michael@0 | 182 | ReadParam(aMsg, aIter, &aResult->persistenceType) && |
michael@0 | 183 | ReadParam(aMsg, aIter, &aResult->nextObjectStoreId) && |
michael@0 | 184 | ReadParam(aMsg, aIter, &aResult->nextIndexId); |
michael@0 | 185 | } |
michael@0 | 186 | |
michael@0 | 187 | static void Log(const paramType& aParam, std::wstring* aLog) |
michael@0 | 188 | { |
michael@0 | 189 | LogParam(aParam.name, aLog); |
michael@0 | 190 | LogParam(aParam.group, aLog); |
michael@0 | 191 | LogParam(aParam.origin, aLog); |
michael@0 | 192 | LogParam(aParam.version, aLog); |
michael@0 | 193 | LogParam(aParam.nextObjectStoreId, aLog); |
michael@0 | 194 | LogParam(aParam.nextIndexId, aLog); |
michael@0 | 195 | } |
michael@0 | 196 | }; |
michael@0 | 197 | |
michael@0 | 198 | template <> |
michael@0 | 199 | struct ParamTraits<mozilla::dom::indexedDB::IndexUpdateInfo> |
michael@0 | 200 | { |
michael@0 | 201 | typedef mozilla::dom::indexedDB::IndexUpdateInfo paramType; |
michael@0 | 202 | |
michael@0 | 203 | static void Write(Message* aMsg, const paramType& aParam) |
michael@0 | 204 | { |
michael@0 | 205 | WriteParam(aMsg, aParam.indexId); |
michael@0 | 206 | WriteParam(aMsg, aParam.indexUnique); |
michael@0 | 207 | WriteParam(aMsg, aParam.value); |
michael@0 | 208 | } |
michael@0 | 209 | |
michael@0 | 210 | static bool Read(const Message* aMsg, void** aIter, paramType* aResult) |
michael@0 | 211 | { |
michael@0 | 212 | return ReadParam(aMsg, aIter, &aResult->indexId) && |
michael@0 | 213 | ReadParam(aMsg, aIter, &aResult->indexUnique) && |
michael@0 | 214 | ReadParam(aMsg, aIter, &aResult->value); |
michael@0 | 215 | } |
michael@0 | 216 | |
michael@0 | 217 | static void Log(const paramType& aParam, std::wstring* aLog) |
michael@0 | 218 | { |
michael@0 | 219 | LogParam(aParam.indexId, aLog); |
michael@0 | 220 | LogParam(aParam.indexUnique, aLog); |
michael@0 | 221 | LogParam(aParam.value, aLog); |
michael@0 | 222 | } |
michael@0 | 223 | }; |
michael@0 | 224 | |
michael@0 | 225 | template <> |
michael@0 | 226 | struct ParamTraits<mozilla::dom::indexedDB::SerializedStructuredCloneReadInfo> |
michael@0 | 227 | { |
michael@0 | 228 | typedef mozilla::dom::indexedDB::SerializedStructuredCloneReadInfo paramType; |
michael@0 | 229 | |
michael@0 | 230 | static void Write(Message* aMsg, const paramType& aParam) |
michael@0 | 231 | { |
michael@0 | 232 | WriteParam(aMsg, aParam.dataLength); |
michael@0 | 233 | if (aParam.dataLength) { |
michael@0 | 234 | aMsg->WriteBytes(aParam.data, aParam.dataLength); |
michael@0 | 235 | } |
michael@0 | 236 | } |
michael@0 | 237 | |
michael@0 | 238 | static bool Read(const Message* aMsg, void** aIter, paramType* aResult) |
michael@0 | 239 | { |
michael@0 | 240 | if (!ReadParam(aMsg, aIter, &aResult->dataLength)) { |
michael@0 | 241 | return false; |
michael@0 | 242 | } |
michael@0 | 243 | |
michael@0 | 244 | if (aResult->dataLength) { |
michael@0 | 245 | const char** buffer = |
michael@0 | 246 | const_cast<const char**>(reinterpret_cast<char**>(&aResult->data)); |
michael@0 | 247 | if (!aMsg->ReadBytes(aIter, buffer, aResult->dataLength)) { |
michael@0 | 248 | return false; |
michael@0 | 249 | } |
michael@0 | 250 | } else { |
michael@0 | 251 | aResult->data = nullptr; |
michael@0 | 252 | } |
michael@0 | 253 | |
michael@0 | 254 | return true; |
michael@0 | 255 | } |
michael@0 | 256 | |
michael@0 | 257 | static void Log(const paramType& aParam, std::wstring* aLog) |
michael@0 | 258 | { |
michael@0 | 259 | LogParam(aParam.dataLength, aLog); |
michael@0 | 260 | } |
michael@0 | 261 | }; |
michael@0 | 262 | |
michael@0 | 263 | template <> |
michael@0 | 264 | struct ParamTraits<mozilla::dom::indexedDB::SerializedStructuredCloneWriteInfo> |
michael@0 | 265 | { |
michael@0 | 266 | typedef mozilla::dom::indexedDB::SerializedStructuredCloneWriteInfo paramType; |
michael@0 | 267 | |
michael@0 | 268 | static void Write(Message* aMsg, const paramType& aParam) |
michael@0 | 269 | { |
michael@0 | 270 | WriteParam(aMsg, aParam.dataLength); |
michael@0 | 271 | if (aParam.dataLength) { |
michael@0 | 272 | aMsg->WriteBytes(aParam.data, aParam.dataLength); |
michael@0 | 273 | } |
michael@0 | 274 | WriteParam(aMsg, aParam.offsetToKeyProp); |
michael@0 | 275 | } |
michael@0 | 276 | |
michael@0 | 277 | static bool Read(const Message* aMsg, void** aIter, paramType* aResult) |
michael@0 | 278 | { |
michael@0 | 279 | if (!ReadParam(aMsg, aIter, &aResult->dataLength)) { |
michael@0 | 280 | return false; |
michael@0 | 281 | } |
michael@0 | 282 | |
michael@0 | 283 | if (aResult->dataLength) { |
michael@0 | 284 | const char** buffer = |
michael@0 | 285 | const_cast<const char**>(reinterpret_cast<char**>(&aResult->data)); |
michael@0 | 286 | if (!aMsg->ReadBytes(aIter, buffer, aResult->dataLength)) { |
michael@0 | 287 | return false; |
michael@0 | 288 | } |
michael@0 | 289 | } else { |
michael@0 | 290 | aResult->data = nullptr; |
michael@0 | 291 | } |
michael@0 | 292 | |
michael@0 | 293 | if (!ReadParam(aMsg, aIter, &aResult->offsetToKeyProp)) { |
michael@0 | 294 | return false; |
michael@0 | 295 | } |
michael@0 | 296 | |
michael@0 | 297 | return true; |
michael@0 | 298 | } |
michael@0 | 299 | |
michael@0 | 300 | static void Log(const paramType& aParam, std::wstring* aLog) |
michael@0 | 301 | { |
michael@0 | 302 | LogParam(aParam.dataLength, aLog); |
michael@0 | 303 | LogParam(aParam.offsetToKeyProp, aLog); |
michael@0 | 304 | } |
michael@0 | 305 | }; |
michael@0 | 306 | |
michael@0 | 307 | } // namespace IPC |
michael@0 | 308 | |
michael@0 | 309 | #endif // mozilla_dom_indexeddb_serializationhelpers_h__ |