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_CACHE_STORAGE_CACHE_STORAGE_CACHE_H_ | 5 #ifndef CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CACHE_H_ |
6 #define CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CACHE_H_ | 6 #define CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CACHE_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "content/common/cache_storage/cache_storage_types.h" | 14 #include "content/common/cache_storage/cache_storage_types.h" |
15 #include "content/common/service_worker/service_worker_types.h" | 15 #include "content/common/service_worker/service_worker_types.h" |
16 #include "net/disk_cache/disk_cache.h" | 16 #include "net/disk_cache/disk_cache.h" |
17 | 17 |
18 namespace net { | 18 namespace net { |
19 class URLRequestContext; | 19 class URLRequestContextGetter; |
20 class IOBufferWithSize; | 20 class IOBufferWithSize; |
21 } | 21 } |
22 | 22 |
23 namespace storage { | 23 namespace storage { |
24 class BlobDataHandle; | 24 class BlobDataHandle; |
25 class BlobStorageContext; | 25 class BlobStorageContext; |
26 class QuotaManagerProxy; | 26 class QuotaManagerProxy; |
27 } | 27 } |
28 | 28 |
29 namespace content { | 29 namespace content { |
(...skipping 13 matching lines...) Expand all Loading... |
43 using ResponseCallback = | 43 using ResponseCallback = |
44 base::Callback<void(CacheStorageError, | 44 base::Callback<void(CacheStorageError, |
45 scoped_ptr<ServiceWorkerResponse>, | 45 scoped_ptr<ServiceWorkerResponse>, |
46 scoped_ptr<storage::BlobDataHandle>)>; | 46 scoped_ptr<storage::BlobDataHandle>)>; |
47 using Requests = std::vector<ServiceWorkerFetchRequest>; | 47 using Requests = std::vector<ServiceWorkerFetchRequest>; |
48 using RequestsCallback = | 48 using RequestsCallback = |
49 base::Callback<void(CacheStorageError, scoped_ptr<Requests>)>; | 49 base::Callback<void(CacheStorageError, scoped_ptr<Requests>)>; |
50 | 50 |
51 static scoped_refptr<CacheStorageCache> CreateMemoryCache( | 51 static scoped_refptr<CacheStorageCache> CreateMemoryCache( |
52 const GURL& origin, | 52 const GURL& origin, |
53 net::URLRequestContext* request_context, | 53 const scoped_refptr<net::URLRequestContextGetter>& request_context, |
54 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, | 54 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, |
55 base::WeakPtr<storage::BlobStorageContext> blob_context); | 55 base::WeakPtr<storage::BlobStorageContext> blob_context); |
56 static scoped_refptr<CacheStorageCache> CreatePersistentCache( | 56 static scoped_refptr<CacheStorageCache> CreatePersistentCache( |
57 const GURL& origin, | 57 const GURL& origin, |
58 const base::FilePath& path, | 58 const base::FilePath& path, |
59 net::URLRequestContext* request_context, | 59 const scoped_refptr<net::URLRequestContextGetter>& request_context, |
60 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, | 60 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, |
61 base::WeakPtr<storage::BlobStorageContext> blob_context); | 61 base::WeakPtr<storage::BlobStorageContext> blob_context); |
62 | 62 |
63 // Returns ERROR_TYPE_NOT_FOUND if not found. | 63 // Returns ERROR_TYPE_NOT_FOUND if not found. |
64 void Match(scoped_ptr<ServiceWorkerFetchRequest> request, | 64 void Match(scoped_ptr<ServiceWorkerFetchRequest> request, |
65 const ResponseCallback& callback); | 65 const ResponseCallback& callback); |
66 | 66 |
67 // Runs given batch operations. This corresponds to the Batch Cache Operations | 67 // Runs given batch operations. This corresponds to the Batch Cache Operations |
68 // algorithm in the spec. | 68 // algorithm in the spec. |
69 // | 69 // |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 BACKEND_OPEN, // Backend can be used. | 114 BACKEND_OPEN, // Backend can be used. |
115 BACKEND_CLOSED // Backend cannot be used. All ops should fail. | 115 BACKEND_CLOSED // Backend cannot be used. All ops should fail. |
116 }; | 116 }; |
117 | 117 |
118 using Entries = std::vector<disk_cache::Entry*>; | 118 using Entries = std::vector<disk_cache::Entry*>; |
119 using ScopedBackendPtr = scoped_ptr<disk_cache::Backend>; | 119 using ScopedBackendPtr = scoped_ptr<disk_cache::Backend>; |
120 | 120 |
121 CacheStorageCache( | 121 CacheStorageCache( |
122 const GURL& origin, | 122 const GURL& origin, |
123 const base::FilePath& path, | 123 const base::FilePath& path, |
124 net::URLRequestContext* request_context, | 124 const scoped_refptr<net::URLRequestContextGetter>& request_context, |
125 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, | 125 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, |
126 base::WeakPtr<storage::BlobStorageContext> blob_context); | 126 base::WeakPtr<storage::BlobStorageContext> blob_context); |
127 | 127 |
128 // Async operations in progress will cancel and not run their callbacks. | 128 // Async operations in progress will cancel and not run their callbacks. |
129 virtual ~CacheStorageCache(); | 129 virtual ~CacheStorageCache(); |
130 | 130 |
131 // Match callbacks | 131 // Match callbacks |
132 void MatchImpl(scoped_ptr<ServiceWorkerFetchRequest> request, | 132 void MatchImpl(scoped_ptr<ServiceWorkerFetchRequest> request, |
133 const ResponseCallback& callback); | 133 const ResponseCallback& callback); |
134 void MatchDidOpenEntry(scoped_ptr<MatchContext> match_context, int rv); | 134 void MatchDidOpenEntry(scoped_ptr<MatchContext> match_context, int rv); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 scoped_ptr<storage::BlobDataHandle> blob_data_handle); | 199 scoped_ptr<storage::BlobDataHandle> blob_data_handle); |
200 void PendingRequestsCallback(const RequestsCallback& callback, | 200 void PendingRequestsCallback(const RequestsCallback& callback, |
201 CacheStorageError error, | 201 CacheStorageError error, |
202 scoped_ptr<Requests> requests); | 202 scoped_ptr<Requests> requests); |
203 | 203 |
204 // Be sure to check |backend_state_| before use. | 204 // Be sure to check |backend_state_| before use. |
205 scoped_ptr<disk_cache::Backend> backend_; | 205 scoped_ptr<disk_cache::Backend> backend_; |
206 | 206 |
207 GURL origin_; | 207 GURL origin_; |
208 base::FilePath path_; | 208 base::FilePath path_; |
209 net::URLRequestContext* request_context_; | 209 scoped_refptr<net::URLRequestContextGetter> request_context_; |
210 scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy_; | 210 scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy_; |
211 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_; | 211 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_; |
212 BackendState backend_state_; | 212 BackendState backend_state_; |
213 scoped_ptr<CacheStorageScheduler> scheduler_; | 213 scoped_ptr<CacheStorageScheduler> scheduler_; |
214 bool initializing_; | 214 bool initializing_; |
215 | 215 |
216 // Whether or not to store data in disk or memory. | 216 // Whether or not to store data in disk or memory. |
217 bool memory_only_; | 217 bool memory_only_; |
218 | 218 |
219 base::WeakPtrFactory<CacheStorageCache> weak_ptr_factory_; | 219 base::WeakPtrFactory<CacheStorageCache> weak_ptr_factory_; |
220 | 220 |
221 DISALLOW_COPY_AND_ASSIGN(CacheStorageCache); | 221 DISALLOW_COPY_AND_ASSIGN(CacheStorageCache); |
222 }; | 222 }; |
223 | 223 |
224 } // namespace content | 224 } // namespace content |
225 | 225 |
226 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CACHE_H_ | 226 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CACHE_H_ |
OLD | NEW |