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_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 namespace storage { | 23 namespace storage { |
24 class BlobDataBuilder; | 24 class BlobDataBuilder; |
25 class BlobDataHandle; | 25 class BlobDataHandle; |
26 class BlobStorageContext; | 26 class BlobStorageContext; |
27 class QuotaManagerProxy; | 27 class QuotaManagerProxy; |
28 } | 28 } |
29 | 29 |
30 namespace content { | 30 namespace content { |
31 class ChromeBlobStorageContext; | 31 class ChromeBlobStorageContext; |
32 class ServiceWorkerCacheMetadata; | 32 class ServiceWorkerCacheMetadata; |
| 33 class ServiceWorkerCacheScheduler; |
33 class TestServiceWorkerCache; | 34 class TestServiceWorkerCache; |
34 | 35 |
35 // Represents a ServiceWorker Cache as seen in | 36 // Represents a ServiceWorker Cache as seen in |
36 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html. | 37 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html. |
37 // The asynchronous methods are executed serially. Callbacks to the | 38 // The asynchronous methods are executed serially. Callbacks to the |
38 // public functions will be called so long as the cache object lives. | 39 // public functions will be called so long as the cache object lives. |
39 class CONTENT_EXPORT ServiceWorkerCache | 40 class CONTENT_EXPORT ServiceWorkerCache |
40 : public base::RefCounted<ServiceWorkerCache> { | 41 : public base::RefCounted<ServiceWorkerCache> { |
41 public: | 42 public: |
42 enum ErrorType { | 43 enum ErrorType { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 // Loads the backend and calls the callback with the result (true for | 176 // Loads the backend and calls the callback with the result (true for |
176 // success). The callback will always be called. Virtual for tests. | 177 // success). The callback will always be called. Virtual for tests. |
177 virtual void CreateBackend(const ErrorCallback& callback); | 178 virtual void CreateBackend(const ErrorCallback& callback); |
178 void CreateBackendDidCreate(const ServiceWorkerCache::ErrorCallback& callback, | 179 void CreateBackendDidCreate(const ServiceWorkerCache::ErrorCallback& callback, |
179 scoped_ptr<ScopedBackendPtr> backend_ptr, | 180 scoped_ptr<ScopedBackendPtr> backend_ptr, |
180 int rv); | 181 int rv); |
181 | 182 |
182 void InitBackend(); | 183 void InitBackend(); |
183 void InitDone(ErrorType error); | 184 void InitDone(ErrorType error); |
184 | 185 |
185 void CompleteOperationAndRunNext(); | |
186 void RunOperationIfIdle(); | |
187 void PendingClosure(const base::Closure& callback); | 186 void PendingClosure(const base::Closure& callback); |
188 void PendingErrorCallback(const ErrorCallback& callback, ErrorType error); | 187 void PendingErrorCallback(const ErrorCallback& callback, ErrorType error); |
189 void PendingResponseCallback( | 188 void PendingResponseCallback( |
190 const ResponseCallback& callback, | 189 const ResponseCallback& callback, |
191 ErrorType error, | 190 ErrorType error, |
192 scoped_ptr<ServiceWorkerResponse> response, | 191 scoped_ptr<ServiceWorkerResponse> response, |
193 scoped_ptr<storage::BlobDataHandle> blob_data_handle); | 192 scoped_ptr<storage::BlobDataHandle> blob_data_handle); |
194 void PendingRequestsCallback(const RequestsCallback& callback, | 193 void PendingRequestsCallback(const RequestsCallback& callback, |
195 ErrorType error, | 194 ErrorType error, |
196 scoped_ptr<Requests> requests); | 195 scoped_ptr<Requests> requests); |
197 | 196 |
198 // Be sure to check |backend_state_| before use. | 197 // Be sure to check |backend_state_| before use. |
199 scoped_ptr<disk_cache::Backend> backend_; | 198 scoped_ptr<disk_cache::Backend> backend_; |
200 | 199 |
201 GURL origin_; | 200 GURL origin_; |
202 base::FilePath path_; | 201 base::FilePath path_; |
203 net::URLRequestContext* request_context_; | 202 net::URLRequestContext* request_context_; |
204 scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy_; | 203 scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy_; |
205 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_; | 204 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_; |
206 BackendState backend_state_; | 205 BackendState backend_state_; |
207 std::list<base::Closure> pending_operations_; | 206 scoped_ptr<ServiceWorkerCacheScheduler> scheduler_; |
208 bool operation_running_; | |
209 bool initializing_; | 207 bool initializing_; |
210 | 208 |
211 // Whether or not to store data in disk or memory. | 209 // Whether or not to store data in disk or memory. |
212 bool memory_only_; | 210 bool memory_only_; |
213 | 211 |
214 base::WeakPtrFactory<ServiceWorkerCache> weak_ptr_factory_; | 212 base::WeakPtrFactory<ServiceWorkerCache> weak_ptr_factory_; |
215 | 213 |
216 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCache); | 214 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCache); |
217 }; | 215 }; |
218 | 216 |
219 } // namespace content | 217 } // namespace content |
220 | 218 |
221 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_H_ | 219 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_H_ |
OLD | NEW |