2012-12-17 19:25:10 +00: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_quotamanager_h__
|
|
|
|
#define mozilla_dom_quota_quotamanager_h__
|
|
|
|
|
|
|
|
#include "QuotaCommon.h"
|
|
|
|
|
2013-03-26 11:13:17 +00:00
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsIQuotaManager.h"
|
|
|
|
|
2013-09-11 04:18:36 +00:00
|
|
|
#include "mozilla/dom/Nullable.h"
|
2012-12-17 19:25:10 +00:00
|
|
|
#include "mozilla/Mutex.h"
|
2013-09-11 04:18:36 +00:00
|
|
|
|
2013-03-26 11:13:17 +00:00
|
|
|
#include "nsClassHashtable.h"
|
2012-12-17 19:25:10 +00:00
|
|
|
#include "nsRefPtrHashtable.h"
|
|
|
|
|
2013-03-26 11:13:17 +00:00
|
|
|
#include "ArrayCluster.h"
|
|
|
|
#include "Client.h"
|
2013-09-11 04:18:36 +00:00
|
|
|
#include "PersistenceType.h"
|
2013-03-26 11:13:17 +00:00
|
|
|
|
|
|
|
#define QUOTA_MANAGER_CONTRACTID "@mozilla.org/dom/quota/manager;1"
|
|
|
|
|
|
|
|
class nsIOfflineStorage;
|
|
|
|
class nsIPrincipal;
|
|
|
|
class nsIThread;
|
|
|
|
class nsITimer;
|
|
|
|
class nsIURI;
|
2012-12-19 17:45:57 +00:00
|
|
|
class nsPIDOMWindow;
|
2013-09-19 13:54:39 +00:00
|
|
|
class nsIRunnable;
|
2012-12-19 17:45:57 +00:00
|
|
|
|
2014-09-26 23:21:57 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class ContentParent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-17 19:25:10 +00:00
|
|
|
BEGIN_QUOTA_NAMESPACE
|
|
|
|
|
2013-03-26 11:13:17 +00:00
|
|
|
class AcquireListener;
|
|
|
|
class AsyncUsageRunnable;
|
2013-09-11 04:18:36 +00:00
|
|
|
class CollectOriginsHelper;
|
|
|
|
class FinalizeOriginEvictionRunnable;
|
|
|
|
class GroupInfo;
|
2015-01-22 08:40:42 +00:00
|
|
|
class GroupInfoPair;
|
2013-03-26 11:13:17 +00:00
|
|
|
class OriginClearRunnable;
|
2012-12-17 19:25:10 +00:00
|
|
|
class OriginInfo;
|
2013-03-26 11:13:17 +00:00
|
|
|
class OriginOrPatternString;
|
|
|
|
class QuotaObject;
|
2013-09-11 04:18:36 +00:00
|
|
|
class ResetOrClearRunnable;
|
2013-03-26 11:13:17 +00:00
|
|
|
struct SynchronizedOp;
|
2012-12-17 19:25:10 +00:00
|
|
|
|
2014-11-04 20:44:56 +00:00
|
|
|
struct OriginParams
|
|
|
|
{
|
|
|
|
OriginParams(PersistenceType aPersistenceType,
|
2014-11-28 08:44:12 +00:00
|
|
|
const nsACString& aOrigin,
|
|
|
|
bool aIsApp)
|
2014-11-04 20:44:56 +00:00
|
|
|
: mOrigin(aOrigin)
|
|
|
|
, mPersistenceType(aPersistenceType)
|
2014-11-28 08:44:12 +00:00
|
|
|
, mIsApp(aIsApp)
|
2014-11-04 20:44:56 +00:00
|
|
|
{ }
|
|
|
|
|
|
|
|
nsCString mOrigin;
|
|
|
|
PersistenceType mPersistenceType;
|
2014-11-28 08:44:12 +00:00
|
|
|
bool mIsApp;
|
2014-11-04 20:44:56 +00:00
|
|
|
};
|
|
|
|
|
2013-03-26 11:13:17 +00:00
|
|
|
class QuotaManager MOZ_FINAL : public nsIQuotaManager,
|
|
|
|
public nsIObserver
|
2012-12-17 19:25:10 +00:00
|
|
|
{
|
2013-03-26 11:13:17 +00:00
|
|
|
friend class AsyncUsageRunnable;
|
2013-09-11 04:18:36 +00:00
|
|
|
friend class CollectOriginsHelper;
|
|
|
|
friend class FinalizeOriginEvictionRunnable;
|
|
|
|
friend class GroupInfo;
|
2013-03-26 11:13:17 +00:00
|
|
|
friend class OriginClearRunnable;
|
2012-12-17 19:25:10 +00:00
|
|
|
friend class OriginInfo;
|
|
|
|
friend class QuotaObject;
|
2013-09-11 04:18:36 +00:00
|
|
|
friend class ResetOrClearRunnable;
|
2012-12-17 19:25:10 +00:00
|
|
|
|
2014-09-26 23:21:57 +00:00
|
|
|
typedef mozilla::dom::ContentParent ContentParent;
|
|
|
|
|
2013-03-26 11:13:17 +00:00
|
|
|
enum MozBrowserPatternFlag
|
2012-12-17 19:25:10 +00:00
|
|
|
{
|
2013-03-26 11:13:17 +00:00
|
|
|
MozBrowser = 0,
|
|
|
|
NotMozBrowser,
|
|
|
|
IgnoreMozBrowser
|
|
|
|
};
|
2012-12-17 19:25:10 +00:00
|
|
|
|
2014-11-04 20:44:56 +00:00
|
|
|
typedef nsClassHashtable<nsCStringHashKey,
|
|
|
|
nsTArray<nsIOfflineStorage*>> LiveStorageTable;
|
|
|
|
|
2012-12-17 19:25:10 +00:00
|
|
|
public:
|
2013-03-26 11:13:17 +00:00
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIQUOTAMANAGER
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
2012-12-17 19:25:10 +00:00
|
|
|
// Returns a non-owning reference.
|
|
|
|
static QuotaManager*
|
|
|
|
GetOrCreate();
|
|
|
|
|
|
|
|
// Returns a non-owning reference.
|
|
|
|
static QuotaManager*
|
|
|
|
Get();
|
|
|
|
|
2013-03-26 11:13:17 +00:00
|
|
|
// Returns an owning reference! No one should call this but the factory.
|
|
|
|
static QuotaManager*
|
|
|
|
FactoryCreate();
|
|
|
|
|
|
|
|
// Returns true if we've begun the shutdown process.
|
|
|
|
static bool IsShuttingDown();
|
|
|
|
|
2012-12-17 19:25:10 +00:00
|
|
|
void
|
2013-09-11 04:18:36 +00:00
|
|
|
InitQuotaForOrigin(PersistenceType aPersistenceType,
|
|
|
|
const nsACString& aGroup,
|
|
|
|
const nsACString& aOrigin,
|
2014-11-04 20:44:56 +00:00
|
|
|
bool aIsApp,
|
2013-09-11 04:18:36 +00:00
|
|
|
uint64_t aUsageBytes,
|
|
|
|
int64_t aAccessTime);
|
2012-12-17 19:25:10 +00:00
|
|
|
|
|
|
|
void
|
2013-09-11 04:18:36 +00:00
|
|
|
DecreaseUsageForOrigin(PersistenceType aPersistenceType,
|
|
|
|
const nsACString& aGroup,
|
|
|
|
const nsACString& aOrigin,
|
2012-12-17 19:25:10 +00:00
|
|
|
int64_t aSize);
|
|
|
|
|
|
|
|
void
|
2013-09-11 04:18:36 +00:00
|
|
|
UpdateOriginAccessTime(PersistenceType aPersistenceType,
|
|
|
|
const nsACString& aGroup,
|
|
|
|
const nsACString& aOrigin);
|
|
|
|
|
|
|
|
void
|
|
|
|
RemoveQuota();
|
|
|
|
|
|
|
|
void
|
|
|
|
RemoveQuotaForOrigin(PersistenceType aPersistenceType,
|
|
|
|
const nsACString& aGroup,
|
|
|
|
const nsACString& aOrigin)
|
|
|
|
{
|
|
|
|
MutexAutoLock lock(mQuotaMutex);
|
|
|
|
LockedRemoveQuotaForOrigin(aPersistenceType, aGroup, aOrigin);
|
|
|
|
}
|
|
|
|
|
2012-12-17 19:25:10 +00:00
|
|
|
already_AddRefed<QuotaObject>
|
2013-09-11 04:18:36 +00:00
|
|
|
GetQuotaObject(PersistenceType aPersistenceType,
|
|
|
|
const nsACString& aGroup,
|
|
|
|
const nsACString& aOrigin,
|
2012-12-17 19:25:10 +00:00
|
|
|
nsIFile* aFile);
|
|
|
|
|
|
|
|
already_AddRefed<QuotaObject>
|
2013-09-11 04:18:36 +00:00
|
|
|
GetQuotaObject(PersistenceType aPersistenceType,
|
|
|
|
const nsACString& aGroup,
|
|
|
|
const nsACString& aOrigin,
|
2012-12-17 19:25:10 +00:00
|
|
|
const nsAString& aPath);
|
|
|
|
|
2012-12-19 17:45:57 +00:00
|
|
|
// Set the Window that the current thread is doing operations for.
|
|
|
|
// The caller is responsible for ensuring that aWindow is held alive.
|
|
|
|
static void
|
|
|
|
SetCurrentWindow(nsPIDOMWindow* aWindow)
|
2012-12-17 19:25:10 +00:00
|
|
|
{
|
2012-12-19 17:45:57 +00:00
|
|
|
QuotaManager* quotaManager = Get();
|
|
|
|
NS_ASSERTION(quotaManager, "Must have a manager here!");
|
2012-12-17 19:25:10 +00:00
|
|
|
|
2012-12-19 17:45:57 +00:00
|
|
|
quotaManager->SetCurrentWindowInternal(aWindow);
|
2012-12-17 19:25:10 +00:00
|
|
|
}
|
|
|
|
|
2013-03-26 11:13:17 +00:00
|
|
|
// Called when a storage is created.
|
|
|
|
bool
|
|
|
|
RegisterStorage(nsIOfflineStorage* aStorage);
|
|
|
|
|
|
|
|
// Called when a storage is being unlinked or destroyed.
|
|
|
|
void
|
|
|
|
UnregisterStorage(nsIOfflineStorage* aStorage);
|
|
|
|
|
2014-09-26 23:21:57 +00:00
|
|
|
// Called when a process is being shot down. Forces any live storage objects
|
|
|
|
// to close themselves and aborts any running transactions.
|
|
|
|
void
|
|
|
|
AbortCloseStoragesForProcess(ContentParent* aContentParent);
|
|
|
|
|
2013-03-26 11:13:17 +00:00
|
|
|
// Waits for storages to be cleared and for version change transactions to
|
|
|
|
// complete before dispatching the given runnable.
|
|
|
|
nsresult
|
|
|
|
WaitForOpenAllowed(const OriginOrPatternString& aOriginOrPattern,
|
2013-09-11 04:18:36 +00:00
|
|
|
Nullable<PersistenceType> aPersistenceType,
|
2013-11-25 16:53:48 +00:00
|
|
|
const nsACString& aId, nsIRunnable* aRunnable);
|
2013-03-26 11:13:17 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
AllowNextSynchronizedOp(const OriginOrPatternString& aOriginOrPattern,
|
2013-09-11 04:18:36 +00:00
|
|
|
Nullable<PersistenceType> aPersistenceType,
|
2013-11-25 16:53:48 +00:00
|
|
|
const nsACString& aId);
|
2013-03-26 11:13:17 +00:00
|
|
|
|
|
|
|
bool
|
2014-04-14 20:48:49 +00:00
|
|
|
IsClearOriginPending(const nsACString& aPattern,
|
|
|
|
Nullable<PersistenceType> aPersistenceType)
|
2013-03-26 11:13:17 +00:00
|
|
|
{
|
2014-04-14 20:48:49 +00:00
|
|
|
return !!FindSynchronizedOp(aPattern, aPersistenceType, EmptyCString());
|
2013-03-26 11:13:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2013-09-11 04:18:36 +00:00
|
|
|
GetDirectoryForOrigin(PersistenceType aPersistenceType,
|
|
|
|
const nsACString& aASCIIOrigin,
|
2013-03-26 11:13:17 +00:00
|
|
|
nsIFile** aDirectory) const;
|
|
|
|
|
|
|
|
nsresult
|
2013-09-11 04:18:36 +00:00
|
|
|
EnsureOriginIsInitialized(PersistenceType aPersistenceType,
|
|
|
|
const nsACString& aGroup,
|
|
|
|
const nsACString& aOrigin,
|
2014-11-04 20:44:56 +00:00
|
|
|
bool aIsApp,
|
2013-03-26 11:13:17 +00:00
|
|
|
nsIFile** aDirectory);
|
|
|
|
|
|
|
|
void
|
2013-09-11 04:18:36 +00:00
|
|
|
OriginClearCompleted(PersistenceType aPersistenceType,
|
2014-11-28 08:44:12 +00:00
|
|
|
const nsACString& aOrigin,
|
|
|
|
bool aIsApp);
|
2013-09-11 04:18:36 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
ResetOrClearCompleted();
|
|
|
|
|
|
|
|
void
|
|
|
|
AssertCurrentThreadOwnsQuotaMutex()
|
|
|
|
{
|
|
|
|
mQuotaMutex.AssertCurrentThreadOwns();
|
|
|
|
}
|
2013-03-26 11:13:17 +00:00
|
|
|
|
|
|
|
nsIThread*
|
|
|
|
IOThread()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mIOThread, "This should never be null!");
|
|
|
|
return mIOThread;
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<Client>
|
|
|
|
GetClient(Client::Type aClientType);
|
|
|
|
|
2014-10-13 19:12:25 +00:00
|
|
|
const nsString&
|
|
|
|
GetStoragePath() const
|
|
|
|
{
|
|
|
|
return mStoragePath;
|
|
|
|
}
|
|
|
|
|
2013-03-26 11:13:17 +00:00
|
|
|
const nsString&
|
2013-09-11 04:18:36 +00:00
|
|
|
GetStoragePath(PersistenceType aPersistenceType) const
|
2013-03-26 11:13:17 +00:00
|
|
|
{
|
2013-09-11 04:18:36 +00:00
|
|
|
if (aPersistenceType == PERSISTENCE_TYPE_PERSISTENT) {
|
2014-11-28 08:44:12 +00:00
|
|
|
return mPermanentStoragePath;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aPersistenceType == PERSISTENCE_TYPE_TEMPORARY) {
|
|
|
|
return mTemporaryStoragePath;
|
2013-09-11 04:18:36 +00:00
|
|
|
}
|
|
|
|
|
2014-11-28 08:44:12 +00:00
|
|
|
MOZ_ASSERT(aPersistenceType == PERSISTENCE_TYPE_DEFAULT);
|
2013-09-11 04:18:36 +00:00
|
|
|
|
2014-11-28 08:44:12 +00:00
|
|
|
return mDefaultStoragePath;
|
2013-09-11 04:18:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t
|
2014-05-20 22:19:59 +00:00
|
|
|
GetGroupLimit() const;
|
2013-03-26 11:13:17 +00:00
|
|
|
|
2013-11-25 16:53:48 +00:00
|
|
|
static void
|
2013-09-11 04:18:36 +00:00
|
|
|
GetStorageId(PersistenceType aPersistenceType,
|
|
|
|
const nsACString& aOrigin,
|
2013-11-18 21:49:53 +00:00
|
|
|
Client::Type aClientType,
|
2013-11-25 16:53:48 +00:00
|
|
|
const nsAString& aName,
|
|
|
|
nsACString& aDatabaseId);
|
2013-03-26 11:13:17 +00:00
|
|
|
|
|
|
|
static nsresult
|
2013-09-11 04:18:36 +00:00
|
|
|
GetInfoFromURI(nsIURI* aURI,
|
|
|
|
uint32_t aAppId,
|
|
|
|
bool aInMozBrowser,
|
|
|
|
nsACString* aGroup,
|
2014-09-26 23:21:57 +00:00
|
|
|
nsACString* aOrigin,
|
2015-01-22 08:40:42 +00:00
|
|
|
bool* aIsApp);
|
2013-03-26 11:13:17 +00:00
|
|
|
|
|
|
|
static nsresult
|
2013-09-11 04:18:36 +00:00
|
|
|
GetInfoFromPrincipal(nsIPrincipal* aPrincipal,
|
|
|
|
nsACString* aGroup,
|
2014-09-26 23:21:57 +00:00
|
|
|
nsACString* aOrigin,
|
2015-01-22 08:40:42 +00:00
|
|
|
bool* aIsApp);
|
2013-03-26 11:13:17 +00:00
|
|
|
|
|
|
|
static nsresult
|
2013-09-11 04:18:36 +00:00
|
|
|
GetInfoFromWindow(nsPIDOMWindow* aWindow,
|
|
|
|
nsACString* aGroup,
|
2014-09-26 23:21:57 +00:00
|
|
|
nsACString* aOrigin,
|
2015-01-22 08:40:42 +00:00
|
|
|
bool* aIsApp);
|
2013-03-26 11:13:17 +00:00
|
|
|
|
2013-09-19 12:45:25 +00:00
|
|
|
static void
|
|
|
|
GetInfoForChrome(nsACString* aGroup,
|
2014-09-26 23:21:57 +00:00
|
|
|
nsACString* aOrigin,
|
2015-01-22 08:40:42 +00:00
|
|
|
bool* aIsApp);
|
2014-11-04 20:44:56 +00:00
|
|
|
|
|
|
|
static bool
|
2015-01-09 15:56:23 +00:00
|
|
|
IsOriginWhitelistedForPersistentStorage(const nsACString& aOrigin);
|
|
|
|
|
2014-11-28 08:44:12 +00:00
|
|
|
static bool
|
|
|
|
IsFirstPromptRequired(PersistenceType aPersistenceType,
|
|
|
|
const nsACString& aOrigin,
|
|
|
|
bool aIsApp);
|
|
|
|
|
2014-11-04 20:44:56 +00:00
|
|
|
static bool
|
|
|
|
IsQuotaEnforced(PersistenceType aPersistenceType,
|
|
|
|
const nsACString& aOrigin,
|
2015-01-22 08:40:42 +00:00
|
|
|
bool aIsApp);
|
2013-09-19 12:45:25 +00:00
|
|
|
|
2014-09-26 23:21:57 +00:00
|
|
|
static void
|
|
|
|
ChromeOrigin(nsACString& aOrigin);
|
|
|
|
|
2013-03-26 11:13:17 +00:00
|
|
|
static void
|
|
|
|
GetOriginPatternString(uint32_t aAppId, bool aBrowserOnly,
|
|
|
|
const nsACString& aOrigin, nsAutoCString& _retval)
|
|
|
|
{
|
|
|
|
return GetOriginPatternString(aAppId,
|
|
|
|
aBrowserOnly ? MozBrowser : NotMozBrowser,
|
|
|
|
aOrigin, _retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
GetOriginPatternStringMaybeIgnoreBrowser(uint32_t aAppId, bool aBrowserOnly,
|
|
|
|
nsAutoCString& _retval)
|
|
|
|
{
|
|
|
|
return GetOriginPatternString(aAppId,
|
|
|
|
aBrowserOnly ? MozBrowser : IgnoreMozBrowser,
|
|
|
|
EmptyCString(), _retval);
|
|
|
|
}
|
|
|
|
|
2012-12-19 17:45:57 +00:00
|
|
|
private:
|
|
|
|
QuotaManager();
|
|
|
|
|
|
|
|
virtual ~QuotaManager();
|
|
|
|
|
2013-03-26 11:13:17 +00:00
|
|
|
nsresult
|
2012-12-19 17:45:57 +00:00
|
|
|
Init();
|
|
|
|
|
|
|
|
void
|
|
|
|
SetCurrentWindowInternal(nsPIDOMWindow* aWindow);
|
|
|
|
|
2013-09-11 04:18:36 +00:00
|
|
|
uint64_t
|
|
|
|
LockedCollectOriginsForEviction(uint64_t aMinSizeToBeFreed,
|
|
|
|
nsTArray<OriginInfo*>& aOriginInfos);
|
|
|
|
|
|
|
|
void
|
|
|
|
LockedRemoveQuotaForOrigin(PersistenceType aPersistenceType,
|
|
|
|
const nsACString& aGroup,
|
|
|
|
const nsACString& aOrigin);
|
|
|
|
|
2013-03-26 11:13:17 +00:00
|
|
|
nsresult
|
|
|
|
AcquireExclusiveAccess(const nsACString& aOrigin,
|
2014-04-14 20:48:49 +00:00
|
|
|
Nullable<PersistenceType> aPersistenceType,
|
2014-12-06 15:31:53 +00:00
|
|
|
nsIRunnable* aRunnable);
|
2013-03-26 11:13:17 +00:00
|
|
|
|
2013-09-11 04:18:36 +00:00
|
|
|
void
|
|
|
|
AddSynchronizedOp(const OriginOrPatternString& aOriginOrPattern,
|
2013-11-25 16:53:48 +00:00
|
|
|
Nullable<PersistenceType> aPersistenceType);
|
2013-09-11 04:18:36 +00:00
|
|
|
|
2013-03-26 11:13:17 +00:00
|
|
|
SynchronizedOp*
|
|
|
|
FindSynchronizedOp(const nsACString& aPattern,
|
2013-09-11 04:18:36 +00:00
|
|
|
Nullable<PersistenceType> aPersistenceType,
|
2013-11-25 16:53:48 +00:00
|
|
|
const nsACString& aId);
|
2013-03-26 11:13:17 +00:00
|
|
|
|
|
|
|
nsresult
|
2013-09-11 04:18:36 +00:00
|
|
|
MaybeUpgradeIndexedDBDirectory();
|
|
|
|
|
2014-11-28 08:44:12 +00:00
|
|
|
nsresult
|
|
|
|
MaybeUpgradePersistentStorageDirectory();
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
MaybeUpgradeStorageArea();
|
|
|
|
|
2014-11-04 20:44:56 +00:00
|
|
|
nsresult
|
|
|
|
InitializeRepository(PersistenceType aPersistenceType);
|
|
|
|
|
2013-09-11 04:18:36 +00:00
|
|
|
nsresult
|
|
|
|
InitializeOrigin(PersistenceType aPersistenceType,
|
|
|
|
const nsACString& aGroup,
|
|
|
|
const nsACString& aOrigin,
|
2014-11-04 20:44:56 +00:00
|
|
|
bool aIsApp,
|
2013-09-11 04:18:36 +00:00
|
|
|
int64_t aAccessTime,
|
|
|
|
nsIFile* aDirectory);
|
2013-03-26 11:13:17 +00:00
|
|
|
|
|
|
|
nsresult
|
2013-09-11 04:18:36 +00:00
|
|
|
ClearStoragesForApp(uint32_t aAppId, bool aBrowserOnly);
|
|
|
|
|
|
|
|
void
|
|
|
|
CheckTemporaryStorageLimits();
|
|
|
|
|
|
|
|
// Collect inactive and the least recently used origins.
|
|
|
|
uint64_t
|
|
|
|
CollectOriginsForEviction(uint64_t aMinSizeToBeFreed,
|
|
|
|
nsTArray<OriginInfo*>& aOriginInfos);
|
|
|
|
|
|
|
|
void
|
2014-11-04 20:44:56 +00:00
|
|
|
DeleteFilesForOrigin(PersistenceType aPersistenceType,
|
|
|
|
const nsACString& aOrigin);
|
2013-09-11 04:18:36 +00:00
|
|
|
|
|
|
|
void
|
2014-11-04 20:44:56 +00:00
|
|
|
FinalizeOriginEviction(nsTArray<OriginParams>& aOrigins);
|
2013-09-11 04:18:36 +00:00
|
|
|
|
|
|
|
void
|
2014-11-04 20:44:56 +00:00
|
|
|
SaveOriginAccessTime(PersistenceType aPersistenceType,
|
|
|
|
const nsACString& aOrigin,
|
|
|
|
int64_t aTimestamp);
|
2013-03-26 11:13:17 +00:00
|
|
|
|
2013-06-05 08:11:23 +00:00
|
|
|
void
|
|
|
|
ReleaseIOThreadObjects()
|
|
|
|
{
|
|
|
|
AssertIsOnIOThread();
|
|
|
|
|
|
|
|
for (uint32_t index = 0; index < Client::TYPE_MAX; index++) {
|
|
|
|
mClients[index]->ReleaseIOThreadObjects();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-04 20:44:56 +00:00
|
|
|
LiveStorageTable&
|
|
|
|
GetLiveStorageTable(PersistenceType aPersistenceType);
|
|
|
|
|
2013-03-26 11:13:17 +00:00
|
|
|
static void
|
|
|
|
GetOriginPatternString(uint32_t aAppId,
|
|
|
|
MozBrowserPatternFlag aBrowserFlag,
|
|
|
|
const nsACString& aOrigin,
|
|
|
|
nsAutoCString& _retval);
|
|
|
|
|
2013-09-11 04:18:36 +00:00
|
|
|
static PLDHashOperator
|
|
|
|
RemoveQuotaCallback(const nsACString& aKey,
|
2015-01-22 08:40:42 +00:00
|
|
|
nsAutoPtr<GroupInfoPair>& aValue,
|
2013-09-11 04:18:36 +00:00
|
|
|
void* aUserArg);
|
|
|
|
|
|
|
|
static PLDHashOperator
|
|
|
|
GetOriginsExceedingGroupLimit(const nsACString& aKey,
|
2015-01-22 08:40:42 +00:00
|
|
|
GroupInfoPair* aValue,
|
2013-09-11 04:18:36 +00:00
|
|
|
void* aUserArg);
|
|
|
|
|
|
|
|
static PLDHashOperator
|
|
|
|
GetAllTemporaryStorageOrigins(const nsACString& aKey,
|
2015-01-22 08:40:42 +00:00
|
|
|
GroupInfoPair* aValue,
|
2013-09-11 04:18:36 +00:00
|
|
|
void* aUserArg);
|
|
|
|
|
|
|
|
static PLDHashOperator
|
2014-11-04 20:44:56 +00:00
|
|
|
AddLiveStorageOrigins(const nsACString& aKey,
|
|
|
|
nsTArray<nsIOfflineStorage*>* aValue,
|
|
|
|
void* aUserArg);
|
2013-09-11 04:18:36 +00:00
|
|
|
|
|
|
|
static PLDHashOperator
|
|
|
|
GetInactiveTemporaryStorageOrigins(const nsACString& aKey,
|
2015-01-22 08:40:42 +00:00
|
|
|
GroupInfoPair* aValue,
|
2013-09-11 04:18:36 +00:00
|
|
|
void* aUserArg);
|
|
|
|
|
2012-12-19 17:45:57 +00:00
|
|
|
// TLS storage index for the current thread's window.
|
|
|
|
unsigned int mCurrentWindowIndex;
|
|
|
|
|
2012-12-17 19:25:10 +00:00
|
|
|
mozilla::Mutex mQuotaMutex;
|
|
|
|
|
2015-01-22 08:40:42 +00:00
|
|
|
nsClassHashtable<nsCStringHashKey, GroupInfoPair> mGroupInfoPairs;
|
2013-03-26 11:13:17 +00:00
|
|
|
|
|
|
|
// Maintains a list of live storages per origin.
|
|
|
|
nsClassHashtable<nsCStringHashKey,
|
|
|
|
ArrayCluster<nsIOfflineStorage*> > mLiveStorages;
|
|
|
|
|
2014-11-04 20:44:56 +00:00
|
|
|
LiveStorageTable mTemporaryLiveStorageTable;
|
2014-11-28 08:44:12 +00:00
|
|
|
LiveStorageTable mDefaultLiveStorageTable;
|
2014-11-04 20:44:56 +00:00
|
|
|
|
2013-03-26 11:13:17 +00:00
|
|
|
// Maintains a list of synchronized operatons that are in progress or queued.
|
|
|
|
nsAutoTArray<nsAutoPtr<SynchronizedOp>, 5> mSynchronizedOps;
|
|
|
|
|
|
|
|
// Thread on which IO is performed.
|
|
|
|
nsCOMPtr<nsIThread> mIOThread;
|
|
|
|
|
|
|
|
// A timer that gets activated at shutdown to ensure we close all storages.
|
|
|
|
nsCOMPtr<nsITimer> mShutdownTimer;
|
|
|
|
|
|
|
|
// A list of all successfully initialized origins. This list isn't protected
|
|
|
|
// by any mutex but it is only ever touched on the IO thread.
|
|
|
|
nsTArray<nsCString> mInitializedOrigins;
|
|
|
|
|
|
|
|
nsAutoTArray<nsRefPtr<Client>, Client::TYPE_MAX> mClients;
|
|
|
|
|
2013-09-11 04:18:36 +00:00
|
|
|
nsString mIndexedDBPath;
|
2014-10-13 19:12:25 +00:00
|
|
|
nsString mStoragePath;
|
2014-11-28 08:44:12 +00:00
|
|
|
nsString mPermanentStoragePath;
|
2013-09-11 04:18:36 +00:00
|
|
|
nsString mTemporaryStoragePath;
|
2014-11-28 08:44:12 +00:00
|
|
|
nsString mDefaultStoragePath;
|
2013-09-11 04:18:36 +00:00
|
|
|
|
|
|
|
uint64_t mTemporaryStorageLimit;
|
|
|
|
uint64_t mTemporaryStorageUsage;
|
|
|
|
bool mTemporaryStorageInitialized;
|
|
|
|
|
|
|
|
bool mStorageAreaInitialized;
|
2012-12-19 17:45:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class AutoEnterWindow
|
|
|
|
{
|
|
|
|
public:
|
2014-08-08 13:49:39 +00:00
|
|
|
explicit AutoEnterWindow(nsPIDOMWindow* aWindow)
|
2012-12-19 17:45:57 +00:00
|
|
|
{
|
|
|
|
QuotaManager::SetCurrentWindow(aWindow);
|
|
|
|
}
|
|
|
|
|
|
|
|
~AutoEnterWindow()
|
|
|
|
{
|
|
|
|
QuotaManager::SetCurrentWindow(nullptr);
|
|
|
|
}
|
2012-12-17 19:25:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
END_QUOTA_NAMESPACE
|
|
|
|
|
|
|
|
#endif /* mozilla_dom_quota_quotamanager_h__ */
|