dom/quota/Client.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ts=2 et sw=2 tw=80: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef mozilla_dom_quota_client_h__
michael@0 8 #define mozilla_dom_quota_client_h__
michael@0 9
michael@0 10 #include "mozilla/dom/quota/QuotaCommon.h"
michael@0 11
michael@0 12 #include "PersistenceType.h"
michael@0 13
michael@0 14 class nsIOfflineStorage;
michael@0 15 class nsIRunnable;
michael@0 16
michael@0 17 #define IDB_DIRECTORY_NAME "idb"
michael@0 18 #define ASMJSCACHE_DIRECTORY_NAME "asmjs"
michael@0 19
michael@0 20 BEGIN_QUOTA_NAMESPACE
michael@0 21
michael@0 22 class OriginOrPatternString;
michael@0 23 class UsageInfo;
michael@0 24
michael@0 25 // An abstract interface for quota manager clients.
michael@0 26 // Each storage API must provide an implementation of this interface in order
michael@0 27 // to participate in centralized quota and storage handling.
michael@0 28 class Client
michael@0 29 {
michael@0 30 public:
michael@0 31 NS_IMETHOD_(MozExternalRefCountType)
michael@0 32 AddRef() = 0;
michael@0 33
michael@0 34 NS_IMETHOD_(MozExternalRefCountType)
michael@0 35 Release() = 0;
michael@0 36
michael@0 37 enum Type {
michael@0 38 IDB = 0,
michael@0 39 //LS,
michael@0 40 //APPCACHE,
michael@0 41 ASMJS,
michael@0 42 TYPE_MAX
michael@0 43 };
michael@0 44
michael@0 45 virtual Type
michael@0 46 GetType() = 0;
michael@0 47
michael@0 48 static nsresult
michael@0 49 TypeToText(Type aType, nsAString& aText)
michael@0 50 {
michael@0 51 switch (aType) {
michael@0 52 case IDB:
michael@0 53 aText.AssignLiteral(IDB_DIRECTORY_NAME);
michael@0 54 break;
michael@0 55
michael@0 56 case ASMJS:
michael@0 57 aText.AssignLiteral(ASMJSCACHE_DIRECTORY_NAME);
michael@0 58 break;
michael@0 59
michael@0 60 case TYPE_MAX:
michael@0 61 default:
michael@0 62 NS_NOTREACHED("Bad id value!");
michael@0 63 return NS_ERROR_UNEXPECTED;
michael@0 64 }
michael@0 65
michael@0 66 return NS_OK;
michael@0 67 }
michael@0 68
michael@0 69 static nsresult
michael@0 70 TypeFromText(const nsAString& aText, Type& aType)
michael@0 71 {
michael@0 72 if (aText.EqualsLiteral(IDB_DIRECTORY_NAME)) {
michael@0 73 aType = IDB;
michael@0 74 }
michael@0 75 else if (aText.EqualsLiteral(ASMJSCACHE_DIRECTORY_NAME)) {
michael@0 76 aType = ASMJS;
michael@0 77 }
michael@0 78 else {
michael@0 79 return NS_ERROR_FAILURE;
michael@0 80 }
michael@0 81
michael@0 82 return NS_OK;
michael@0 83 }
michael@0 84
michael@0 85 // Methods which are called on the IO thred.
michael@0 86 virtual nsresult
michael@0 87 InitOrigin(PersistenceType aPersistenceType,
michael@0 88 const nsACString& aGroup,
michael@0 89 const nsACString& aOrigin,
michael@0 90 UsageInfo* aUsageInfo) = 0;
michael@0 91
michael@0 92 virtual nsresult
michael@0 93 GetUsageForOrigin(PersistenceType aPersistenceType,
michael@0 94 const nsACString& aGroup,
michael@0 95 const nsACString& aOrigin,
michael@0 96 UsageInfo* aUsageInfo) = 0;
michael@0 97
michael@0 98 virtual void
michael@0 99 OnOriginClearCompleted(PersistenceType aPersistenceType,
michael@0 100 const OriginOrPatternString& aOriginOrPattern) = 0;
michael@0 101
michael@0 102 virtual void
michael@0 103 ReleaseIOThreadObjects() = 0;
michael@0 104
michael@0 105 // Methods which are called on the main thred.
michael@0 106 virtual bool
michael@0 107 IsFileServiceUtilized() = 0;
michael@0 108
michael@0 109 virtual bool
michael@0 110 IsTransactionServiceActivated() = 0;
michael@0 111
michael@0 112 virtual void
michael@0 113 WaitForStoragesToComplete(nsTArray<nsIOfflineStorage*>& aStorages,
michael@0 114 nsIRunnable* aCallback) = 0;
michael@0 115
michael@0 116 virtual void
michael@0 117 AbortTransactionsForStorage(nsIOfflineStorage* aStorage) = 0;
michael@0 118
michael@0 119 virtual bool
michael@0 120 HasTransactionsForStorage(nsIOfflineStorage* aStorage) = 0;
michael@0 121
michael@0 122 virtual void
michael@0 123 ShutdownTransactionService() = 0;
michael@0 124
michael@0 125 protected:
michael@0 126 virtual ~Client()
michael@0 127 { }
michael@0 128 };
michael@0 129
michael@0 130 END_QUOTA_NAMESPACE
michael@0 131
michael@0 132 #endif // mozilla_dom_quota_client_h__

mercurial