| 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/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 class SequencedTaskRunner; | 17 class SequencedTaskRunner; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace net { | 20 namespace net { |
| 21 class URLRequestContext; | 21 class URLRequestContext; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace webkit_blob { | 24 namespace storage { |
| 25 class BlobStorageContext; | 25 class BlobStorageContext; |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace content { | 28 namespace content { |
| 29 class ServiceWorkerCache; | 29 class ServiceWorkerCache; |
| 30 | 30 |
| 31 // TODO(jkarlin): Constrain the total bytes used per origin. | 31 // TODO(jkarlin): Constrain the total bytes used per origin. |
| 32 | 32 |
| 33 // ServiceWorkerCacheStorage holds the set of caches for a given origin. It is | 33 // ServiceWorkerCacheStorage holds the set of caches for a given origin. It is |
| 34 // owned by the ServiceWorkerCacheStorageManager. This class expects to be run | 34 // owned by the ServiceWorkerCacheStorageManager. This class expects to be run |
| (...skipping 12 matching lines...) Expand all Loading... |
| 47 typedef base::Callback<void(bool, CacheStorageError)> BoolAndErrorCallback; | 47 typedef base::Callback<void(bool, CacheStorageError)> BoolAndErrorCallback; |
| 48 typedef base::Callback<void(int, CacheStorageError)> CacheAndErrorCallback; | 48 typedef base::Callback<void(int, CacheStorageError)> CacheAndErrorCallback; |
| 49 typedef base::Callback<void(const std::vector<std::string>&, | 49 typedef base::Callback<void(const std::vector<std::string>&, |
| 50 CacheStorageError)> StringsAndErrorCallback; | 50 CacheStorageError)> StringsAndErrorCallback; |
| 51 | 51 |
| 52 ServiceWorkerCacheStorage( | 52 ServiceWorkerCacheStorage( |
| 53 const base::FilePath& origin_path, | 53 const base::FilePath& origin_path, |
| 54 bool memory_only, | 54 bool memory_only, |
| 55 base::SequencedTaskRunner* cache_task_runner, | 55 base::SequencedTaskRunner* cache_task_runner, |
| 56 net::URLRequestContext* request_context, | 56 net::URLRequestContext* request_context, |
| 57 base::WeakPtr<webkit_blob::BlobStorageContext> blob_context); | 57 base::WeakPtr<storage::BlobStorageContext> blob_context); |
| 58 | 58 |
| 59 virtual ~ServiceWorkerCacheStorage(); | 59 virtual ~ServiceWorkerCacheStorage(); |
| 60 | 60 |
| 61 // Create a ServiceWorkerCache if it doesn't already exist and call the | 61 // Create a ServiceWorkerCache if it doesn't already exist and call the |
| 62 // callback with the cache's id. If it already | 62 // callback with the cache's id. If it already |
| 63 // exists the callback is called with CACHE_STORAGE_ERROR_EXISTS. | 63 // exists the callback is called with CACHE_STORAGE_ERROR_EXISTS. |
| 64 void CreateCache(const std::string& cache_name, | 64 void CreateCache(const std::string& cache_name, |
| 65 const CacheAndErrorCallback& callback); | 65 const CacheAndErrorCallback& callback); |
| 66 | 66 |
| 67 // Get the cache id for the given key. If not found returns | 67 // 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... |
| 150 scoped_refptr<CacheLoader> cache_loader_; | 150 scoped_refptr<CacheLoader> cache_loader_; |
| 151 | 151 |
| 152 base::WeakPtrFactory<ServiceWorkerCacheStorage> weak_factory_; | 152 base::WeakPtrFactory<ServiceWorkerCacheStorage> weak_factory_; |
| 153 | 153 |
| 154 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCacheStorage); | 154 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCacheStorage); |
| 155 }; | 155 }; |
| 156 | 156 |
| 157 } // namespace content | 157 } // namespace content |
| 158 | 158 |
| 159 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_H_ | 159 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_H_ |
| OLD | NEW |