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