Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim: set ts=2 et sw=2 tw=80: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef mozilla_dom_indexeddb_indexeddatabase_h__ |
michael@0 | 8 | #define mozilla_dom_indexeddb_indexeddatabase_h__ |
michael@0 | 9 | |
michael@0 | 10 | #include "nsIProgrammingLanguage.h" |
michael@0 | 11 | |
michael@0 | 12 | #include "mozilla/Attributes.h" |
michael@0 | 13 | #include "js/StructuredClone.h" |
michael@0 | 14 | #include "nsAutoPtr.h" |
michael@0 | 15 | #include "nsCOMPtr.h" |
michael@0 | 16 | #include "nsDebug.h" |
michael@0 | 17 | #include "nsError.h" |
michael@0 | 18 | #include "nsString.h" |
michael@0 | 19 | #include "nsTArray.h" |
michael@0 | 20 | #include "nsIInputStream.h" |
michael@0 | 21 | |
michael@0 | 22 | #define BEGIN_INDEXEDDB_NAMESPACE \ |
michael@0 | 23 | namespace mozilla { namespace dom { namespace indexedDB { |
michael@0 | 24 | |
michael@0 | 25 | #define END_INDEXEDDB_NAMESPACE \ |
michael@0 | 26 | } /* namespace indexedDB */ } /* namepsace dom */ } /* namespace mozilla */ |
michael@0 | 27 | |
michael@0 | 28 | #define USING_INDEXEDDB_NAMESPACE \ |
michael@0 | 29 | using namespace mozilla::dom::indexedDB; |
michael@0 | 30 | |
michael@0 | 31 | class nsIDOMBlob; |
michael@0 | 32 | |
michael@0 | 33 | BEGIN_INDEXEDDB_NAMESPACE |
michael@0 | 34 | |
michael@0 | 35 | class FileInfo; |
michael@0 | 36 | class IDBDatabase; |
michael@0 | 37 | class IDBTransaction; |
michael@0 | 38 | |
michael@0 | 39 | struct StructuredCloneFile |
michael@0 | 40 | { |
michael@0 | 41 | bool operator==(const StructuredCloneFile& aOther) const |
michael@0 | 42 | { |
michael@0 | 43 | return this->mFile == aOther.mFile && |
michael@0 | 44 | this->mFileInfo == aOther.mFileInfo && |
michael@0 | 45 | this->mInputStream == aOther.mInputStream; |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | nsCOMPtr<nsIDOMBlob> mFile; |
michael@0 | 49 | nsRefPtr<FileInfo> mFileInfo; |
michael@0 | 50 | nsCOMPtr<nsIInputStream> mInputStream; |
michael@0 | 51 | }; |
michael@0 | 52 | |
michael@0 | 53 | struct SerializedStructuredCloneReadInfo; |
michael@0 | 54 | |
michael@0 | 55 | struct StructuredCloneReadInfo |
michael@0 | 56 | { |
michael@0 | 57 | // In IndexedDatabaseInlines.h |
michael@0 | 58 | inline StructuredCloneReadInfo(); |
michael@0 | 59 | |
michael@0 | 60 | inline StructuredCloneReadInfo& |
michael@0 | 61 | operator=(StructuredCloneReadInfo&& aCloneReadInfo); |
michael@0 | 62 | |
michael@0 | 63 | // In IndexedDatabaseInlines.h |
michael@0 | 64 | inline bool |
michael@0 | 65 | SetFromSerialized(const SerializedStructuredCloneReadInfo& aOther); |
michael@0 | 66 | |
michael@0 | 67 | JSAutoStructuredCloneBuffer mCloneBuffer; |
michael@0 | 68 | nsTArray<StructuredCloneFile> mFiles; |
michael@0 | 69 | IDBDatabase* mDatabase; |
michael@0 | 70 | }; |
michael@0 | 71 | |
michael@0 | 72 | struct SerializedStructuredCloneReadInfo |
michael@0 | 73 | { |
michael@0 | 74 | SerializedStructuredCloneReadInfo() |
michael@0 | 75 | : data(nullptr), dataLength(0) |
michael@0 | 76 | { } |
michael@0 | 77 | |
michael@0 | 78 | bool |
michael@0 | 79 | operator==(const SerializedStructuredCloneReadInfo& aOther) const |
michael@0 | 80 | { |
michael@0 | 81 | return this->data == aOther.data && |
michael@0 | 82 | this->dataLength == aOther.dataLength; |
michael@0 | 83 | } |
michael@0 | 84 | |
michael@0 | 85 | SerializedStructuredCloneReadInfo& |
michael@0 | 86 | operator=(const StructuredCloneReadInfo& aOther) |
michael@0 | 87 | { |
michael@0 | 88 | data = aOther.mCloneBuffer.data(); |
michael@0 | 89 | dataLength = aOther.mCloneBuffer.nbytes(); |
michael@0 | 90 | return *this; |
michael@0 | 91 | } |
michael@0 | 92 | |
michael@0 | 93 | // Make sure to update ipc/SerializationHelpers.h when changing members here! |
michael@0 | 94 | uint64_t* data; |
michael@0 | 95 | size_t dataLength; |
michael@0 | 96 | }; |
michael@0 | 97 | |
michael@0 | 98 | struct SerializedStructuredCloneWriteInfo; |
michael@0 | 99 | |
michael@0 | 100 | struct StructuredCloneWriteInfo |
michael@0 | 101 | { |
michael@0 | 102 | // In IndexedDatabaseInlines.h |
michael@0 | 103 | inline StructuredCloneWriteInfo(); |
michael@0 | 104 | inline StructuredCloneWriteInfo(StructuredCloneWriteInfo&& aCloneWriteInfo); |
michael@0 | 105 | |
michael@0 | 106 | bool operator==(const StructuredCloneWriteInfo& aOther) const |
michael@0 | 107 | { |
michael@0 | 108 | return this->mCloneBuffer.nbytes() == aOther.mCloneBuffer.nbytes() && |
michael@0 | 109 | this->mCloneBuffer.data() == aOther.mCloneBuffer.data() && |
michael@0 | 110 | this->mFiles == aOther.mFiles && |
michael@0 | 111 | this->mTransaction == aOther.mTransaction && |
michael@0 | 112 | this->mOffsetToKeyProp == aOther.mOffsetToKeyProp; |
michael@0 | 113 | } |
michael@0 | 114 | |
michael@0 | 115 | // In IndexedDatabaseInlines.h |
michael@0 | 116 | inline bool |
michael@0 | 117 | SetFromSerialized(const SerializedStructuredCloneWriteInfo& aOther); |
michael@0 | 118 | |
michael@0 | 119 | JSAutoStructuredCloneBuffer mCloneBuffer; |
michael@0 | 120 | nsTArray<StructuredCloneFile> mFiles; |
michael@0 | 121 | IDBTransaction* mTransaction; |
michael@0 | 122 | uint64_t mOffsetToKeyProp; |
michael@0 | 123 | }; |
michael@0 | 124 | |
michael@0 | 125 | struct SerializedStructuredCloneWriteInfo |
michael@0 | 126 | { |
michael@0 | 127 | SerializedStructuredCloneWriteInfo() |
michael@0 | 128 | : data(nullptr), dataLength(0), offsetToKeyProp(0) |
michael@0 | 129 | { } |
michael@0 | 130 | |
michael@0 | 131 | bool |
michael@0 | 132 | operator==(const SerializedStructuredCloneWriteInfo& aOther) const |
michael@0 | 133 | { |
michael@0 | 134 | return this->data == aOther.data && |
michael@0 | 135 | this->dataLength == aOther.dataLength && |
michael@0 | 136 | this->offsetToKeyProp == aOther.offsetToKeyProp; |
michael@0 | 137 | } |
michael@0 | 138 | |
michael@0 | 139 | SerializedStructuredCloneWriteInfo& |
michael@0 | 140 | operator=(const StructuredCloneWriteInfo& aOther) |
michael@0 | 141 | { |
michael@0 | 142 | data = aOther.mCloneBuffer.data(); |
michael@0 | 143 | dataLength = aOther.mCloneBuffer.nbytes(); |
michael@0 | 144 | offsetToKeyProp = aOther.mOffsetToKeyProp; |
michael@0 | 145 | return *this; |
michael@0 | 146 | } |
michael@0 | 147 | |
michael@0 | 148 | // Make sure to update ipc/SerializationHelpers.h when changing members here! |
michael@0 | 149 | uint64_t* data; |
michael@0 | 150 | size_t dataLength; |
michael@0 | 151 | uint64_t offsetToKeyProp; |
michael@0 | 152 | }; |
michael@0 | 153 | |
michael@0 | 154 | END_INDEXEDDB_NAMESPACE |
michael@0 | 155 | |
michael@0 | 156 | #endif // mozilla_dom_indexeddb_indexeddatabase_h__ |