| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_MANAGER_H_ |
| 6 #define CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_MANAGER_H_ | 6 #define CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "base/memory/ref_counted.h" |
| 14 #include "content/browser/cache_storage/cache_storage.h" | 15 #include "content/browser/cache_storage/cache_storage.h" |
| 15 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
| 17 #include "net/url_request/url_request_context_getter.h" |
| 16 #include "storage/browser/quota/quota_client.h" | 18 #include "storage/browser/quota/quota_client.h" |
| 17 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 18 | 20 |
| 19 namespace base { | 21 namespace base { |
| 20 class SequencedTaskRunner; | 22 class SequencedTaskRunner; |
| 21 } | 23 } |
| 22 | 24 |
| 23 namespace net { | |
| 24 class URLRequestContext; | |
| 25 } | |
| 26 | |
| 27 namespace storage { | 25 namespace storage { |
| 28 class BlobStorageContext; | 26 class BlobStorageContext; |
| 29 class QuotaManagerProxy; | 27 class QuotaManagerProxy; |
| 30 } | 28 } |
| 31 | 29 |
| 32 namespace content { | 30 namespace content { |
| 33 | 31 |
| 34 class CacheStorageQuotaClient; | 32 class CacheStorageQuotaClient; |
| 35 | 33 |
| 36 // Keeps track of a CacheStorage per origin. There is one | 34 // Keeps track of a CacheStorage per origin. There is one |
| (...skipping 29 matching lines...) Expand all Loading... |
| 66 const std::string& cache_name, | 64 const std::string& cache_name, |
| 67 scoped_ptr<ServiceWorkerFetchRequest> request, | 65 scoped_ptr<ServiceWorkerFetchRequest> request, |
| 68 const CacheStorageCache::ResponseCallback& callback); | 66 const CacheStorageCache::ResponseCallback& callback); |
| 69 void MatchAllCaches(const GURL& origin, | 67 void MatchAllCaches(const GURL& origin, |
| 70 scoped_ptr<ServiceWorkerFetchRequest> request, | 68 scoped_ptr<ServiceWorkerFetchRequest> request, |
| 71 const CacheStorageCache::ResponseCallback& callback); | 69 const CacheStorageCache::ResponseCallback& callback); |
| 72 | 70 |
| 73 // This must be called before creating any of the public *Cache functions | 71 // This must be called before creating any of the public *Cache functions |
| 74 // above. | 72 // above. |
| 75 void SetBlobParametersForCache( | 73 void SetBlobParametersForCache( |
| 76 net::URLRequestContext* request_context, | 74 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, |
| 77 base::WeakPtr<storage::BlobStorageContext> blob_storage_context); | 75 base::WeakPtr<storage::BlobStorageContext> blob_storage_context); |
| 78 | 76 |
| 79 base::WeakPtr<CacheStorageManager> AsWeakPtr() { | 77 base::WeakPtr<CacheStorageManager> AsWeakPtr() { |
| 80 return weak_ptr_factory_.GetWeakPtr(); | 78 return weak_ptr_factory_.GetWeakPtr(); |
| 81 } | 79 } |
| 82 | 80 |
| 83 private: | 81 private: |
| 84 friend class CacheStorageQuotaClient; | 82 friend class CacheStorageQuotaClient; |
| 85 friend class CacheStorageManagerTest; | 83 friend class CacheStorageManagerTest; |
| 86 friend class CacheStorageMigrationTest; | 84 friend class CacheStorageMigrationTest; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 103 const std::string& host, | 101 const std::string& host, |
| 104 const storage::QuotaClient::GetOriginsCallback& callback); | 102 const storage::QuotaClient::GetOriginsCallback& callback); |
| 105 void DeleteOriginData(const GURL& origin, | 103 void DeleteOriginData(const GURL& origin, |
| 106 const storage::QuotaClient::DeletionCallback& callback); | 104 const storage::QuotaClient::DeletionCallback& callback); |
| 107 static void DeleteOriginDidClose( | 105 static void DeleteOriginDidClose( |
| 108 const GURL& origin, | 106 const GURL& origin, |
| 109 const storage::QuotaClient::DeletionCallback& callback, | 107 const storage::QuotaClient::DeletionCallback& callback, |
| 110 scoped_ptr<CacheStorage> cache_storage, | 108 scoped_ptr<CacheStorage> cache_storage, |
| 111 base::WeakPtr<CacheStorageManager> cache_manager); | 109 base::WeakPtr<CacheStorageManager> cache_manager); |
| 112 | 110 |
| 113 net::URLRequestContext* url_request_context() const { | 111 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter() |
| 114 return request_context_; | 112 const { |
| 113 return request_context_getter_; |
| 115 } | 114 } |
| 116 base::WeakPtr<storage::BlobStorageContext> blob_storage_context() const { | 115 base::WeakPtr<storage::BlobStorageContext> blob_storage_context() const { |
| 117 return blob_context_; | 116 return blob_context_; |
| 118 } | 117 } |
| 119 base::FilePath root_path() const { return root_path_; } | 118 base::FilePath root_path() const { return root_path_; } |
| 120 const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner() const { | 119 const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner() const { |
| 121 return cache_task_runner_; | 120 return cache_task_runner_; |
| 122 } | 121 } |
| 123 | 122 |
| 124 bool IsMemoryBacked() const { return root_path_.empty(); } | 123 bool IsMemoryBacked() const { return root_path_.empty(); } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 140 | 139 |
| 141 base::FilePath root_path_; | 140 base::FilePath root_path_; |
| 142 scoped_refptr<base::SequencedTaskRunner> cache_task_runner_; | 141 scoped_refptr<base::SequencedTaskRunner> cache_task_runner_; |
| 143 | 142 |
| 144 scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy_; | 143 scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy_; |
| 145 | 144 |
| 146 // The map owns the CacheStorages and the CacheStorages are only accessed on | 145 // The map owns the CacheStorages and the CacheStorages are only accessed on |
| 147 // |cache_task_runner_|. | 146 // |cache_task_runner_|. |
| 148 CacheStorageMap cache_storage_map_; | 147 CacheStorageMap cache_storage_map_; |
| 149 | 148 |
| 150 net::URLRequestContext* request_context_; | 149 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
| 151 base::WeakPtr<storage::BlobStorageContext> blob_context_; | 150 base::WeakPtr<storage::BlobStorageContext> blob_context_; |
| 152 | 151 |
| 153 base::WeakPtrFactory<CacheStorageManager> weak_ptr_factory_; | 152 base::WeakPtrFactory<CacheStorageManager> weak_ptr_factory_; |
| 154 DISALLOW_COPY_AND_ASSIGN(CacheStorageManager); | 153 DISALLOW_COPY_AND_ASSIGN(CacheStorageManager); |
| 155 }; | 154 }; |
| 156 | 155 |
| 157 } // namespace content | 156 } // namespace content |
| 158 | 157 |
| 159 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_MANAGER_H_ | 158 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_MANAGER_H_ |
| OLD | NEW |