Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / quota / QuotaManagerService.h
blobf8f8c01c31c1ce96d3687a8ae9ddcc4b17328bf1
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 "nsISupports.h"
19 #define QUOTAMANAGER_SERVICE_CONTRACTID \
20 "@mozilla.org/dom/quota-manager-service;1"
22 class nsIPrincipal;
23 class nsIQuotaRequest;
24 class nsIQuotaUsageCallback;
25 class nsIQuotaUsageRequest;
27 namespace mozilla {
28 namespace ipc {
30 class PBackgroundChild;
32 } // namespace ipc
34 namespace hal {
35 class BatteryInformation;
38 namespace dom::quota {
40 class QuotaChild;
41 class QuotaManager;
43 class QuotaManagerService final : public nsIQuotaManagerService,
44 public nsIObserver,
45 public hal::BatteryObserver {
46 using PBackgroundChild = mozilla::ipc::PBackgroundChild;
48 class BackgroundCreateCallback;
49 class PendingRequestInfo;
50 class UsageRequestInfo;
51 class RequestInfo;
52 class IdleMaintenanceInfo;
54 QuotaChild* mBackgroundActor;
56 bool mBackgroundActorFailed;
57 bool mIdleObserverRegistered;
59 public:
60 // Returns a non-owning reference.
61 static QuotaManagerService* GetOrCreate();
63 // Returns a non-owning reference.
64 static QuotaManagerService* Get();
66 // No one should call this but the factory.
67 static already_AddRefed<QuotaManagerService> FactoryCreate();
69 void ClearBackgroundActor();
71 // Called when a process is being shot down. Aborts any running operations
72 // for the given process.
73 void AbortOperationsForProcess(ContentParentId aContentParentId);
75 private:
76 QuotaManagerService();
77 ~QuotaManagerService();
79 nsresult Init();
81 void Destroy();
83 nsresult EnsureBackgroundActor();
85 nsresult InitiateRequest(PendingRequestInfo& aInfo);
87 void PerformIdleMaintenance();
89 void RemoveIdleObserver();
91 NS_DECL_ISUPPORTS
92 NS_DECL_NSIQUOTAMANAGERSERVICE
93 NS_DECL_NSIOBSERVER
95 // BatteryObserver override
96 void Notify(const hal::BatteryInformation& aBatteryInfo) override;
99 } // namespace dom::quota
100 } // namespace mozilla
102 #endif /* mozilla_dom_quota_QuotaManagerService_h */