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_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/id_map.h" | 13 #include "base/id_map.h" |
14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 class SequencedTaskRunner; | 17 class SequencedTaskRunner; |
18 } | 18 } |
19 | 19 |
20 namespace net { | |
21 class URLRequestContext; | |
22 } | |
23 | |
20 namespace content { | 24 namespace content { |
25 class ChromeBlobStorageContext; | |
21 class ServiceWorkerCache; | 26 class ServiceWorkerCache; |
22 | 27 |
23 // TODO(jkarlin): Constrain the total bytes used per origin. | 28 // TODO(jkarlin): Constrain the total bytes used per origin. |
24 // The set of caches for a given origin. It is owned by the | 29 // The set of caches for a given origin. It is owned by the |
25 // ServiceWorkerCacheStorageManager. Provided callbacks are called on the | 30 // ServiceWorkerCacheStorageManager. Provided callbacks are called on the |
26 // |callback_loop| provided in the constructor. | 31 // |callback_loop| provided in the constructor. |
27 class ServiceWorkerCacheStorage { | 32 class ServiceWorkerCacheStorage { |
28 public: | 33 public: |
29 enum CacheStorageError { | 34 enum CacheStorageError { |
30 CACHE_STORAGE_ERROR_NO_ERROR, | 35 CACHE_STORAGE_ERROR_NO_ERROR, |
31 CACHE_STORAGE_ERROR_NOT_IMPLEMENTED, | 36 CACHE_STORAGE_ERROR_NOT_IMPLEMENTED, |
32 CACHE_STORAGE_ERROR_NOT_FOUND, | 37 CACHE_STORAGE_ERROR_NOT_FOUND, |
33 CACHE_STORAGE_ERROR_EXISTS, | 38 CACHE_STORAGE_ERROR_EXISTS, |
34 CACHE_STORAGE_ERROR_STORAGE, | 39 CACHE_STORAGE_ERROR_STORAGE, |
35 CACHE_STORAGE_ERROR_EMPTY_KEY, | 40 CACHE_STORAGE_ERROR_EMPTY_KEY, |
36 }; | 41 }; |
37 | 42 |
38 typedef base::Callback<void(bool, CacheStorageError)> BoolAndErrorCallback; | 43 typedef base::Callback<void(bool, CacheStorageError)> BoolAndErrorCallback; |
39 typedef base::Callback<void(int, CacheStorageError)> CacheAndErrorCallback; | 44 typedef base::Callback<void(int, CacheStorageError)> CacheAndErrorCallback; |
40 typedef base::Callback<void(const std::vector<std::string>&, | 45 typedef base::Callback<void(const std::vector<std::string>&, |
41 CacheStorageError)> StringsAndErrorCallback; | 46 CacheStorageError)> StringsAndErrorCallback; |
42 | 47 |
43 ServiceWorkerCacheStorage(const base::FilePath& origin_path, | 48 ServiceWorkerCacheStorage(const base::FilePath& origin_path, |
44 bool memory_only, | 49 bool memory_only, |
45 base::SequencedTaskRunner* cache_task_runner); | 50 base::SequencedTaskRunner* cache_task_runner, |
51 net::URLRequestContext* request_context, | |
52 ChromeBlobStorageContext* blob_context); | |
michaeln
2014/08/12 03:48:52
ditto base::WeakPtr<webkit_blob::BlobStorageContex
| |
46 | 53 |
47 virtual ~ServiceWorkerCacheStorage(); | 54 virtual ~ServiceWorkerCacheStorage(); |
48 | 55 |
49 // Create a ServiceWorkerCache if it doesn't already exist and call the | 56 // Create a ServiceWorkerCache if it doesn't already exist and call the |
50 // callback with the cache's id. If it already | 57 // callback with the cache's id. If it already |
51 // exists the callback is called with CACHE_STORAGE_ERROR_EXISTS. | 58 // exists the callback is called with CACHE_STORAGE_ERROR_EXISTS. |
52 void CreateCache(const std::string& cache_name, | 59 void CreateCache(const std::string& cache_name, |
53 const CacheAndErrorCallback& callback); | 60 const CacheAndErrorCallback& callback); |
54 | 61 |
55 // Get the cache id for the given key. If not found returns | 62 // Get the cache id for the given key. If not found returns |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 scoped_ptr<CacheLoader> cache_loader_; | 145 scoped_ptr<CacheLoader> cache_loader_; |
139 | 146 |
140 base::ThreadChecker thread_checker_; | 147 base::ThreadChecker thread_checker_; |
141 | 148 |
142 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCacheStorage); | 149 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCacheStorage); |
143 }; | 150 }; |
144 | 151 |
145 } // namespace content | 152 } // namespace content |
146 | 153 |
147 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_H_ | 154 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_H_ |
OLD | NEW |