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 "nsISupports.h"
19 #define QUOTAMANAGER_SERVICE_CONTRACTID \
20 "@mozilla.org/dom/quota-manager-service;1"
23 class nsIQuotaRequest
;
24 class nsIQuotaUsageCallback
;
25 class nsIQuotaUsageRequest
;
30 class PBackgroundChild
;
35 class BatteryInformation
;
38 namespace dom::quota
{
43 class QuotaManagerService final
: public nsIQuotaManagerService
,
45 public hal::BatteryObserver
{
46 using PBackgroundChild
= mozilla::ipc::PBackgroundChild
;
48 class BackgroundCreateCallback
;
49 class PendingRequestInfo
;
50 class UsageRequestInfo
;
52 class IdleMaintenanceInfo
;
54 QuotaChild
* mBackgroundActor
;
56 bool mBackgroundActorFailed
;
57 bool mIdleObserverRegistered
;
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
);
76 QuotaManagerService();
77 ~QuotaManagerService();
83 nsresult
EnsureBackgroundActor();
85 nsresult
InitiateRequest(PendingRequestInfo
& aInfo
);
87 void PerformIdleMaintenance();
89 void RemoveIdleObserver();
92 NS_DECL_NSIQUOTAMANAGERSERVICE
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 */