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 |
(...skipping 18 matching lines...) Expand all Loading... |
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 { |
36 public: | 36 public: |
37 static scoped_ptr<ServiceWorkerCacheStorageManager> Create( | 37 static scoped_ptr<ServiceWorkerCacheStorageManager> Create( |
38 const base::FilePath& path, | 38 const base::FilePath& path, |
39 base::SequencedTaskRunner* cache_task_runner); | 39 const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner); |
40 | 40 |
41 static scoped_ptr<ServiceWorkerCacheStorageManager> Create( | 41 static scoped_ptr<ServiceWorkerCacheStorageManager> Create( |
42 ServiceWorkerCacheStorageManager* old_manager); | 42 ServiceWorkerCacheStorageManager* old_manager); |
43 | 43 |
44 virtual ~ServiceWorkerCacheStorageManager(); | 44 virtual ~ServiceWorkerCacheStorageManager(); |
45 | 45 |
46 // Methods to support the CacheStorage spec. These methods call the | 46 // Methods to support the CacheStorage spec. These methods call the |
47 // corresponding ServiceWorkerCacheStorage method on the appropriate thread. | 47 // corresponding ServiceWorkerCacheStorage method on the appropriate thread. |
48 void CreateCache( | 48 void CreateCache( |
49 const GURL& origin, | 49 const GURL& origin, |
(...skipping 21 matching lines...) Expand all Loading... |
71 void SetBlobParametersForCache( | 71 void SetBlobParametersForCache( |
72 net::URLRequestContext* request_context, | 72 net::URLRequestContext* request_context, |
73 base::WeakPtr<storage::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 const scoped_refptr<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<storage::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 const 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<storage::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 |