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"
|
|
|
|
|
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
|
|
|
|
|
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:
|
2014-03-28 00:38:33 +04:00
|
|
|
NS_IMETHOD_(MozExternalRefCountType)
|
2013-03-26 15:13:17 +04:00
|
|
|
AddRef() = 0;
|
|
|
|
|
2014-03-28 00:38:33 +04:00
|
|
|
NS_IMETHOD_(MozExternalRefCountType)
|
2013-03-26 15:13:17 +04:00
|
|
|
Release() = 0;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-06-05 12:11:23 +04:00
|
|
|
// Methods which are called on the IO thred.
|
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,
|
|
|
|
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,
|
|
|
|
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;
|
|
|
|
|
|
|
|
// Methods which are called on the main thred.
|
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
|
|
|
|
PerformIdleMaintenance() = 0;
|
|
|
|
|
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
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~Client()
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
END_QUOTA_NAMESPACE
|
|
|
|
|
|
|
|
#endif // mozilla_dom_quota_client_h__
|