2015-11-22 12:43:55 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_quota_QuotaManagerService_h
|
|
|
|
#define mozilla_dom_quota_QuotaManagerService_h
|
|
|
|
|
|
|
|
#include "mozilla/dom/ipc/IdType.h"
|
2018-08-13 04:57:50 +03:00
|
|
|
#include "mozilla/HalBatteryInformation.h"
|
2016-06-07 23:10:18 +03:00
|
|
|
#include "nsAutoPtr.h"
|
2015-11-22 12:43:55 +03:00
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsIQuotaManagerService.h"
|
|
|
|
|
|
|
|
#define QUOTAMANAGER_SERVICE_CONTRACTID \
|
|
|
|
"@mozilla.org/dom/quota-manager-service;1"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace ipc {
|
|
|
|
|
|
|
|
class PBackgroundChild;
|
|
|
|
|
|
|
|
} // namespace ipc
|
|
|
|
|
2016-11-29 00:22:51 +03:00
|
|
|
namespace hal {
|
|
|
|
class BatteryInformation;
|
|
|
|
}
|
|
|
|
|
2015-11-22 12:43:55 +03:00
|
|
|
namespace dom {
|
|
|
|
namespace quota {
|
|
|
|
|
|
|
|
class QuotaChild;
|
|
|
|
class QuotaManager;
|
|
|
|
|
|
|
|
class QuotaManagerService final
|
|
|
|
: public nsIQuotaManagerService
|
|
|
|
, public nsIObserver
|
2018-08-13 04:57:50 +03:00
|
|
|
, public hal::BatteryObserver
|
2015-11-22 12:43:55 +03:00
|
|
|
{
|
|
|
|
typedef mozilla::ipc::PBackgroundChild PBackgroundChild;
|
|
|
|
|
|
|
|
class BackgroundCreateCallback;
|
|
|
|
class PendingRequestInfo;
|
|
|
|
class UsageRequestInfo;
|
|
|
|
class RequestInfo;
|
|
|
|
class IdleMaintenanceInfo;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIEventTarget> mBackgroundThread;
|
|
|
|
|
|
|
|
QuotaChild* mBackgroundActor;
|
|
|
|
|
|
|
|
bool mBackgroundActorFailed;
|
|
|
|
bool mIdleObserverRegistered;
|
|
|
|
|
|
|
|
public:
|
|
|
|
// Returns a non-owning reference.
|
|
|
|
static QuotaManagerService*
|
|
|
|
GetOrCreate();
|
|
|
|
|
|
|
|
// Returns a non-owning reference.
|
|
|
|
static QuotaManagerService*
|
|
|
|
Get();
|
|
|
|
|
2017-10-17 07:08:42 +03:00
|
|
|
// No one should call this but the factory.
|
|
|
|
static already_AddRefed<QuotaManagerService>
|
2015-11-22 12:43:55 +03:00
|
|
|
FactoryCreate();
|
|
|
|
|
|
|
|
void
|
|
|
|
ClearBackgroundActor();
|
|
|
|
|
|
|
|
void
|
|
|
|
NoteLiveManager(QuotaManager* aManager);
|
|
|
|
|
|
|
|
void
|
2016-07-18 19:51:54 +03:00
|
|
|
NoteShuttingDownManager();
|
2015-11-22 12:43:55 +03:00
|
|
|
|
|
|
|
// Called when a process is being shot down. Aborts any running operations
|
|
|
|
// for the given process.
|
|
|
|
void
|
|
|
|
AbortOperationsForProcess(ContentParentId aContentParentId);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QuotaManagerService();
|
|
|
|
~QuotaManagerService();
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
Init();
|
|
|
|
|
|
|
|
void
|
|
|
|
Destroy();
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
InitiateRequest(nsAutoPtr<PendingRequestInfo>& aInfo);
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
BackgroundActorCreated(PBackgroundChild* aBackgroundActor);
|
|
|
|
|
|
|
|
void
|
|
|
|
BackgroundActorFailed();
|
|
|
|
|
|
|
|
void
|
|
|
|
PerformIdleMaintenance();
|
|
|
|
|
|
|
|
void
|
|
|
|
RemoveIdleObserver();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIQUOTAMANAGERSERVICE
|
|
|
|
NS_DECL_NSIOBSERVER
|
2016-11-29 00:22:51 +03:00
|
|
|
|
|
|
|
// BatteryObserver override
|
|
|
|
void
|
|
|
|
Notify(const hal::BatteryInformation& aBatteryInfo) override;
|
2015-11-22 12:43:55 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace quota
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif /* mozilla_dom_quota_QuotaManagerService_h */
|