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"
14 #include "nsAutoPtr.h"
18 #include "nsStringGlue.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;
33 BEGIN_INDEXEDDB_NAMESPACE
40 void SwapData(T
& aData1
, T
& aData2
)
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
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)
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();
105 // Make sure to update ipc/SerializationHelpers.h when changing members here!
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
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)
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
;
167 // Make sure to update ipc/SerializationHelpers.h when changing members here!
170 uint64_t offsetToKeyProp
;
173 END_INDEXEDDB_NAMESPACE
175 #endif // mozilla_dom_indexeddb_indexeddatabase_h__