dom/indexedDB/IDBIndex.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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_idbindex_h__
     8 #define mozilla_dom_indexeddb_idbindex_h__
    10 #include "mozilla/dom/indexedDB/IndexedDatabase.h"
    12 #include "mozilla/Attributes.h"
    13 #include "mozilla/dom/IDBCursorBinding.h"
    14 #include "mozilla/ErrorResult.h"
    15 #include "nsCycleCollectionParticipant.h"
    16 #include "nsWrapperCache.h"
    18 #include "mozilla/dom/indexedDB/IDBObjectStore.h"
    19 #include "mozilla/dom/indexedDB/IDBRequest.h"
    20 #include "mozilla/dom/indexedDB/KeyPath.h"
    22 class nsIScriptContext;
    23 class nsPIDOMWindow;
    25 BEGIN_INDEXEDDB_NAMESPACE
    27 class AsyncConnectionHelper;
    28 class IDBCursor;
    29 class IDBKeyRange;
    30 class IDBObjectStore;
    31 class IDBRequest;
    32 class IndexedDBIndexChild;
    33 class IndexedDBIndexParent;
    34 class Key;
    36 struct IndexInfo;
    38 class IDBIndex MOZ_FINAL : public nsISupports,
    39                            public nsWrapperCache
    40 {
    41 public:
    42   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
    43   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IDBIndex)
    45   static already_AddRefed<IDBIndex>
    46   Create(IDBObjectStore* aObjectStore,
    47          const IndexInfo* aIndexInfo,
    48          bool aCreating);
    50   IDBObjectStore* ObjectStore()
    51   {
    52     return mObjectStore;
    53   }
    55   const int64_t Id() const
    56   {
    57     return mId;
    58   }
    60   const nsString& Name() const
    61   {
    62     return mName;
    63   }
    65   bool IsUnique() const
    66   {
    67     return mUnique;
    68   }
    70   bool IsMultiEntry() const
    71   {
    72     return mMultiEntry;
    73   }
    75   const KeyPath& GetKeyPath() const
    76   {
    77     return mKeyPath;
    78   }
    80   void
    81   SetActor(IndexedDBIndexChild* aActorChild)
    82   {
    83     NS_ASSERTION(!aActorChild || !mActorChild, "Shouldn't have more than one!");
    84     mActorChild = aActorChild;
    85   }
    87   void
    88   SetActor(IndexedDBIndexParent* aActorParent)
    89   {
    90     NS_ASSERTION(!aActorParent || !mActorParent,
    91                  "Shouldn't have more than one!");
    92     mActorParent = aActorParent;
    93   }
    95   IndexedDBIndexChild*
    96   GetActorChild() const
    97   {
    98     return mActorChild;
    99   }
   101   IndexedDBIndexParent*
   102   GetActorParent() const
   103   {
   104     return mActorParent;
   105   }
   107   already_AddRefed<IDBRequest>
   108   GetInternal(IDBKeyRange* aKeyRange,
   109               ErrorResult& aRv);
   111   already_AddRefed<IDBRequest>
   112   GetKeyInternal(IDBKeyRange* aKeyRange,
   113                  ErrorResult& aRv);
   115   already_AddRefed<IDBRequest>
   116   GetAllInternal(IDBKeyRange* aKeyRange,
   117                  uint32_t aLimit,
   118                  ErrorResult& aRv);
   120   already_AddRefed<IDBRequest>
   121   GetAllKeysInternal(IDBKeyRange* aKeyRange,
   122                      uint32_t aLimit,
   123                      ErrorResult& aRv);
   125   already_AddRefed<IDBRequest>
   126   CountInternal(IDBKeyRange* aKeyRange,
   127                 ErrorResult& aRv);
   129   nsresult OpenCursorFromChildProcess(
   130                             IDBRequest* aRequest,
   131                             size_t aDirection,
   132                             const Key& aKey,
   133                             const Key& aObjectKey,
   134                             IDBCursor** _retval);
   136   already_AddRefed<IDBRequest>
   137   OpenKeyCursorInternal(IDBKeyRange* aKeyRange,
   138                         size_t aDirection,
   139                         ErrorResult& aRv);
   141   nsresult OpenCursorInternal(IDBKeyRange* aKeyRange,
   142                               size_t aDirection,
   143                               IDBRequest** _retval);
   145   nsresult OpenCursorFromChildProcess(
   146                             IDBRequest* aRequest,
   147                             size_t aDirection,
   148                             const Key& aKey,
   149                             const Key& aObjectKey,
   150                             const SerializedStructuredCloneReadInfo& aCloneInfo,
   151                             nsTArray<StructuredCloneFile>& aBlobs,
   152                             IDBCursor** _retval);
   154   // nsWrapperCache
   155   virtual JSObject*
   156   WrapObject(JSContext* aCx) MOZ_OVERRIDE;
   158   // WebIDL
   159   IDBObjectStore*
   160   GetParentObject() const
   161   {
   162     return mObjectStore;
   163   }
   165   void
   166   GetName(nsString& aName) const
   167   {
   168     NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
   169     aName.Assign(mName);
   170   }
   172   IDBObjectStore*
   173   ObjectStore() const
   174   {
   175     NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
   176     return mObjectStore;
   177   }
   179   void
   180   GetKeyPath(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
   181              ErrorResult& aRv);
   183   bool
   184   MultiEntry() const
   185   {
   186     NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
   187     return mMultiEntry;
   188   }
   190   bool
   191   Unique() const
   192   {
   193     NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
   194     return mUnique;
   195   }
   197   already_AddRefed<IDBRequest>
   198   OpenCursor(JSContext* aCx, JS::Handle<JS::Value> aRange,
   199              IDBCursorDirection aDirection, ErrorResult& aRv);
   201   already_AddRefed<IDBRequest>
   202   OpenKeyCursor(JSContext* aCx, JS::Handle<JS::Value> aRange,
   203                 IDBCursorDirection aDirection, ErrorResult& aRv);
   205   already_AddRefed<IDBRequest>
   206   Get(JSContext* aCx, JS::Handle<JS::Value> aKey, ErrorResult& aRv);
   208   already_AddRefed<IDBRequest>
   209   GetKey(JSContext* aCx, JS::Handle<JS::Value> aKey, ErrorResult& aRv);
   211   already_AddRefed<IDBRequest>
   212   Count(JSContext* aCx, JS::Handle<JS::Value> aKey,
   213          ErrorResult& aRv);
   215   void
   216   GetStoreName(nsString& aStoreName) const
   217   {
   218     NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
   219     mObjectStore->GetName(aStoreName);
   220   }
   222   already_AddRefed<IDBRequest>
   223   GetAll(JSContext* aCx, JS::Handle<JS::Value> aKey,
   224          const Optional<uint32_t>& aLimit, ErrorResult& aRv);
   226   already_AddRefed<IDBRequest>
   227   GetAllKeys(JSContext* aCx, JS::Handle<JS::Value> aKey,
   228              const Optional<uint32_t>& aLimit, ErrorResult& aRv);
   230 private:
   231   IDBIndex();
   232   ~IDBIndex();
   234   nsRefPtr<IDBObjectStore> mObjectStore;
   236   int64_t mId;
   237   nsString mName;
   238   KeyPath mKeyPath;
   239   JS::Heap<JS::Value> mCachedKeyPath;
   241   IndexedDBIndexChild* mActorChild;
   242   IndexedDBIndexParent* mActorParent;
   244   bool mUnique;
   245   bool mMultiEntry;
   246   bool mRooted;
   247 };
   249 END_INDEXEDDB_NAMESPACE
   251 #endif // mozilla_dom_indexeddb_idbindex_h__

mercurial