2013-03-26 15:13:17 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2015-05-03 22:32:37 +03:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-03-26 15:13:17 +04:00
|
|
|
/* 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_client_h__
|
|
|
|
#define mozilla_dom_quota_client_h__
|
|
|
|
|
|
|
|
#include "mozilla/dom/quota/QuotaCommon.h"
|
|
|
|
|
2015-06-30 15:59:27 +03:00
|
|
|
#include "mozilla/dom/ipc/IdType.h"
|
|
|
|
|
2013-09-11 08:18:36 +04:00
|
|
|
#include "PersistenceType.h"
|
|
|
|
|
2017-03-06 20:40:31 +03:00
|
|
|
class nsIFile;
|
2013-03-26 15:13:17 +04:00
|
|
|
class nsIRunnable;
|
|
|
|
|
2013-11-19 01:49:53 +04:00
|
|
|
#define IDB_DIRECTORY_NAME "idb"
|
|
|
|
#define ASMJSCACHE_DIRECTORY_NAME "asmjs"
|
2015-03-02 16:20:00 +03:00
|
|
|
#define DOMCACHE_DIRECTORY_NAME "cache"
|
2013-11-19 01:49:53 +04:00
|
|
|
|
2013-03-26 15:13:17 +04:00
|
|
|
BEGIN_QUOTA_NAMESPACE
|
|
|
|
|
2016-07-18 19:51:54 +03:00
|
|
|
class QuotaManager;
|
2013-09-11 08:18:36 +04:00
|
|
|
class UsageInfo;
|
2013-03-26 15:13:17 +04:00
|
|
|
|
|
|
|
// An abstract interface for quota manager clients.
|
|
|
|
// Each storage API must provide an implementation of this interface in order
|
|
|
|
// to participate in centralized quota and storage handling.
|
|
|
|
class Client
|
|
|
|
{
|
|
|
|
public:
|
2017-03-22 14:13:54 +03:00
|
|
|
typedef mozilla::Atomic<bool> AtomicBool;
|
|
|
|
|
2017-01-25 22:51:34 +03:00
|
|
|
NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
|
2013-03-26 15:13:17 +04:00
|
|
|
|
|
|
|
enum Type {
|
|
|
|
IDB = 0,
|
|
|
|
//LS,
|
|
|
|
//APPCACHE,
|
2013-11-19 01:49:53 +04:00
|
|
|
ASMJS,
|
2015-03-02 16:20:00 +03:00
|
|
|
DOMCACHE,
|
2013-03-26 15:13:17 +04:00
|
|
|
TYPE_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
virtual Type
|
|
|
|
GetType() = 0;
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
TypeToText(Type aType, nsAString& aText)
|
|
|
|
{
|
|
|
|
switch (aType) {
|
|
|
|
case IDB:
|
2013-11-19 01:49:53 +04:00
|
|
|
aText.AssignLiteral(IDB_DIRECTORY_NAME);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ASMJS:
|
|
|
|
aText.AssignLiteral(ASMJSCACHE_DIRECTORY_NAME);
|
2013-03-26 15:13:17 +04:00
|
|
|
break;
|
|
|
|
|
2015-03-02 16:20:00 +03:00
|
|
|
case DOMCACHE:
|
|
|
|
aText.AssignLiteral(DOMCACHE_DIRECTORY_NAME);
|
|
|
|
break;
|
|
|
|
|
2013-03-26 15:13:17 +04:00
|
|
|
case TYPE_MAX:
|
|
|
|
default:
|
|
|
|
NS_NOTREACHED("Bad id value!");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
TypeFromText(const nsAString& aText, Type& aType)
|
|
|
|
{
|
2013-11-19 01:49:53 +04:00
|
|
|
if (aText.EqualsLiteral(IDB_DIRECTORY_NAME)) {
|
2013-03-26 15:13:17 +04:00
|
|
|
aType = IDB;
|
|
|
|
}
|
2013-11-19 01:49:53 +04:00
|
|
|
else if (aText.EqualsLiteral(ASMJSCACHE_DIRECTORY_NAME)) {
|
|
|
|
aType = ASMJS;
|
|
|
|
}
|
2015-03-02 16:20:00 +03:00
|
|
|
else if (aText.EqualsLiteral(DOMCACHE_DIRECTORY_NAME)) {
|
|
|
|
aType = DOMCACHE;
|
|
|
|
}
|
2013-03-26 15:13:17 +04:00
|
|
|
else {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-07-18 13:54:20 +03:00
|
|
|
// Methods which are called on the IO thread.
|
2017-03-06 20:40:31 +03:00
|
|
|
virtual nsresult
|
|
|
|
UpgradeStorageFrom1_0To2_0(nsIFile* aDirectory)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-07-18 13:54:20 +03:00
|
|
|
virtual nsresult
|
2017-10-03 17:02:27 +03:00
|
|
|
UpgradeStorageFrom2_0To2_1(nsIFile* aDirectory)
|
2017-07-18 13:54:20 +03:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-03-26 15:13:17 +04:00
|
|
|
virtual nsresult
|
2013-09-11 08:18:36 +04:00
|
|
|
InitOrigin(PersistenceType aPersistenceType,
|
|
|
|
const nsACString& aGroup,
|
|
|
|
const nsACString& aOrigin,
|
2017-03-22 14:13:54 +03:00
|
|
|
const AtomicBool& aCanceled,
|
2013-09-11 08:18:36 +04:00
|
|
|
UsageInfo* aUsageInfo) = 0;
|
2013-03-26 15:13:17 +04:00
|
|
|
|
|
|
|
virtual nsresult
|
2013-09-11 08:18:36 +04:00
|
|
|
GetUsageForOrigin(PersistenceType aPersistenceType,
|
|
|
|
const nsACString& aGroup,
|
|
|
|
const nsACString& aOrigin,
|
2017-03-22 14:13:54 +03:00
|
|
|
const AtomicBool& aCanceled,
|
2013-09-11 08:18:36 +04:00
|
|
|
UsageInfo* aUsageInfo) = 0;
|
2013-03-26 15:13:17 +04:00
|
|
|
|
2013-06-05 12:11:23 +04:00
|
|
|
virtual void
|
2013-09-11 08:18:36 +04:00
|
|
|
OnOriginClearCompleted(PersistenceType aPersistenceType,
|
2014-11-28 11:44:12 +03:00
|
|
|
const nsACString& aOrigin) = 0;
|
2013-06-05 12:11:23 +04:00
|
|
|
|
|
|
|
virtual void
|
|
|
|
ReleaseIOThreadObjects() = 0;
|
|
|
|
|
2017-07-18 13:54:20 +03:00
|
|
|
// Methods which are called on the background thread.
|
2013-03-26 15:13:17 +04:00
|
|
|
virtual void
|
2015-06-30 15:59:27 +03:00
|
|
|
AbortOperations(const nsACString& aOrigin) = 0;
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
AbortOperationsForProcess(ContentParentId aContentParentId) = 0;
|
2013-03-26 15:13:17 +04:00
|
|
|
|
2015-04-30 23:46:51 +03:00
|
|
|
virtual void
|
2015-11-22 12:43:55 +03:00
|
|
|
StartIdleMaintenance() = 0;
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
StopIdleMaintenance() = 0;
|
2015-04-30 23:46:51 +03:00
|
|
|
|
2013-03-26 15:13:17 +04:00
|
|
|
virtual void
|
2015-04-14 11:57:41 +03:00
|
|
|
ShutdownWorkThreads() = 0;
|
2013-03-26 15:13:17 +04:00
|
|
|
|
2016-07-18 19:51:54 +03:00
|
|
|
// Methods which are called on the main thread.
|
|
|
|
virtual void
|
|
|
|
DidInitialize(QuotaManager* aQuotaManager)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
WillShutdown()
|
|
|
|
{ }
|
|
|
|
|
2013-03-26 15:13:17 +04:00
|
|
|
protected:
|
|
|
|
virtual ~Client()
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
END_QUOTA_NAMESPACE
|
|
|
|
|
|
|
|
#endif // mozilla_dom_quota_client_h__
|