Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=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/. */
6 :
7 : #ifndef mozilla_dom_StorageManager_h
8 : #define mozilla_dom_StorageManager_h
9 :
10 : #include "nsCOMPtr.h"
11 : #include "nsCycleCollectionParticipant.h"
12 : #include "nsISupports.h"
13 : #include "nsWrapperCache.h"
14 :
15 : namespace mozilla {
16 : namespace dom {
17 :
18 : class Promise;
19 : struct StorageEstimate;
20 :
21 : class StorageManager final
22 : : public nsISupports
23 : , public nsWrapperCache
24 : {
25 : nsCOMPtr<nsIGlobalObject> mOwner;
26 :
27 : public:
28 : // Return dom.quota.storageManager.enabled on main/worker thread.
29 : static bool
30 : PrefEnabled(JSContext* aCx, JSObject* aObj);
31 :
32 : explicit
33 : StorageManager(nsIGlobalObject* aGlobal);
34 :
35 : nsIGlobalObject*
36 0 : GetParentObject() const
37 : {
38 0 : return mOwner;
39 : }
40 :
41 : // WebIDL
42 : already_AddRefed<Promise>
43 : Persisted(ErrorResult& aRv);
44 :
45 : already_AddRefed<Promise>
46 : Persist(ErrorResult& aRv);
47 :
48 : already_AddRefed<Promise>
49 : Estimate(ErrorResult& aRv);
50 :
51 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
52 0 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(StorageManager)
53 :
54 : // nsWrapperCache
55 : virtual JSObject*
56 : WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
57 :
58 : private:
59 : ~StorageManager();
60 : };
61 :
62 : } // namespace dom
63 : } // namespace mozilla
64 :
65 : #endif // mozilla_dom_StorageManager_h
|