dom/datastore/DataStore.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

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 #ifndef mozilla_dom_DataStore_h
michael@0 6 #define mozilla_dom_DataStore_h
michael@0 7
michael@0 8 #include "mozilla/DOMEventTargetHelper.h"
michael@0 9
michael@0 10 namespace mozilla {
michael@0 11
michael@0 12 class ErrorResult;
michael@0 13
michael@0 14 namespace dom {
michael@0 15
michael@0 16 class Promise;
michael@0 17 class DataStoreCursor;
michael@0 18 class DataStoreImpl;
michael@0 19 class StringOrUnsignedLong;
michael@0 20 class OwningStringOrUnsignedLong;
michael@0 21
michael@0 22 class DataStore MOZ_FINAL : public DOMEventTargetHelper
michael@0 23 {
michael@0 24 public:
michael@0 25 NS_DECL_ISUPPORTS_INHERITED
michael@0 26 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DataStore,
michael@0 27 DOMEventTargetHelper)
michael@0 28
michael@0 29 explicit DataStore(nsPIDOMWindow* aWindow);
michael@0 30
michael@0 31 // WebIDL (internal functions)
michael@0 32
michael@0 33 static already_AddRefed<DataStore> Constructor(GlobalObject& aGlobal,
michael@0 34 ErrorResult& aRv);
michael@0 35
michael@0 36 virtual JSObject* WrapObject(JSContext *aCx) MOZ_OVERRIDE;
michael@0 37
michael@0 38 static bool EnabledForScope(JSContext* aCx, JS::Handle<JSObject*> aObj);
michael@0 39
michael@0 40 // WebIDL (public APIs)
michael@0 41
michael@0 42 void GetName(nsAString& aName, ErrorResult& aRv);
michael@0 43
michael@0 44 void GetOwner(nsAString& aOwner, ErrorResult& aRv);
michael@0 45
michael@0 46 bool GetReadOnly(ErrorResult& aRv);
michael@0 47
michael@0 48 already_AddRefed<Promise> Get(const Sequence<OwningStringOrUnsignedLong>& aId,
michael@0 49 ErrorResult& aRv);
michael@0 50
michael@0 51 already_AddRefed<Promise> Put(JSContext* aCx,
michael@0 52 JS::Handle<JS::Value> aObj,
michael@0 53 const StringOrUnsignedLong& aId,
michael@0 54 const nsAString& aRevisionId,
michael@0 55 ErrorResult& aRv);
michael@0 56
michael@0 57 already_AddRefed<Promise> Add(JSContext* aCx,
michael@0 58 JS::Handle<JS::Value> aObj,
michael@0 59 const Optional<StringOrUnsignedLong>& aId,
michael@0 60 const nsAString& aRevisionId,
michael@0 61 ErrorResult& aRv);
michael@0 62
michael@0 63 already_AddRefed<Promise> Remove(const StringOrUnsignedLong& aId,
michael@0 64 const nsAString& aRevisionId,
michael@0 65 ErrorResult& aRv);
michael@0 66
michael@0 67 already_AddRefed<Promise> Clear(const nsAString& aRevisionId,
michael@0 68 ErrorResult& aRv);
michael@0 69
michael@0 70 void GetRevisionId(nsAString& aRevisionId, ErrorResult& aRv);
michael@0 71
michael@0 72 already_AddRefed<Promise> GetLength(ErrorResult& aRv);
michael@0 73
michael@0 74 already_AddRefed<DataStoreCursor> Sync(const nsAString& aRevisionId,
michael@0 75 ErrorResult& aRv);
michael@0 76
michael@0 77 IMPL_EVENT_HANDLER(change)
michael@0 78
michael@0 79 // This internal function (ChromeOnly) is aimed to make the DataStore keep a
michael@0 80 // reference to the DataStoreImpl which really implements the API's logic in
michael@0 81 // JS. We also need to let the DataStoreImpl implementation keep the event
michael@0 82 // target of DataStore, so that it can know where to fire the events.
michael@0 83 void SetDataStoreImpl(DataStoreImpl& aStore, ErrorResult& aRv);
michael@0 84
michael@0 85 protected:
michael@0 86 virtual ~DataStore() {}
michael@0 87
michael@0 88 private:
michael@0 89 nsRefPtr<DataStoreImpl> mStore;
michael@0 90 };
michael@0 91
michael@0 92 } //namespace dom
michael@0 93 } //namespace mozilla
michael@0 94
michael@0 95 #endif

mercurial