2013-03-26 04:13:17 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=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_client_h__
|
|
|
|
#define mozilla_dom_quota_client_h__
|
|
|
|
|
|
|
|
#include "mozilla/dom/quota/QuotaCommon.h"
|
|
|
|
|
2013-09-10 21:18:36 -07:00
|
|
|
#include "PersistenceType.h"
|
|
|
|
|
2013-03-26 04:13:17 -07:00
|
|
|
class nsIOfflineStorage;
|
|
|
|
class nsIRunnable;
|
|
|
|
|
2013-11-18 13:49:53 -08:00
|
|
|
#define IDB_DIRECTORY_NAME "idb"
|
|
|
|
#define ASMJSCACHE_DIRECTORY_NAME "asmjs"
|
2015-03-02 05:20:00 -08:00
|
|
|
#define DOMCACHE_DIRECTORY_NAME "cache"
|
2013-11-18 13:49:53 -08:00
|
|
|
|
2013-03-26 04:13:17 -07:00
|
|
|
BEGIN_QUOTA_NAMESPACE
|
|
|
|
|
2013-09-10 21:18:36 -07:00
|
|
|
class UsageInfo;
|
2013-03-26 04:13:17 -07: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-27 13:38:33 -07:00
|
|
|
NS_IMETHOD_(MozExternalRefCountType)
|
2013-03-26 04:13:17 -07:00
|
|
|
AddRef() = 0;
|
|
|
|
|
2014-03-27 13:38:33 -07:00
|
|
|
NS_IMETHOD_(MozExternalRefCountType)
|
2013-03-26 04:13:17 -07:00
|
|
|
Release() = 0;
|
|
|
|
|
|
|
|
enum Type {
|
|
|
|
IDB = 0,
|
|
|
|
//LS,
|
|
|
|
//APPCACHE,
|
2013-11-18 13:49:53 -08:00
|
|
|
ASMJS,
|
2015-03-02 05:20:00 -08:00
|
|
|
DOMCACHE,
|
2013-03-26 04:13:17 -07:00
|
|
|
TYPE_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
virtual Type
|
|
|
|
GetType() = 0;
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
TypeToText(Type aType, nsAString& aText)
|
|
|
|
{
|
|
|
|
switch (aType) {
|
|
|
|
case IDB:
|
2013-11-18 13:49:53 -08:00
|
|
|
aText.AssignLiteral(IDB_DIRECTORY_NAME);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ASMJS:
|
|
|
|
aText.AssignLiteral(ASMJSCACHE_DIRECTORY_NAME);
|
2013-03-26 04:13:17 -07:00
|
|
|
break;
|
|
|
|
|
2015-03-02 05:20:00 -08:00
|
|
|
case DOMCACHE:
|
|
|
|
aText.AssignLiteral(DOMCACHE_DIRECTORY_NAME);
|
|
|
|
break;
|
|
|
|
|
2013-03-26 04:13:17 -07: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-18 13:49:53 -08:00
|
|
|
if (aText.EqualsLiteral(IDB_DIRECTORY_NAME)) {
|
2013-03-26 04:13:17 -07:00
|
|
|
aType = IDB;
|
|
|
|
}
|
2013-11-18 13:49:53 -08:00
|
|
|
else if (aText.EqualsLiteral(ASMJSCACHE_DIRECTORY_NAME)) {
|
|
|
|
aType = ASMJS;
|
|
|
|
}
|
2015-03-02 05:20:00 -08:00
|
|
|
else if (aText.EqualsLiteral(DOMCACHE_DIRECTORY_NAME)) {
|
|
|
|
aType = DOMCACHE;
|
|
|
|
}
|
2013-03-26 04:13:17 -07:00
|
|
|
else {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-06-05 01:11:23 -07:00
|
|
|
// Methods which are called on the IO thred.
|
2013-03-26 04:13:17 -07:00
|
|
|
virtual nsresult
|
2013-09-10 21:18:36 -07:00
|
|
|
InitOrigin(PersistenceType aPersistenceType,
|
|
|
|
const nsACString& aGroup,
|
|
|
|
const nsACString& aOrigin,
|
|
|
|
UsageInfo* aUsageInfo) = 0;
|
2013-03-26 04:13:17 -07:00
|
|
|
|
|
|
|
virtual nsresult
|
2013-09-10 21:18:36 -07:00
|
|
|
GetUsageForOrigin(PersistenceType aPersistenceType,
|
|
|
|
const nsACString& aGroup,
|
|
|
|
const nsACString& aOrigin,
|
|
|
|
UsageInfo* aUsageInfo) = 0;
|
2013-03-26 04:13:17 -07:00
|
|
|
|
2013-06-05 01:11:23 -07:00
|
|
|
virtual void
|
2013-09-10 21:18:36 -07:00
|
|
|
OnOriginClearCompleted(PersistenceType aPersistenceType,
|
2014-11-28 00:44:12 -08:00
|
|
|
const nsACString& aOrigin) = 0;
|
2013-06-05 01:11:23 -07:00
|
|
|
|
|
|
|
virtual void
|
|
|
|
ReleaseIOThreadObjects() = 0;
|
|
|
|
|
|
|
|
// Methods which are called on the main thred.
|
2013-03-26 04:13:17 -07:00
|
|
|
virtual void
|
|
|
|
WaitForStoragesToComplete(nsTArray<nsIOfflineStorage*>& aStorages,
|
|
|
|
nsIRunnable* aCallback) = 0;
|
|
|
|
|
|
|
|
virtual void
|
2015-04-14 01:57:41 -07:00
|
|
|
ShutdownWorkThreads() = 0;
|
2013-03-26 04:13:17 -07:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~Client()
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
END_QUOTA_NAMESPACE
|
|
|
|
|
|
|
|
#endif // mozilla_dom_quota_client_h__
|