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
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"
24 class nsIQuotaRequest
;
25 class nsIQuotaUsageCallback
;
26 class nsIQuotaUsageRequest
;
31 class PBackgroundChild
;
36 class BatteryInformation
;
39 namespace dom::quota
{
44 class QuotaManagerService final
: public nsIQuotaManagerService
,
45 public nsIQuotaManagerServiceInternal
,
47 public hal::BatteryObserver
{
48 using PBackgroundChild
= mozilla::ipc::PBackgroundChild
;
50 class BackgroundCreateCallback
;
51 class PendingRequestInfo
;
52 class UsageRequestInfo
;
54 class IdleMaintenanceInfo
;
56 QuotaChild
* mBackgroundActor
;
58 bool mBackgroundActorFailed
;
59 bool mIdleObserverRegistered
;
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
);
78 QuotaManagerService();
79 ~QuotaManagerService();
85 nsresult
EnsureBackgroundActor();
87 nsresult
InitiateRequest(PendingRequestInfo
& aInfo
);
89 void PerformIdleMaintenance();
91 void RemoveIdleObserver();
94 NS_DECL_NSIQUOTAMANAGERSERVICE
95 NS_DECL_NSIQUOTAMANAGERSERVICEINTERNAL
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 */