tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

QuotaManagerService.h (2693B)


      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/. */
      6 
      7 #ifndef mozilla_dom_quota_QuotaManagerService_h
      8 #define mozilla_dom_quota_QuotaManagerService_h
      9 
     10 #include "ErrorList.h"
     11 #include "mozilla/AlreadyAddRefed.h"
     12 #include "mozilla/HalBatteryInformation.h"
     13 #include "mozilla/dom/ipc/IdType.h"
     14 #include "nsIObserver.h"
     15 #include "nsIQuotaManagerService.h"
     16 #include "nsIQuotaManagerServiceInternal.h"
     17 #include "nsISupports.h"
     18 
     19 #define QUOTAMANAGER_SERVICE_CONTRACTID \
     20  "@mozilla.org/dom/quota-manager-service;1"
     21 
     22 class nsIPrincipal;
     23 class nsIQuotaRequest;
     24 class nsIQuotaUsageCallback;
     25 class nsIQuotaUsageRequest;
     26 
     27 namespace mozilla {
     28 namespace ipc {
     29 
     30 class PBackgroundChild;
     31 
     32 }  // namespace ipc
     33 
     34 namespace hal {
     35 class BatteryInformation;
     36 }
     37 
     38 namespace dom::quota {
     39 
     40 class QuotaChild;
     41 class QuotaManager;
     42 
     43 class QuotaManagerService final : public nsIQuotaManagerService,
     44                                  public nsIQuotaManagerServiceInternal,
     45                                  public nsIObserver,
     46                                  public hal::BatteryObserver {
     47  using PBackgroundChild = mozilla::ipc::PBackgroundChild;
     48 
     49  class BackgroundCreateCallback;
     50  class PendingRequestInfo;
     51  class UsageRequestInfo;
     52  class RequestInfo;
     53  class IdleMaintenanceInfo;
     54 
     55  QuotaChild* mBackgroundActor;
     56 
     57  bool mBackgroundActorFailed;
     58  bool mIdleObserverRegistered;
     59 
     60 public:
     61  // Returns a non-owning reference.
     62  static QuotaManagerService* GetOrCreate();
     63 
     64  // Returns a non-owning reference.
     65  static QuotaManagerService* Get();
     66 
     67  // No one should call this but the factory.
     68  static already_AddRefed<QuotaManagerService> FactoryCreate();
     69 
     70  void ClearBackgroundActor();
     71 
     72  // Called when a process is being shot down. Aborts any running operations
     73  // for the given process.
     74  void AbortOperationsForProcess(ContentParentId aContentParentId);
     75 
     76 private:
     77  QuotaManagerService();
     78  ~QuotaManagerService();
     79 
     80  nsresult Init();
     81 
     82  void Destroy();
     83 
     84  nsresult EnsureBackgroundActor();
     85 
     86  nsresult InitiateRequest(PendingRequestInfo& aInfo);
     87 
     88  void PerformIdleMaintenance();
     89 
     90  void RemoveIdleObserver();
     91 
     92  NS_DECL_ISUPPORTS
     93  NS_DECL_NSIQUOTAMANAGERSERVICE
     94  NS_DECL_NSIQUOTAMANAGERSERVICEINTERNAL
     95  NS_DECL_NSIOBSERVER
     96 
     97  // BatteryObserver override
     98  void Notify(const hal::BatteryInformation& aBatteryInfo) override;
     99 };
    100 
    101 }  // namespace dom::quota
    102 }  // namespace mozilla
    103 
    104 #endif /* mozilla_dom_quota_QuotaManagerService_h */