bug 700693 - OCSP stapling PSM changes r=bsmith
[gecko.git] / dom / indexedDB / IndexedDatabase.h
blobb0ea8965f6c983e5c2bdd4b3de6707a3c74f3acb
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/. */
7 #ifndef mozilla_dom_indexeddb_indexeddatabase_h__
8 #define mozilla_dom_indexeddb_indexeddatabase_h__
10 #include "nsIProgrammingLanguage.h"
12 #include "mozilla/Attributes.h"
13 #include "jsapi.h"
14 #include "nsAutoPtr.h"
15 #include "nsCOMPtr.h"
16 #include "nsDebug.h"
17 #include "nsError.h"
18 #include "nsStringGlue.h"
19 #include "nsTArray.h"
21 #define BEGIN_INDEXEDDB_NAMESPACE \
22 namespace mozilla { namespace dom { namespace indexedDB {
24 #define END_INDEXEDDB_NAMESPACE \
25 } /* namespace indexedDB */ } /* namepsace dom */ } /* namespace mozilla */
27 #define USING_INDEXEDDB_NAMESPACE \
28 using namespace mozilla::dom::indexedDB;
30 class nsIDOMBlob;
31 class nsIInputStream;
33 BEGIN_INDEXEDDB_NAMESPACE
35 class FileInfo;
36 class IDBDatabase;
37 class IDBTransaction;
39 template <class T>
40 void SwapData(T& aData1, T& aData2)
42 T temp = aData2;
43 aData2 = aData1;
44 aData1 = temp;
47 struct StructuredCloneFile
49 bool operator==(const StructuredCloneFile& aOther) const
51 return this->mFile == aOther.mFile &&
52 this->mFileInfo == aOther.mFileInfo &&
53 this->mInputStream == aOther.mInputStream;
56 nsCOMPtr<nsIDOMBlob> mFile;
57 nsRefPtr<FileInfo> mFileInfo;
58 nsCOMPtr<nsIInputStream> mInputStream;
61 struct SerializedStructuredCloneReadInfo;
63 struct StructuredCloneReadInfo
65 // In IndexedDatabaseInlines.h
66 inline StructuredCloneReadInfo();
68 void Swap(StructuredCloneReadInfo& aCloneReadInfo)
70 mCloneBuffer.swap(aCloneReadInfo.mCloneBuffer);
71 mFiles.SwapElements(aCloneReadInfo.mFiles);
72 SwapData(mDatabase, aCloneReadInfo.mDatabase);
75 // In IndexedDatabaseInlines.h
76 inline bool
77 SetFromSerialized(const SerializedStructuredCloneReadInfo& aOther);
79 JSAutoStructuredCloneBuffer mCloneBuffer;
80 nsTArray<StructuredCloneFile> mFiles;
81 IDBDatabase* mDatabase;
84 struct SerializedStructuredCloneReadInfo
86 SerializedStructuredCloneReadInfo()
87 : data(nullptr), dataLength(0)
88 { }
90 bool
91 operator==(const SerializedStructuredCloneReadInfo& aOther) const
93 return this->data == aOther.data &&
94 this->dataLength == aOther.dataLength;
97 SerializedStructuredCloneReadInfo&
98 operator=(const StructuredCloneReadInfo& aOther)
100 data = aOther.mCloneBuffer.data();
101 dataLength = aOther.mCloneBuffer.nbytes();
102 return *this;
105 // Make sure to update ipc/SerializationHelpers.h when changing members here!
106 uint64_t* data;
107 size_t dataLength;
110 struct SerializedStructuredCloneWriteInfo;
112 struct StructuredCloneWriteInfo
114 // In IndexedDatabaseInlines.h
115 inline StructuredCloneWriteInfo();
117 void Swap(StructuredCloneWriteInfo& aCloneWriteInfo)
119 mCloneBuffer.swap(aCloneWriteInfo.mCloneBuffer);
120 mFiles.SwapElements(aCloneWriteInfo.mFiles);
121 SwapData(mTransaction, aCloneWriteInfo.mTransaction);
122 SwapData(mOffsetToKeyProp, aCloneWriteInfo.mOffsetToKeyProp);
125 bool operator==(const StructuredCloneWriteInfo& aOther) const
127 return this->mCloneBuffer.nbytes() == aOther.mCloneBuffer.nbytes() &&
128 this->mCloneBuffer.data() == aOther.mCloneBuffer.data() &&
129 this->mFiles == aOther.mFiles &&
130 this->mTransaction == aOther.mTransaction &&
131 this->mOffsetToKeyProp == aOther.mOffsetToKeyProp;
134 // In IndexedDatabaseInlines.h
135 inline bool
136 SetFromSerialized(const SerializedStructuredCloneWriteInfo& aOther);
138 JSAutoStructuredCloneBuffer mCloneBuffer;
139 nsTArray<StructuredCloneFile> mFiles;
140 IDBTransaction* mTransaction;
141 uint64_t mOffsetToKeyProp;
144 struct SerializedStructuredCloneWriteInfo
146 SerializedStructuredCloneWriteInfo()
147 : data(nullptr), dataLength(0), offsetToKeyProp(0)
150 bool
151 operator==(const SerializedStructuredCloneWriteInfo& aOther) const
153 return this->data == aOther.data &&
154 this->dataLength == aOther.dataLength &&
155 this->offsetToKeyProp == aOther.offsetToKeyProp;
158 SerializedStructuredCloneWriteInfo&
159 operator=(const StructuredCloneWriteInfo& aOther)
161 data = aOther.mCloneBuffer.data();
162 dataLength = aOther.mCloneBuffer.nbytes();
163 offsetToKeyProp = aOther.mOffsetToKeyProp;
164 return *this;
167 // Make sure to update ipc/SerializationHelpers.h when changing members here!
168 uint64_t* data;
169 size_t dataLength;
170 uint64_t offsetToKeyProp;
173 END_INDEXEDDB_NAMESPACE
175 #endif // mozilla_dom_indexeddb_indexeddatabase_h__