Index: content/browser/service_worker/service_worker_cache_storage_manager.h |
diff --git a/content/browser/service_worker/service_worker_cache_storage_manager.h b/content/browser/service_worker/service_worker_cache_storage_manager.h |
index 385450d3554df6e5f12f602b51f3de3eb3ab5c76..0037f8031dc61ad2c6541a0fec6eaa4b3dc7aa2a 100644 |
--- a/content/browser/service_worker/service_worker_cache_storage_manager.h |
+++ b/content/browser/service_worker/service_worker_cache_storage_manager.h |
@@ -12,6 +12,7 @@ |
#include "base/files/file_path.h" |
#include "content/browser/service_worker/service_worker_cache_storage.h" |
#include "content/common/content_export.h" |
+#include "storage/browser/quota/quota_client.h" |
#include "url/gurl.h" |
namespace base { |
@@ -24,10 +25,13 @@ class URLRequestContext; |
namespace storage { |
class BlobStorageContext; |
+class QuotaManagerProxy; |
} |
namespace content { |
+class ServiceWorkerCacheQuotaClient; |
+ |
// Keeps track of a ServiceWorkerCacheStorage per origin. There is one |
// ServiceWorkerCacheStorageManager per ServiceWorkerContextCore. |
// TODO(jkarlin): Remove ServiceWorkerCacheStorage from memory once they're no |
@@ -36,7 +40,8 @@ class CONTENT_EXPORT ServiceWorkerCacheStorageManager { |
public: |
static scoped_ptr<ServiceWorkerCacheStorageManager> Create( |
const base::FilePath& path, |
- const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner); |
+ const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner, |
+ storage::QuotaManagerProxy* quota_manager_proxy); |
static scoped_ptr<ServiceWorkerCacheStorageManager> Create( |
ServiceWorkerCacheStorageManager* old_manager); |
@@ -76,19 +81,36 @@ class CONTENT_EXPORT ServiceWorkerCacheStorageManager { |
net::URLRequestContext* request_context, |
base::WeakPtr<storage::BlobStorageContext> blob_storage_context); |
+ base::WeakPtr<ServiceWorkerCacheStorageManager> AsWeakPtr() { |
+ return weak_ptr_factory_.GetWeakPtr(); |
+ } |
+ |
private: |
+ friend class ServiceWorkerCacheQuotaClient; |
+ |
typedef std::map<GURL, ServiceWorkerCacheStorage*> |
ServiceWorkerCacheStorageMap; |
ServiceWorkerCacheStorageManager( |
const base::FilePath& path, |
- const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner); |
+ const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner, |
+ storage::QuotaManagerProxy* quota_manager_proxy); |
// The returned ServiceWorkerCacheStorage* is owned by |
// service_worker_cache_storages_. |
ServiceWorkerCacheStorage* FindOrCreateServiceWorkerCacheManager( |
const GURL& origin); |
+ // QuotaClient support |
+ void GetOriginUsage(const GURL& origin_url, |
+ const storage::QuotaClient::GetUsageCallback& callback); |
+ void GetOrigins(const storage::QuotaClient::GetOriginsCallback& callback); |
+ void GetOriginsForHost( |
+ const std::string& host, |
+ const storage::QuotaClient::GetOriginsCallback& callback); |
+ void DeleteOriginData(const GURL& origin, |
+ const storage::QuotaClient::DeletionCallback& callback); |
+ |
net::URLRequestContext* url_request_context() const { |
return request_context_; |
} |
@@ -100,9 +122,13 @@ class CONTENT_EXPORT ServiceWorkerCacheStorageManager { |
return cache_task_runner_; |
} |
+ bool IsMemoryBacked() const { return root_path_.empty(); } |
+ |
base::FilePath root_path_; |
scoped_refptr<base::SequencedTaskRunner> cache_task_runner_; |
+ scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy_; |
+ |
// The map owns the CacheStorages and the CacheStorages are only accessed on |
// |cache_task_runner_|. |
ServiceWorkerCacheStorageMap cache_storage_map_; |
@@ -110,6 +136,7 @@ class CONTENT_EXPORT ServiceWorkerCacheStorageManager { |
net::URLRequestContext* request_context_; |
base::WeakPtr<storage::BlobStorageContext> blob_context_; |
+ base::WeakPtrFactory<ServiceWorkerCacheStorageManager> weak_ptr_factory_; |
DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCacheStorageManager); |
}; |