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 |
(...skipping 13 matching lines...) Expand all Loading... |
24 } | 24 } |
25 | 25 |
26 namespace storage { | 26 namespace storage { |
27 class BlobStorageContext; | 27 class BlobStorageContext; |
28 class QuotaManagerProxy; | 28 class QuotaManagerProxy; |
29 } | 29 } |
30 | 30 |
31 namespace content { | 31 namespace content { |
32 | 32 |
33 class CacheStorageQuotaClient; | 33 class CacheStorageQuotaClient; |
34 class MigratedLegacyCacheDirectoryNameTest; | |
35 | 34 |
36 // Keeps track of a CacheStorage per origin. There is one | 35 // Keeps track of a CacheStorage per origin. There is one |
37 // CacheStorageManager per ServiceWorkerContextCore. | 36 // CacheStorageManager per ServiceWorkerContextCore. |
38 // TODO(jkarlin): Remove CacheStorage from memory once they're no | 37 // TODO(jkarlin): Remove CacheStorage from memory once they're no |
39 // longer in active use. | 38 // longer in active use. |
40 class CONTENT_EXPORT CacheStorageManager { | 39 class CONTENT_EXPORT CacheStorageManager { |
41 public: | 40 public: |
42 static scoped_ptr<CacheStorageManager> Create( | 41 static scoped_ptr<CacheStorageManager> Create( |
43 const base::FilePath& path, | 42 const base::FilePath& path, |
44 const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner, | 43 const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 // This must be called before creating any of the public *Cache functions | 76 // This must be called before creating any of the public *Cache functions |
78 // above. | 77 // above. |
79 void SetBlobParametersForCache( | 78 void SetBlobParametersForCache( |
80 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, | 79 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, |
81 base::WeakPtr<storage::BlobStorageContext> blob_storage_context); | 80 base::WeakPtr<storage::BlobStorageContext> blob_storage_context); |
82 | 81 |
83 base::WeakPtr<CacheStorageManager> AsWeakPtr() { | 82 base::WeakPtr<CacheStorageManager> AsWeakPtr() { |
84 return weak_ptr_factory_.GetWeakPtr(); | 83 return weak_ptr_factory_.GetWeakPtr(); |
85 } | 84 } |
86 | 85 |
| 86 base::FilePath root_path() const { return root_path_; } |
| 87 |
87 private: | 88 private: |
88 friend class CacheStorageContextImpl; | 89 friend class CacheStorageContextImpl; |
89 friend class CacheStorageManagerTest; | 90 friend class CacheStorageManagerTest; |
90 friend class CacheStorageMigrationTest; | 91 friend class CacheStorageMigrationTest; |
91 friend class CacheStorageQuotaClient; | 92 friend class CacheStorageQuotaClient; |
92 friend class MigratedLegacyCacheDirectoryNameTest; | |
93 | 93 |
94 typedef std::map<GURL, CacheStorage*> CacheStorageMap; | 94 typedef std::map<GURL, CacheStorage*> CacheStorageMap; |
95 | 95 |
96 CacheStorageManager( | 96 CacheStorageManager( |
97 const base::FilePath& path, | 97 const base::FilePath& path, |
98 const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner, | 98 const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner, |
99 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy); | 99 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy); |
100 | 100 |
101 // The returned CacheStorage* is owned by this manager. | 101 // The returned CacheStorage* is owned by this manager. |
102 CacheStorage* FindOrCreateCacheStorage(const GURL& origin); | 102 CacheStorage* FindOrCreateCacheStorage(const GURL& origin); |
(...skipping 13 matching lines...) Expand all Loading... |
116 static void DeleteOriginDidClose( | 116 static void DeleteOriginDidClose( |
117 const GURL& origin, | 117 const GURL& origin, |
118 const storage::QuotaClient::DeletionCallback& callback, | 118 const storage::QuotaClient::DeletionCallback& callback, |
119 scoped_ptr<CacheStorage> cache_storage, | 119 scoped_ptr<CacheStorage> cache_storage, |
120 base::WeakPtr<CacheStorageManager> cache_manager); | 120 base::WeakPtr<CacheStorageManager> cache_manager); |
121 | 121 |
122 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter() | 122 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter() |
123 const { | 123 const { |
124 return request_context_getter_; | 124 return request_context_getter_; |
125 } | 125 } |
| 126 |
126 base::WeakPtr<storage::BlobStorageContext> blob_storage_context() const { | 127 base::WeakPtr<storage::BlobStorageContext> blob_storage_context() const { |
127 return blob_context_; | 128 return blob_context_; |
128 } | 129 } |
129 base::FilePath root_path() const { return root_path_; } | 130 |
130 const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner() const { | 131 const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner() const { |
131 return cache_task_runner_; | 132 return cache_task_runner_; |
132 } | 133 } |
133 | 134 |
134 bool IsMemoryBacked() const { return root_path_.empty(); } | 135 bool IsMemoryBacked() const { return root_path_.empty(); } |
135 | 136 |
136 // Map a origin to the path. Exposed for testing. | 137 // Map a origin to the path. Exposed for testing. |
137 static base::FilePath ConstructLegacyOriginPath( | 138 static base::FilePath ConstructLegacyOriginPath( |
138 const base::FilePath& root_path, | 139 const base::FilePath& root_path, |
139 const GURL& origin); | 140 const GURL& origin); |
(...skipping 16 matching lines...) Expand all Loading... |
156 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | 157 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
157 base::WeakPtr<storage::BlobStorageContext> blob_context_; | 158 base::WeakPtr<storage::BlobStorageContext> blob_context_; |
158 | 159 |
159 base::WeakPtrFactory<CacheStorageManager> weak_ptr_factory_; | 160 base::WeakPtrFactory<CacheStorageManager> weak_ptr_factory_; |
160 DISALLOW_COPY_AND_ASSIGN(CacheStorageManager); | 161 DISALLOW_COPY_AND_ASSIGN(CacheStorageManager); |
161 }; | 162 }; |
162 | 163 |
163 } // namespace content | 164 } // namespace content |
164 | 165 |
165 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_MANAGER_H_ | 166 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_MANAGER_H_ |
OLD | NEW |