michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_DataStore_h michael@0: #define mozilla_dom_DataStore_h michael@0: michael@0: #include "mozilla/DOMEventTargetHelper.h" michael@0: michael@0: namespace mozilla { michael@0: michael@0: class ErrorResult; michael@0: michael@0: namespace dom { michael@0: michael@0: class Promise; michael@0: class DataStoreCursor; michael@0: class DataStoreImpl; michael@0: class StringOrUnsignedLong; michael@0: class OwningStringOrUnsignedLong; michael@0: michael@0: class DataStore MOZ_FINAL : public DOMEventTargetHelper michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DataStore, michael@0: DOMEventTargetHelper) michael@0: michael@0: explicit DataStore(nsPIDOMWindow* aWindow); michael@0: michael@0: // WebIDL (internal functions) michael@0: michael@0: static already_AddRefed Constructor(GlobalObject& aGlobal, michael@0: ErrorResult& aRv); michael@0: michael@0: virtual JSObject* WrapObject(JSContext *aCx) MOZ_OVERRIDE; michael@0: michael@0: static bool EnabledForScope(JSContext* aCx, JS::Handle aObj); michael@0: michael@0: // WebIDL (public APIs) michael@0: michael@0: void GetName(nsAString& aName, ErrorResult& aRv); michael@0: michael@0: void GetOwner(nsAString& aOwner, ErrorResult& aRv); michael@0: michael@0: bool GetReadOnly(ErrorResult& aRv); michael@0: michael@0: already_AddRefed Get(const Sequence& aId, michael@0: ErrorResult& aRv); michael@0: michael@0: already_AddRefed Put(JSContext* aCx, michael@0: JS::Handle aObj, michael@0: const StringOrUnsignedLong& aId, michael@0: const nsAString& aRevisionId, michael@0: ErrorResult& aRv); michael@0: michael@0: already_AddRefed Add(JSContext* aCx, michael@0: JS::Handle aObj, michael@0: const Optional& aId, michael@0: const nsAString& aRevisionId, michael@0: ErrorResult& aRv); michael@0: michael@0: already_AddRefed Remove(const StringOrUnsignedLong& aId, michael@0: const nsAString& aRevisionId, michael@0: ErrorResult& aRv); michael@0: michael@0: already_AddRefed Clear(const nsAString& aRevisionId, michael@0: ErrorResult& aRv); michael@0: michael@0: void GetRevisionId(nsAString& aRevisionId, ErrorResult& aRv); michael@0: michael@0: already_AddRefed GetLength(ErrorResult& aRv); michael@0: michael@0: already_AddRefed Sync(const nsAString& aRevisionId, michael@0: ErrorResult& aRv); michael@0: michael@0: IMPL_EVENT_HANDLER(change) michael@0: michael@0: // This internal function (ChromeOnly) is aimed to make the DataStore keep a michael@0: // reference to the DataStoreImpl which really implements the API's logic in michael@0: // JS. We also need to let the DataStoreImpl implementation keep the event michael@0: // target of DataStore, so that it can know where to fire the events. michael@0: void SetDataStoreImpl(DataStoreImpl& aStore, ErrorResult& aRv); michael@0: michael@0: protected: michael@0: virtual ~DataStore() {} michael@0: michael@0: private: michael@0: nsRefPtr mStore; michael@0: }; michael@0: michael@0: } //namespace dom michael@0: } //namespace mozilla michael@0: michael@0: #endif