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
;
44 class QuotaManagerService final
: public nsIQuotaManagerService
,
46 public hal::BatteryObserver
{
47 using PBackgroundChild
= mozilla::ipc::PBackgroundChild
;
49 class BackgroundCreateCallback
;
50 class PendingRequestInfo
;
51 class UsageRequestInfo
;
53 class IdleMaintenanceInfo
;
55 QuotaChild
* mBackgroundActor
;
57 bool mBackgroundActorFailed
;
58 bool mIdleObserverRegistered
;
61 // Returns a non-owning reference.
62 static QuotaManagerService
* GetOrCreate();
64 // Returns a non-owning reference.
65 static QuotaManagerService
* Get();
67 // No one should call this but the factory.
68 static already_AddRefed
<QuotaManagerService
> FactoryCreate();
70 void ClearBackgroundActor();
72 // Called when a process is being shot down. Aborts any running operations
73 // for the given process.
74 void AbortOperationsForProcess(ContentParentId aContentParentId
);
77 QuotaManagerService();
78 ~QuotaManagerService();
84 nsresult
EnsureBackgroundActor();
86 nsresult
InitiateRequest(PendingRequestInfo
& aInfo
);
88 void PerformIdleMaintenance();
90 void RemoveIdleObserver();
93 NS_DECL_NSIQUOTAMANAGERSERVICE
96 // BatteryObserver override
97 void Notify(const hal::BatteryInformation
& aBatteryInfo
) override
;
102 } // namespace mozilla
104 #endif /* mozilla_dom_quota_QuotaManagerService_h */