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_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_MANAGER_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_MANAGER_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_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 "content/browser/service_worker/service_worker_cache_storage.h" | 13 #include "content/browser/service_worker/service_worker_cache_storage.h" |
14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 class SequencedTaskRunner; | 18 class SequencedTaskRunner; |
19 } | 19 } |
20 | 20 |
21 namespace net { | 21 namespace net { |
22 class URLRequestContext; | 22 class URLRequestContext; |
23 } | 23 } |
24 | 24 |
25 namespace webkit_blob { | 25 namespace storage { |
26 class BlobStorageContext; | 26 class BlobStorageContext; |
27 } | 27 } |
28 | 28 |
29 namespace content { | 29 namespace content { |
30 | 30 |
31 // Keeps track of a ServiceWorkerCacheStorage per origin. There is one | 31 // Keeps track of a ServiceWorkerCacheStorage per origin. There is one |
32 // ServiceWorkerCacheStorageManager per ServiceWorkerContextCore. | 32 // ServiceWorkerCacheStorageManager per ServiceWorkerContextCore. |
33 // TODO(jkarlin): Remove ServiceWorkerCacheStorage from memory once they're no | 33 // TODO(jkarlin): Remove ServiceWorkerCacheStorage from memory once they're no |
34 // longer in active use. | 34 // longer in active use. |
35 class CONTENT_EXPORT ServiceWorkerCacheStorageManager { | 35 class CONTENT_EXPORT ServiceWorkerCacheStorageManager { |
(...skipping 27 matching lines...) Expand all Loading... |
63 const ServiceWorkerCacheStorage::BoolAndErrorCallback& callback); | 63 const ServiceWorkerCacheStorage::BoolAndErrorCallback& callback); |
64 void EnumerateCaches( | 64 void EnumerateCaches( |
65 const GURL& origin, | 65 const GURL& origin, |
66 const ServiceWorkerCacheStorage::StringsAndErrorCallback& callback); | 66 const ServiceWorkerCacheStorage::StringsAndErrorCallback& callback); |
67 // TODO(jkarlin): Add match() function. | 67 // TODO(jkarlin): Add match() function. |
68 | 68 |
69 // This must be called before creating any of the public *Cache functions | 69 // This must be called before creating any of the public *Cache functions |
70 // above. | 70 // above. |
71 void SetBlobParametersForCache( | 71 void SetBlobParametersForCache( |
72 net::URLRequestContext* request_context, | 72 net::URLRequestContext* request_context, |
73 base::WeakPtr<webkit_blob::BlobStorageContext> blob_storage_context); | 73 base::WeakPtr<storage::BlobStorageContext> blob_storage_context); |
74 | 74 |
75 private: | 75 private: |
76 typedef std::map<GURL, ServiceWorkerCacheStorage*> | 76 typedef std::map<GURL, ServiceWorkerCacheStorage*> |
77 ServiceWorkerCacheStorageMap; | 77 ServiceWorkerCacheStorageMap; |
78 | 78 |
79 ServiceWorkerCacheStorageManager( | 79 ServiceWorkerCacheStorageManager( |
80 const base::FilePath& path, | 80 const base::FilePath& path, |
81 base::SequencedTaskRunner* cache_task_runner); | 81 base::SequencedTaskRunner* cache_task_runner); |
82 | 82 |
83 // The returned ServiceWorkerCacheStorage* is owned by | 83 // The returned ServiceWorkerCacheStorage* is owned by |
84 // service_worker_cache_storages_. | 84 // service_worker_cache_storages_. |
85 ServiceWorkerCacheStorage* FindOrCreateServiceWorkerCacheManager( | 85 ServiceWorkerCacheStorage* FindOrCreateServiceWorkerCacheManager( |
86 const GURL& origin); | 86 const GURL& origin); |
87 | 87 |
88 net::URLRequestContext* url_request_context() const { | 88 net::URLRequestContext* url_request_context() const { |
89 return request_context_; | 89 return request_context_; |
90 } | 90 } |
91 base::WeakPtr<webkit_blob::BlobStorageContext> blob_storage_context() const { | 91 base::WeakPtr<storage::BlobStorageContext> blob_storage_context() const { |
92 return blob_context_; | 92 return blob_context_; |
93 } | 93 } |
94 base::FilePath root_path() const { return root_path_; } | 94 base::FilePath root_path() const { return root_path_; } |
95 scoped_refptr<base::SequencedTaskRunner> cache_task_runner() const { | 95 scoped_refptr<base::SequencedTaskRunner> cache_task_runner() const { |
96 return cache_task_runner_; | 96 return cache_task_runner_; |
97 } | 97 } |
98 | 98 |
99 base::FilePath root_path_; | 99 base::FilePath root_path_; |
100 scoped_refptr<base::SequencedTaskRunner> cache_task_runner_; | 100 scoped_refptr<base::SequencedTaskRunner> cache_task_runner_; |
101 | 101 |
102 // The map owns the CacheStorages and the CacheStorages are only accessed on | 102 // The map owns the CacheStorages and the CacheStorages are only accessed on |
103 // |cache_task_runner_|. | 103 // |cache_task_runner_|. |
104 ServiceWorkerCacheStorageMap cache_storage_map_; | 104 ServiceWorkerCacheStorageMap cache_storage_map_; |
105 | 105 |
106 net::URLRequestContext* request_context_; | 106 net::URLRequestContext* request_context_; |
107 base::WeakPtr<webkit_blob::BlobStorageContext> blob_context_; | 107 base::WeakPtr<storage::BlobStorageContext> blob_context_; |
108 | 108 |
109 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCacheStorageManager); | 109 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCacheStorageManager); |
110 }; | 110 }; |
111 | 111 |
112 } // namespace content | 112 } // namespace content |
113 | 113 |
114 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_MANAGER_H
_ | 114 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_MANAGER_H
_ |
OLD | NEW |