michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_indexeddb_indexeddatabase_h__ michael@0: #define mozilla_dom_indexeddb_indexeddatabase_h__ michael@0: michael@0: #include "nsIProgrammingLanguage.h" michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "js/StructuredClone.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsDebug.h" michael@0: #include "nsError.h" michael@0: #include "nsString.h" michael@0: #include "nsTArray.h" michael@0: #include "nsIInputStream.h" michael@0: michael@0: #define BEGIN_INDEXEDDB_NAMESPACE \ michael@0: namespace mozilla { namespace dom { namespace indexedDB { michael@0: michael@0: #define END_INDEXEDDB_NAMESPACE \ michael@0: } /* namespace indexedDB */ } /* namepsace dom */ } /* namespace mozilla */ michael@0: michael@0: #define USING_INDEXEDDB_NAMESPACE \ michael@0: using namespace mozilla::dom::indexedDB; michael@0: michael@0: class nsIDOMBlob; michael@0: michael@0: BEGIN_INDEXEDDB_NAMESPACE michael@0: michael@0: class FileInfo; michael@0: class IDBDatabase; michael@0: class IDBTransaction; michael@0: michael@0: struct StructuredCloneFile michael@0: { michael@0: bool operator==(const StructuredCloneFile& aOther) const michael@0: { michael@0: return this->mFile == aOther.mFile && michael@0: this->mFileInfo == aOther.mFileInfo && michael@0: this->mInputStream == aOther.mInputStream; michael@0: } michael@0: michael@0: nsCOMPtr mFile; michael@0: nsRefPtr mFileInfo; michael@0: nsCOMPtr mInputStream; michael@0: }; michael@0: michael@0: struct SerializedStructuredCloneReadInfo; michael@0: michael@0: struct StructuredCloneReadInfo michael@0: { michael@0: // In IndexedDatabaseInlines.h michael@0: inline StructuredCloneReadInfo(); michael@0: michael@0: inline StructuredCloneReadInfo& michael@0: operator=(StructuredCloneReadInfo&& aCloneReadInfo); michael@0: michael@0: // In IndexedDatabaseInlines.h michael@0: inline bool michael@0: SetFromSerialized(const SerializedStructuredCloneReadInfo& aOther); michael@0: michael@0: JSAutoStructuredCloneBuffer mCloneBuffer; michael@0: nsTArray mFiles; michael@0: IDBDatabase* mDatabase; michael@0: }; michael@0: michael@0: struct SerializedStructuredCloneReadInfo michael@0: { michael@0: SerializedStructuredCloneReadInfo() michael@0: : data(nullptr), dataLength(0) michael@0: { } michael@0: michael@0: bool michael@0: operator==(const SerializedStructuredCloneReadInfo& aOther) const michael@0: { michael@0: return this->data == aOther.data && michael@0: this->dataLength == aOther.dataLength; michael@0: } michael@0: michael@0: SerializedStructuredCloneReadInfo& michael@0: operator=(const StructuredCloneReadInfo& aOther) michael@0: { michael@0: data = aOther.mCloneBuffer.data(); michael@0: dataLength = aOther.mCloneBuffer.nbytes(); michael@0: return *this; michael@0: } michael@0: michael@0: // Make sure to update ipc/SerializationHelpers.h when changing members here! michael@0: uint64_t* data; michael@0: size_t dataLength; michael@0: }; michael@0: michael@0: struct SerializedStructuredCloneWriteInfo; michael@0: michael@0: struct StructuredCloneWriteInfo michael@0: { michael@0: // In IndexedDatabaseInlines.h michael@0: inline StructuredCloneWriteInfo(); michael@0: inline StructuredCloneWriteInfo(StructuredCloneWriteInfo&& aCloneWriteInfo); michael@0: michael@0: bool operator==(const StructuredCloneWriteInfo& aOther) const michael@0: { michael@0: return this->mCloneBuffer.nbytes() == aOther.mCloneBuffer.nbytes() && michael@0: this->mCloneBuffer.data() == aOther.mCloneBuffer.data() && michael@0: this->mFiles == aOther.mFiles && michael@0: this->mTransaction == aOther.mTransaction && michael@0: this->mOffsetToKeyProp == aOther.mOffsetToKeyProp; michael@0: } michael@0: michael@0: // In IndexedDatabaseInlines.h michael@0: inline bool michael@0: SetFromSerialized(const SerializedStructuredCloneWriteInfo& aOther); michael@0: michael@0: JSAutoStructuredCloneBuffer mCloneBuffer; michael@0: nsTArray mFiles; michael@0: IDBTransaction* mTransaction; michael@0: uint64_t mOffsetToKeyProp; michael@0: }; michael@0: michael@0: struct SerializedStructuredCloneWriteInfo michael@0: { michael@0: SerializedStructuredCloneWriteInfo() michael@0: : data(nullptr), dataLength(0), offsetToKeyProp(0) michael@0: { } michael@0: michael@0: bool michael@0: operator==(const SerializedStructuredCloneWriteInfo& aOther) const michael@0: { michael@0: return this->data == aOther.data && michael@0: this->dataLength == aOther.dataLength && michael@0: this->offsetToKeyProp == aOther.offsetToKeyProp; michael@0: } michael@0: michael@0: SerializedStructuredCloneWriteInfo& michael@0: operator=(const StructuredCloneWriteInfo& aOther) michael@0: { michael@0: data = aOther.mCloneBuffer.data(); michael@0: dataLength = aOther.mCloneBuffer.nbytes(); michael@0: offsetToKeyProp = aOther.mOffsetToKeyProp; michael@0: return *this; michael@0: } michael@0: michael@0: // Make sure to update ipc/SerializationHelpers.h when changing members here! michael@0: uint64_t* data; michael@0: size_t dataLength; michael@0: uint64_t offsetToKeyProp; michael@0: }; michael@0: michael@0: END_INDEXEDDB_NAMESPACE michael@0: michael@0: #endif // mozilla_dom_indexeddb_indexeddatabase_h__