dom/indexedDB/IndexedDatabase.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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 "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"
    22 #define BEGIN_INDEXEDDB_NAMESPACE \
    23   namespace mozilla { namespace dom { namespace indexedDB {
    25 #define END_INDEXEDDB_NAMESPACE \
    26   } /* namespace indexedDB */ } /* namepsace dom */ } /* namespace mozilla */
    28 #define USING_INDEXEDDB_NAMESPACE \
    29   using namespace mozilla::dom::indexedDB;
    31 class nsIDOMBlob;
    33 BEGIN_INDEXEDDB_NAMESPACE
    35 class FileInfo;
    36 class IDBDatabase;
    37 class IDBTransaction;
    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   }
    48   nsCOMPtr<nsIDOMBlob> mFile;
    49   nsRefPtr<FileInfo> mFileInfo;
    50   nsCOMPtr<nsIInputStream> mInputStream;
    51 };
    53 struct SerializedStructuredCloneReadInfo;
    55 struct StructuredCloneReadInfo
    56 {
    57   // In IndexedDatabaseInlines.h
    58   inline StructuredCloneReadInfo();
    60   inline StructuredCloneReadInfo&
    61   operator=(StructuredCloneReadInfo&& aCloneReadInfo);
    63   // In IndexedDatabaseInlines.h
    64   inline bool
    65   SetFromSerialized(const SerializedStructuredCloneReadInfo& aOther);
    67   JSAutoStructuredCloneBuffer mCloneBuffer;
    68   nsTArray<StructuredCloneFile> mFiles;
    69   IDBDatabase* mDatabase;
    70 };
    72 struct SerializedStructuredCloneReadInfo
    73 {
    74   SerializedStructuredCloneReadInfo()
    75   : data(nullptr), dataLength(0)
    76   { }
    78   bool
    79   operator==(const SerializedStructuredCloneReadInfo& aOther) const
    80   {
    81     return this->data == aOther.data &&
    82            this->dataLength == aOther.dataLength;
    83   }
    85   SerializedStructuredCloneReadInfo&
    86   operator=(const StructuredCloneReadInfo& aOther)
    87   {
    88     data = aOther.mCloneBuffer.data();
    89     dataLength = aOther.mCloneBuffer.nbytes();
    90     return *this;
    91   }
    93   // Make sure to update ipc/SerializationHelpers.h when changing members here!
    94   uint64_t* data;
    95   size_t dataLength;
    96 };
    98 struct SerializedStructuredCloneWriteInfo;
   100 struct StructuredCloneWriteInfo
   101 {
   102   // In IndexedDatabaseInlines.h
   103   inline StructuredCloneWriteInfo();
   104   inline StructuredCloneWriteInfo(StructuredCloneWriteInfo&& aCloneWriteInfo);
   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   }
   115   // In IndexedDatabaseInlines.h
   116   inline bool
   117   SetFromSerialized(const SerializedStructuredCloneWriteInfo& aOther);
   119   JSAutoStructuredCloneBuffer mCloneBuffer;
   120   nsTArray<StructuredCloneFile> mFiles;
   121   IDBTransaction* mTransaction;
   122   uint64_t mOffsetToKeyProp;
   123 };
   125 struct SerializedStructuredCloneWriteInfo
   126 {
   127   SerializedStructuredCloneWriteInfo()
   128   : data(nullptr), dataLength(0), offsetToKeyProp(0)
   129   { }
   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   }
   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   }
   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 };
   154 END_INDEXEDDB_NAMESPACE
   156 #endif // mozilla_dom_indexeddb_indexeddatabase_h__

mercurial