1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/indexedDB/IndexedDatabase.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,156 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set ts=2 et sw=2 tw=80: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef mozilla_dom_indexeddb_indexeddatabase_h__ 1.11 +#define mozilla_dom_indexeddb_indexeddatabase_h__ 1.12 + 1.13 +#include "nsIProgrammingLanguage.h" 1.14 + 1.15 +#include "mozilla/Attributes.h" 1.16 +#include "js/StructuredClone.h" 1.17 +#include "nsAutoPtr.h" 1.18 +#include "nsCOMPtr.h" 1.19 +#include "nsDebug.h" 1.20 +#include "nsError.h" 1.21 +#include "nsString.h" 1.22 +#include "nsTArray.h" 1.23 +#include "nsIInputStream.h" 1.24 + 1.25 +#define BEGIN_INDEXEDDB_NAMESPACE \ 1.26 + namespace mozilla { namespace dom { namespace indexedDB { 1.27 + 1.28 +#define END_INDEXEDDB_NAMESPACE \ 1.29 + } /* namespace indexedDB */ } /* namepsace dom */ } /* namespace mozilla */ 1.30 + 1.31 +#define USING_INDEXEDDB_NAMESPACE \ 1.32 + using namespace mozilla::dom::indexedDB; 1.33 + 1.34 +class nsIDOMBlob; 1.35 + 1.36 +BEGIN_INDEXEDDB_NAMESPACE 1.37 + 1.38 +class FileInfo; 1.39 +class IDBDatabase; 1.40 +class IDBTransaction; 1.41 + 1.42 +struct StructuredCloneFile 1.43 +{ 1.44 + bool operator==(const StructuredCloneFile& aOther) const 1.45 + { 1.46 + return this->mFile == aOther.mFile && 1.47 + this->mFileInfo == aOther.mFileInfo && 1.48 + this->mInputStream == aOther.mInputStream; 1.49 + } 1.50 + 1.51 + nsCOMPtr<nsIDOMBlob> mFile; 1.52 + nsRefPtr<FileInfo> mFileInfo; 1.53 + nsCOMPtr<nsIInputStream> mInputStream; 1.54 +}; 1.55 + 1.56 +struct SerializedStructuredCloneReadInfo; 1.57 + 1.58 +struct StructuredCloneReadInfo 1.59 +{ 1.60 + // In IndexedDatabaseInlines.h 1.61 + inline StructuredCloneReadInfo(); 1.62 + 1.63 + inline StructuredCloneReadInfo& 1.64 + operator=(StructuredCloneReadInfo&& aCloneReadInfo); 1.65 + 1.66 + // In IndexedDatabaseInlines.h 1.67 + inline bool 1.68 + SetFromSerialized(const SerializedStructuredCloneReadInfo& aOther); 1.69 + 1.70 + JSAutoStructuredCloneBuffer mCloneBuffer; 1.71 + nsTArray<StructuredCloneFile> mFiles; 1.72 + IDBDatabase* mDatabase; 1.73 +}; 1.74 + 1.75 +struct SerializedStructuredCloneReadInfo 1.76 +{ 1.77 + SerializedStructuredCloneReadInfo() 1.78 + : data(nullptr), dataLength(0) 1.79 + { } 1.80 + 1.81 + bool 1.82 + operator==(const SerializedStructuredCloneReadInfo& aOther) const 1.83 + { 1.84 + return this->data == aOther.data && 1.85 + this->dataLength == aOther.dataLength; 1.86 + } 1.87 + 1.88 + SerializedStructuredCloneReadInfo& 1.89 + operator=(const StructuredCloneReadInfo& aOther) 1.90 + { 1.91 + data = aOther.mCloneBuffer.data(); 1.92 + dataLength = aOther.mCloneBuffer.nbytes(); 1.93 + return *this; 1.94 + } 1.95 + 1.96 + // Make sure to update ipc/SerializationHelpers.h when changing members here! 1.97 + uint64_t* data; 1.98 + size_t dataLength; 1.99 +}; 1.100 + 1.101 +struct SerializedStructuredCloneWriteInfo; 1.102 + 1.103 +struct StructuredCloneWriteInfo 1.104 +{ 1.105 + // In IndexedDatabaseInlines.h 1.106 + inline StructuredCloneWriteInfo(); 1.107 + inline StructuredCloneWriteInfo(StructuredCloneWriteInfo&& aCloneWriteInfo); 1.108 + 1.109 + bool operator==(const StructuredCloneWriteInfo& aOther) const 1.110 + { 1.111 + return this->mCloneBuffer.nbytes() == aOther.mCloneBuffer.nbytes() && 1.112 + this->mCloneBuffer.data() == aOther.mCloneBuffer.data() && 1.113 + this->mFiles == aOther.mFiles && 1.114 + this->mTransaction == aOther.mTransaction && 1.115 + this->mOffsetToKeyProp == aOther.mOffsetToKeyProp; 1.116 + } 1.117 + 1.118 + // In IndexedDatabaseInlines.h 1.119 + inline bool 1.120 + SetFromSerialized(const SerializedStructuredCloneWriteInfo& aOther); 1.121 + 1.122 + JSAutoStructuredCloneBuffer mCloneBuffer; 1.123 + nsTArray<StructuredCloneFile> mFiles; 1.124 + IDBTransaction* mTransaction; 1.125 + uint64_t mOffsetToKeyProp; 1.126 +}; 1.127 + 1.128 +struct SerializedStructuredCloneWriteInfo 1.129 +{ 1.130 + SerializedStructuredCloneWriteInfo() 1.131 + : data(nullptr), dataLength(0), offsetToKeyProp(0) 1.132 + { } 1.133 + 1.134 + bool 1.135 + operator==(const SerializedStructuredCloneWriteInfo& aOther) const 1.136 + { 1.137 + return this->data == aOther.data && 1.138 + this->dataLength == aOther.dataLength && 1.139 + this->offsetToKeyProp == aOther.offsetToKeyProp; 1.140 + } 1.141 + 1.142 + SerializedStructuredCloneWriteInfo& 1.143 + operator=(const StructuredCloneWriteInfo& aOther) 1.144 + { 1.145 + data = aOther.mCloneBuffer.data(); 1.146 + dataLength = aOther.mCloneBuffer.nbytes(); 1.147 + offsetToKeyProp = aOther.mOffsetToKeyProp; 1.148 + return *this; 1.149 + } 1.150 + 1.151 + // Make sure to update ipc/SerializationHelpers.h when changing members here! 1.152 + uint64_t* data; 1.153 + size_t dataLength; 1.154 + uint64_t offsetToKeyProp; 1.155 +}; 1.156 + 1.157 +END_INDEXEDDB_NAMESPACE 1.158 + 1.159 +#endif // mozilla_dom_indexeddb_indexeddatabase_h__