dom/datastore/DataStore.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/datastore/DataStore.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,95 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef mozilla_dom_DataStore_h
     1.9 +#define mozilla_dom_DataStore_h
    1.10 +
    1.11 +#include "mozilla/DOMEventTargetHelper.h"
    1.12 +
    1.13 +namespace mozilla {
    1.14 +
    1.15 +class ErrorResult;
    1.16 +
    1.17 +namespace dom {
    1.18 +
    1.19 +class Promise;
    1.20 +class DataStoreCursor;
    1.21 +class DataStoreImpl;
    1.22 +class StringOrUnsignedLong;
    1.23 +class OwningStringOrUnsignedLong;
    1.24 +
    1.25 +class DataStore MOZ_FINAL : public DOMEventTargetHelper
    1.26 +{
    1.27 +public:
    1.28 +  NS_DECL_ISUPPORTS_INHERITED
    1.29 +  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DataStore,
    1.30 +                                           DOMEventTargetHelper)
    1.31 +
    1.32 +  explicit DataStore(nsPIDOMWindow* aWindow);
    1.33 +
    1.34 +  // WebIDL (internal functions)
    1.35 +
    1.36 +  static already_AddRefed<DataStore> Constructor(GlobalObject& aGlobal,
    1.37 +                                                 ErrorResult& aRv);
    1.38 +
    1.39 +  virtual JSObject* WrapObject(JSContext *aCx) MOZ_OVERRIDE;
    1.40 +
    1.41 +  static bool EnabledForScope(JSContext* aCx, JS::Handle<JSObject*> aObj);
    1.42 +
    1.43 +  // WebIDL (public APIs)
    1.44 +
    1.45 +  void GetName(nsAString& aName, ErrorResult& aRv);
    1.46 +
    1.47 +  void GetOwner(nsAString& aOwner, ErrorResult& aRv);
    1.48 +
    1.49 +  bool GetReadOnly(ErrorResult& aRv);
    1.50 +
    1.51 +  already_AddRefed<Promise> Get(const Sequence<OwningStringOrUnsignedLong>& aId,
    1.52 +                                ErrorResult& aRv);
    1.53 +
    1.54 +  already_AddRefed<Promise> Put(JSContext* aCx,
    1.55 +                                JS::Handle<JS::Value> aObj,
    1.56 +                                const StringOrUnsignedLong& aId,
    1.57 +                                const nsAString& aRevisionId,
    1.58 +                                ErrorResult& aRv);
    1.59 +
    1.60 +  already_AddRefed<Promise> Add(JSContext* aCx,
    1.61 +                                JS::Handle<JS::Value> aObj,
    1.62 +                                const Optional<StringOrUnsignedLong>& aId,
    1.63 +                                const nsAString& aRevisionId,
    1.64 +                                ErrorResult& aRv);
    1.65 +
    1.66 +  already_AddRefed<Promise> Remove(const StringOrUnsignedLong& aId,
    1.67 +                                   const nsAString& aRevisionId,
    1.68 +                                   ErrorResult& aRv);
    1.69 +
    1.70 +  already_AddRefed<Promise> Clear(const nsAString& aRevisionId,
    1.71 +                                  ErrorResult& aRv);
    1.72 +
    1.73 +  void GetRevisionId(nsAString& aRevisionId, ErrorResult& aRv);
    1.74 +
    1.75 +  already_AddRefed<Promise> GetLength(ErrorResult& aRv);
    1.76 +
    1.77 +  already_AddRefed<DataStoreCursor> Sync(const nsAString& aRevisionId,
    1.78 +                                         ErrorResult& aRv);
    1.79 +
    1.80 +  IMPL_EVENT_HANDLER(change)
    1.81 +
    1.82 +  // This internal function (ChromeOnly) is aimed to make the DataStore keep a
    1.83 +  // reference to the DataStoreImpl which really implements the API's logic in
    1.84 +  // JS. We also need to let the DataStoreImpl implementation keep the event
    1.85 +  // target of DataStore, so that it can know where to fire the events.
    1.86 +  void SetDataStoreImpl(DataStoreImpl& aStore, ErrorResult& aRv);
    1.87 +
    1.88 +protected:
    1.89 +  virtual ~DataStore() {}
    1.90 +
    1.91 +private:
    1.92 +  nsRefPtr<DataStoreImpl> mStore;
    1.93 +};
    1.94 +
    1.95 +} //namespace dom
    1.96 +} //namespace mozilla
    1.97 +
    1.98 +#endif
    1.99 \ No newline at end of file

mercurial