Bug 1941046 - Part 4: Send a callback request for impression and clicks of MARS Top...
[gecko.git] / dom / quota / QuotaManagerService.h
blobfa4f717f2b2898bd23ef2958f1ef3c9fc475546a
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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_quota_QuotaManagerService_h
8 #define mozilla_dom_quota_QuotaManagerService_h
10 #include <cstdint>
11 #include "ErrorList.h"
12 #include "mozilla/AlreadyAddRefed.h"
13 #include "mozilla/HalBatteryInformation.h"
14 #include "mozilla/dom/ipc/IdType.h"
15 #include "nsIObserver.h"
16 #include "nsIQuotaManagerService.h"
17 #include "nsIQuotaManagerServiceInternal.h"
18 #include "nsISupports.h"
20 #define QUOTAMANAGER_SERVICE_CONTRACTID \
21 "@mozilla.org/dom/quota-manager-service;1"
23 class nsIPrincipal;
24 class nsIQuotaRequest;
25 class nsIQuotaUsageCallback;
26 class nsIQuotaUsageRequest;
28 namespace mozilla {
29 namespace ipc {
31 class PBackgroundChild;
33 } // namespace ipc
35 namespace hal {
36 class BatteryInformation;
39 namespace dom::quota {
41 class QuotaChild;
42 class QuotaManager;
44 class QuotaManagerService final : public nsIQuotaManagerService,
45 public nsIQuotaManagerServiceInternal,
46 public nsIObserver,
47 public hal::BatteryObserver {
48 using PBackgroundChild = mozilla::ipc::PBackgroundChild;
50 class BackgroundCreateCallback;
51 class PendingRequestInfo;
52 class UsageRequestInfo;
53 class RequestInfo;
54 class IdleMaintenanceInfo;
56 QuotaChild* mBackgroundActor;
58 bool mBackgroundActorFailed;
59 bool mIdleObserverRegistered;
61 public:
62 // Returns a non-owning reference.
63 static QuotaManagerService* GetOrCreate();
65 // Returns a non-owning reference.
66 static QuotaManagerService* Get();
68 // No one should call this but the factory.
69 static already_AddRefed<QuotaManagerService> FactoryCreate();
71 void ClearBackgroundActor();
73 // Called when a process is being shot down. Aborts any running operations
74 // for the given process.
75 void AbortOperationsForProcess(ContentParentId aContentParentId);
77 private:
78 QuotaManagerService();
79 ~QuotaManagerService();
81 nsresult Init();
83 void Destroy();
85 nsresult EnsureBackgroundActor();
87 nsresult InitiateRequest(PendingRequestInfo& aInfo);
89 void PerformIdleMaintenance();
91 void RemoveIdleObserver();
93 NS_DECL_ISUPPORTS
94 NS_DECL_NSIQUOTAMANAGERSERVICE
95 NS_DECL_NSIQUOTAMANAGERSERVICEINTERNAL
96 NS_DECL_NSIOBSERVER
98 // BatteryObserver override
99 void Notify(const hal::BatteryInformation& aBatteryInfo) override;
102 } // namespace dom::quota
103 } // namespace mozilla
105 #endif /* mozilla_dom_quota_QuotaManagerService_h */