dom/datastore/DataStoreCursor.cpp

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #include "mozilla/dom/DataStore.h"
     6 #include "mozilla/dom/DataStoreCursor.h"
     7 #include "mozilla/dom/DataStoreBinding.h"
     8 #include "mozilla/dom/DataStoreImplBinding.h"
     9 #include "mozilla/dom/Promise.h"
    10 #include "mozilla/ErrorResult.h"
    11 #include "nsPIDOMWindow.h"
    13 namespace mozilla {
    14 namespace dom {
    16 NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DataStoreCursor, AddRef)
    17 NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DataStoreCursor, Release)
    19 NS_IMPL_CYCLE_COLLECTION(DataStoreCursor, mCursor)
    21 already_AddRefed<DataStoreCursor>
    22 DataStoreCursor::Constructor(GlobalObject& aGlobal, ErrorResult& aRv)
    23 {
    24   nsRefPtr<DataStoreCursor> cursor = new DataStoreCursor();
    25   return cursor.forget();
    26 }
    28 JSObject*
    29 DataStoreCursor::WrapObject(JSContext* aCx)
    30 {
    31   return DataStoreCursorBinding::Wrap(aCx, this);
    32 }
    34 already_AddRefed<DataStore>
    35 DataStoreCursor::GetStore(ErrorResult& aRv)
    36 {
    37   MOZ_ASSERT(NS_IsMainThread());
    38   MOZ_ASSERT(mCursor);
    40   return mCursor->GetStore(aRv);
    41 }
    43 already_AddRefed<Promise>
    44 DataStoreCursor::Next(ErrorResult& aRv)
    45 {
    46   MOZ_ASSERT(NS_IsMainThread());
    47   MOZ_ASSERT(mCursor);
    49   return mCursor->Next(aRv);
    50 }
    52 void
    53 DataStoreCursor::Close(ErrorResult& aRv)
    54 {
    55   MOZ_ASSERT(NS_IsMainThread());
    56   MOZ_ASSERT(mCursor);
    58   mCursor->Close(aRv);
    59 }
    61 void
    62 DataStoreCursor::SetDataStoreCursorImpl(DataStoreCursorImpl& aCursor)
    63 {
    64   MOZ_ASSERT(NS_IsMainThread());
    65   MOZ_ASSERT(!mCursor);
    67   mCursor = &aCursor;
    68 }
    70 } //namespace dom
    71 } //namespace mozilla

mercurial