Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: content/browser/cache_storage/cache_storage_cache.h

Issue 2947753002: CacheStorage: Migrate to BindOnce/OnceCallback/OnceClosure (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 namespace proto { 43 namespace proto {
44 class CacheMetadata; 44 class CacheMetadata;
45 } 45 }
46 46
47 // Represents a ServiceWorker Cache as seen in 47 // Represents a ServiceWorker Cache as seen in
48 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/ The 48 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/ The
49 // asynchronous methods are executed serially. Callbacks to the public functions 49 // asynchronous methods are executed serially. Callbacks to the public functions
50 // will be called so long as the cache object lives. 50 // will be called so long as the cache object lives.
51 class CONTENT_EXPORT CacheStorageCache { 51 class CONTENT_EXPORT CacheStorageCache {
52 public: 52 public:
53 using ErrorCallback = base::Callback<void(CacheStorageError)>; 53 using ErrorCallback = base::OnceCallback<void(CacheStorageError)>;
54 using ResponseCallback = 54 using ResponseCallback =
55 base::Callback<void(CacheStorageError, 55 base::OnceCallback<void(CacheStorageError,
56 std::unique_ptr<ServiceWorkerResponse>, 56 std::unique_ptr<ServiceWorkerResponse>,
57 std::unique_ptr<storage::BlobDataHandle>)>; 57 std::unique_ptr<storage::BlobDataHandle>)>;
58 using Responses = std::vector<ServiceWorkerResponse>; 58 using Responses = std::vector<ServiceWorkerResponse>;
59 using BlobDataHandles = std::vector<std::unique_ptr<storage::BlobDataHandle>>; 59 using BlobDataHandles = std::vector<std::unique_ptr<storage::BlobDataHandle>>;
60 using ResponsesCallback = 60 using ResponsesCallback =
61 base::Callback<void(CacheStorageError, 61 base::OnceCallback<void(CacheStorageError,
62 std::unique_ptr<Responses>, 62 std::unique_ptr<Responses>,
63 std::unique_ptr<BlobDataHandles>)>; 63 std::unique_ptr<BlobDataHandles>)>;
64 using Requests = std::vector<ServiceWorkerFetchRequest>; 64 using Requests = std::vector<ServiceWorkerFetchRequest>;
65 using RequestsCallback = 65 using RequestsCallback =
66 base::Callback<void(CacheStorageError, std::unique_ptr<Requests>)>; 66 base::OnceCallback<void(CacheStorageError, std::unique_ptr<Requests>)>;
67 using SizeCallback = base::Callback<void(int64_t)>; 67 using SizeCallback = base::OnceCallback<void(int64_t)>;
68 68
69 enum EntryIndex { INDEX_HEADERS = 0, INDEX_RESPONSE_BODY, INDEX_SIDE_DATA }; 69 enum EntryIndex { INDEX_HEADERS = 0, INDEX_RESPONSE_BODY, INDEX_SIDE_DATA };
70 70
71 static std::unique_ptr<CacheStorageCache> CreateMemoryCache( 71 static std::unique_ptr<CacheStorageCache> CreateMemoryCache(
72 const GURL& origin, 72 const GURL& origin,
73 const std::string& cache_name, 73 const std::string& cache_name,
74 CacheStorage* cache_storage, 74 CacheStorage* cache_storage,
75 scoped_refptr<net::URLRequestContextGetter> request_context_getter, 75 scoped_refptr<net::URLRequestContextGetter> request_context_getter,
76 scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy, 76 scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy,
77 base::WeakPtr<storage::BlobStorageContext> blob_context); 77 base::WeakPtr<storage::BlobStorageContext> blob_context);
78 static std::unique_ptr<CacheStorageCache> CreatePersistentCache( 78 static std::unique_ptr<CacheStorageCache> CreatePersistentCache(
79 const GURL& origin, 79 const GURL& origin,
80 const std::string& cache_name, 80 const std::string& cache_name,
81 CacheStorage* cache_storage, 81 CacheStorage* cache_storage,
82 const base::FilePath& path, 82 const base::FilePath& path,
83 scoped_refptr<net::URLRequestContextGetter> request_context_getter, 83 scoped_refptr<net::URLRequestContextGetter> request_context_getter,
84 scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy, 84 scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy,
85 base::WeakPtr<storage::BlobStorageContext> blob_context, 85 base::WeakPtr<storage::BlobStorageContext> blob_context,
86 int64_t cache_size); 86 int64_t cache_size);
87 87
88 // Returns ERROR_TYPE_NOT_FOUND if not found. 88 // Returns ERROR_TYPE_NOT_FOUND if not found.
89 void Match(std::unique_ptr<ServiceWorkerFetchRequest> request, 89 void Match(std::unique_ptr<ServiceWorkerFetchRequest> request,
90 const CacheStorageCacheQueryParams& match_params, 90 const CacheStorageCacheQueryParams& match_params,
91 const ResponseCallback& callback); 91 ResponseCallback callback);
92 92
93 // Returns CACHE_STORAGE_OK and matched responses in this cache. If there are 93 // Returns CACHE_STORAGE_OK and matched responses in this cache. If there are
94 // no responses, returns CACHE_STORAGE_OK and an empty vector. 94 // no responses, returns CACHE_STORAGE_OK and an empty vector.
95 void MatchAll(std::unique_ptr<ServiceWorkerFetchRequest> request, 95 void MatchAll(std::unique_ptr<ServiceWorkerFetchRequest> request,
96 const CacheStorageCacheQueryParams& match_params, 96 const CacheStorageCacheQueryParams& match_params,
97 const ResponsesCallback& callback); 97 ResponsesCallback callback);
98 98
99 // Writes the side data (ex: V8 code cache) for the specified cache entry. 99 // Writes the side data (ex: V8 code cache) for the specified cache entry.
100 // If it doesn't exist, or the |expected_response_time| differs from the 100 // If it doesn't exist, or the |expected_response_time| differs from the
101 // entry's, CACHE_STORAGE_ERROR_NOT_FOUND is returned. 101 // entry's, CACHE_STORAGE_ERROR_NOT_FOUND is returned.
102 // Note: This "side data" is same meaning as "metadata" in HTTPCache. We use 102 // Note: This "side data" is same meaning as "metadata" in HTTPCache. We use
103 // "metadata" in cache_storage.proto for the pair of headers of a request and 103 // "metadata" in cache_storage.proto for the pair of headers of a request and
104 // a response. To avoid the confusion we use "side data" here. 104 // a response. To avoid the confusion we use "side data" here.
105 void WriteSideData(const CacheStorageCache::ErrorCallback& callback, 105 void WriteSideData(CacheStorageCache::ErrorCallback callback,
106 const GURL& url, 106 const GURL& url,
107 base::Time expected_response_time, 107 base::Time expected_response_time,
108 scoped_refptr<net::IOBuffer> buffer, 108 scoped_refptr<net::IOBuffer> buffer,
109 int buf_len); 109 int buf_len);
110 110
111 // Runs given batch operations. This corresponds to the Batch Cache Operations 111 // Runs given batch operations. This corresponds to the Batch Cache Operations
112 // algorithm in the spec. 112 // algorithm in the spec.
113 // 113 //
114 // |operations| cannot mix PUT and DELETE operations and cannot contain 114 // |operations| cannot mix PUT and DELETE operations and cannot contain
115 // multiple DELETE operations. 115 // multiple DELETE operations.
116 // 116 //
117 // In the case of the PUT operation, puts request and response objects in the 117 // In the case of the PUT operation, puts request and response objects in the
118 // cache and returns OK when all operations are successfully completed. 118 // cache and returns OK when all operations are successfully completed.
119 // In the case of the DELETE operation, returns ERROR_NOT_FOUND if a specified 119 // In the case of the DELETE operation, returns ERROR_NOT_FOUND if a specified
120 // entry is not found. Otherwise deletes it and returns OK. 120 // entry is not found. Otherwise deletes it and returns OK.
121 // 121 //
122 // TODO(nhiroki): This function should run all operations atomically. 122 // TODO(nhiroki): This function should run all operations atomically.
123 // http://crbug.com/486637 123 // http://crbug.com/486637
124 void BatchOperation(const std::vector<CacheStorageBatchOperation>& operations, 124 void BatchOperation(const std::vector<CacheStorageBatchOperation>& operations,
125 const ErrorCallback& callback); 125 ErrorCallback callback);
126 void BatchDidGetUsageAndQuota( 126 void BatchDidGetUsageAndQuota(
127 const std::vector<CacheStorageBatchOperation>& operations, 127 const std::vector<CacheStorageBatchOperation>& operations,
128 const ErrorCallback& callback, 128 ErrorCallback callback,
129 int64_t space_required, 129 int64_t space_required,
130 storage::QuotaStatusCode status_code, 130 storage::QuotaStatusCode status_code,
131 int64_t usage, 131 int64_t usage,
132 int64_t quota); 132 int64_t quota);
133 void BatchDidOneOperation(const base::Closure& barrier_closure, 133 void BatchDidOneOperation(
134 ErrorCallback* callback, 134 const base::RepeatingClosure& barrier_closure,
135 CacheStorageError error); 135 base::RepeatingCallback<void(CacheStorageError)>* callback,
136 void BatchDidAllOperations(std::unique_ptr<ErrorCallback> callback); 136 CacheStorageError error);
137 void BatchDidAllOperations(
138 std::unique_ptr<base::RepeatingCallback<void(CacheStorageError)>>
139 callback);
137 140
138 // Returns CACHE_STORAGE_OK and a vector of requests if there are no errors. 141 // Returns CACHE_STORAGE_OK and a vector of requests if there are no errors.
139 void Keys(std::unique_ptr<ServiceWorkerFetchRequest> request, 142 void Keys(std::unique_ptr<ServiceWorkerFetchRequest> request,
140 const CacheStorageCacheQueryParams& options, 143 const CacheStorageCacheQueryParams& options,
141 const RequestsCallback& callback); 144 RequestsCallback callback);
142 145
143 // Closes the backend. Future operations that require the backend 146 // Closes the backend. Future operations that require the backend
144 // will exit early. Close should only be called once per CacheStorageCache. 147 // will exit early. Close should only be called once per CacheStorageCache.
145 void Close(const base::Closure& callback); 148 void Close(base::OnceClosure callback);
146 149
147 // The size of the cache's contents. 150 // The size of the cache's contents.
148 void Size(const SizeCallback& callback); 151 void Size(SizeCallback callback);
149 152
150 // Gets the cache's size, closes the backend, and then runs |callback| with 153 // Gets the cache's size, closes the backend, and then runs |callback| with
151 // the cache's size. 154 // the cache's size.
152 void GetSizeThenClose(const SizeCallback& callback); 155 void GetSizeThenClose(SizeCallback callback);
153 156
154 // Async operations in progress will cancel and not run their callbacks. 157 // Async operations in progress will cancel and not run their callbacks.
155 virtual ~CacheStorageCache(); 158 virtual ~CacheStorageCache();
156 159
157 base::FilePath path() const { return path_; } 160 base::FilePath path() const { return path_; }
158 161
159 std::string cache_name() const { return cache_name_; } 162 std::string cache_name() const { return cache_name_; }
160 163
161 int64_t cache_size() const { return cache_size_; } 164 int64_t cache_size() const { return cache_size_; }
162 165
(...skipping 12 matching lines...) Expand all
175 enum BackendState { 178 enum BackendState {
176 BACKEND_UNINITIALIZED, // No backend, create backend on first operation. 179 BACKEND_UNINITIALIZED, // No backend, create backend on first operation.
177 BACKEND_OPEN, // Backend can be used. 180 BACKEND_OPEN, // Backend can be used.
178 BACKEND_CLOSED // Backend cannot be used. All ops should fail. 181 BACKEND_CLOSED // Backend cannot be used. All ops should fail.
179 }; 182 };
180 183
181 friend class base::RefCounted<CacheStorageCache>; 184 friend class base::RefCounted<CacheStorageCache>;
182 friend class TestCacheStorageCache; 185 friend class TestCacheStorageCache;
183 friend class CacheStorageCacheTest; 186 friend class CacheStorageCacheTest;
184 187
185 struct OpenAllEntriesContext;
186 struct PutContext; 188 struct PutContext;
187 struct QueryCacheContext; 189 struct QueryCacheContext;
188 struct QueryCacheResult; 190 struct QueryCacheResult;
189 191
190 using QueryCacheResults = std::vector<QueryCacheResult>; 192 using QueryCacheResults = std::vector<QueryCacheResult>;
191 using QueryCacheCallback = 193 using QueryCacheCallback =
192 base::Callback<void(CacheStorageError, 194 base::OnceCallback<void(CacheStorageError,
193 std::unique_ptr<QueryCacheResults>)>; 195 std::unique_ptr<QueryCacheResults>)>;
194 using Entries = std::vector<disk_cache::Entry*>; 196 using Entries = std::vector<disk_cache::Entry*>;
195 using ScopedBackendPtr = std::unique_ptr<disk_cache::Backend>; 197 using ScopedBackendPtr = std::unique_ptr<disk_cache::Backend>;
196 using BlobToDiskCacheIDMap = 198 using BlobToDiskCacheIDMap =
197 IDMap<std::unique_ptr<CacheStorageBlobToDiskCache>>; 199 IDMap<std::unique_ptr<CacheStorageBlobToDiskCache>>;
198 using OpenAllEntriesCallback =
199 base::Callback<void(std::unique_ptr<OpenAllEntriesContext>,
200 CacheStorageError)>;
201 200
202 CacheStorageCache( 201 CacheStorageCache(
203 const GURL& origin, 202 const GURL& origin,
204 const std::string& cache_name, 203 const std::string& cache_name,
205 const base::FilePath& path, 204 const base::FilePath& path,
206 CacheStorage* cache_storage, 205 CacheStorage* cache_storage,
207 scoped_refptr<net::URLRequestContextGetter> request_context_getter, 206 scoped_refptr<net::URLRequestContextGetter> request_context_getter,
208 scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy, 207 scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy,
209 base::WeakPtr<storage::BlobStorageContext> blob_context, 208 base::WeakPtr<storage::BlobStorageContext> blob_context,
210 int64_t cache_size); 209 int64_t cache_size);
211 210
212 // Returns all entries in this cache.
jsbell 2017/06/19 23:45:00 This appeared to be dead code - there are no imple
213 void OpenAllEntries(const OpenAllEntriesCallback& callback);
214 void DidOpenNextEntry(std::unique_ptr<OpenAllEntriesContext> entries_context,
215 const OpenAllEntriesCallback& callback,
216 int rv);
217
218 // Runs |callback| with matching requests/response data. The data provided 211 // Runs |callback| with matching requests/response data. The data provided
219 // in the QueryCacheResults depends on the |query_type|. If |query_type| is 212 // in the QueryCacheResults depends on the |query_type|. If |query_type| is
220 // CACHE_ENTRIES then only out_entries is valid. If |query_type| is REQUESTS 213 // CACHE_ENTRIES then only out_entries is valid. If |query_type| is REQUESTS
221 // then only out_requests is valid. If |query_type| is 214 // then only out_requests is valid. If |query_type| is
222 // REQUESTS_AND_RESPONSES then only out_requests, out_responses, and 215 // REQUESTS_AND_RESPONSES then only out_requests, out_responses, and
223 // out_blob_data_handles are valid. 216 // out_blob_data_handles are valid.
224 void QueryCache(std::unique_ptr<ServiceWorkerFetchRequest> request, 217 void QueryCache(std::unique_ptr<ServiceWorkerFetchRequest> request,
225 const CacheStorageCacheQueryParams& options, 218 const CacheStorageCacheQueryParams& options,
226 QueryCacheType query_type, 219 QueryCacheType query_type,
227 const QueryCacheCallback& callback); 220 QueryCacheCallback callback);
228 void QueryCacheDidOpenFastPath( 221 void QueryCacheDidOpenFastPath(
229 std::unique_ptr<QueryCacheContext> query_cache_context, 222 std::unique_ptr<QueryCacheContext> query_cache_context,
230 int rv); 223 int rv);
231 void QueryCacheOpenNextEntry( 224 void QueryCacheOpenNextEntry(
232 std::unique_ptr<QueryCacheContext> query_cache_context); 225 std::unique_ptr<QueryCacheContext> query_cache_context);
233 void QueryCacheFilterEntry( 226 void QueryCacheFilterEntry(
234 std::unique_ptr<QueryCacheContext> query_cache_context, 227 std::unique_ptr<QueryCacheContext> query_cache_context,
235 int rv); 228 int rv);
236 void QueryCacheDidReadMetadata( 229 void QueryCacheDidReadMetadata(
237 std::unique_ptr<QueryCacheContext> query_cache_context, 230 std::unique_ptr<QueryCacheContext> query_cache_context,
238 disk_cache::ScopedEntryPtr entry, 231 disk_cache::ScopedEntryPtr entry,
239 std::unique_ptr<proto::CacheMetadata> metadata); 232 std::unique_ptr<proto::CacheMetadata> metadata);
240 static bool QueryCacheResultCompare(const QueryCacheResult& lhs, 233 static bool QueryCacheResultCompare(const QueryCacheResult& lhs,
241 const QueryCacheResult& rhs); 234 const QueryCacheResult& rhs);
242 235
243 // Match callbacks 236 // Match callbacks
244 void MatchImpl(std::unique_ptr<ServiceWorkerFetchRequest> request, 237 void MatchImpl(std::unique_ptr<ServiceWorkerFetchRequest> request,
245 const CacheStorageCacheQueryParams& match_params, 238 const CacheStorageCacheQueryParams& match_params,
246 const ResponseCallback& callback); 239 ResponseCallback callback);
247 void MatchDidMatchAll(const ResponseCallback& callback, 240 void MatchDidMatchAll(ResponseCallback callback,
248 CacheStorageError match_all_error, 241 CacheStorageError match_all_error,
249 std::unique_ptr<Responses> match_all_responses, 242 std::unique_ptr<Responses> match_all_responses,
250 std::unique_ptr<BlobDataHandles> match_all_handles); 243 std::unique_ptr<BlobDataHandles> match_all_handles);
251 244
252 // MatchAll callbacks 245 // MatchAll callbacks
253 void MatchAllImpl(std::unique_ptr<ServiceWorkerFetchRequest> request, 246 void MatchAllImpl(std::unique_ptr<ServiceWorkerFetchRequest> request,
254 const CacheStorageCacheQueryParams& options, 247 const CacheStorageCacheQueryParams& options,
255 const ResponsesCallback& callback); 248 ResponsesCallback callback);
256 void MatchAllDidQueryCache( 249 void MatchAllDidQueryCache(
257 const ResponsesCallback& callback, 250 ResponsesCallback callback,
258 CacheStorageError error, 251 CacheStorageError error,
259 std::unique_ptr<QueryCacheResults> query_cache_results); 252 std::unique_ptr<QueryCacheResults> query_cache_results);
260 253
261 // WriteSideData callbacks 254 // WriteSideData callbacks
262 void WriteSideDataDidGetQuota(const ErrorCallback& callback, 255 void WriteSideDataDidGetQuota(ErrorCallback callback,
263 const GURL& url, 256 const GURL& url,
264 base::Time expected_response_time, 257 base::Time expected_response_time,
265 scoped_refptr<net::IOBuffer> buffer, 258 scoped_refptr<net::IOBuffer> buffer,
266 int buf_len, 259 int buf_len,
267 storage::QuotaStatusCode status_code, 260 storage::QuotaStatusCode status_code,
268 int64_t usage, 261 int64_t usage,
269 int64_t quota); 262 int64_t quota);
270 263
271 void WriteSideDataImpl(const ErrorCallback& callback, 264 void WriteSideDataImpl(ErrorCallback callback,
272 const GURL& url, 265 const GURL& url,
273 base::Time expected_response_time, 266 base::Time expected_response_time,
274 scoped_refptr<net::IOBuffer> buffer, 267 scoped_refptr<net::IOBuffer> buffer,
275 int buf_len); 268 int buf_len);
276 void WriteSideDataDidGetUsageAndQuota(const ErrorCallback& callback, 269 void WriteSideDataDidGetUsageAndQuota(ErrorCallback callback,
277 const GURL& url, 270 const GURL& url,
278 base::Time expected_response_time, 271 base::Time expected_response_time,
279 scoped_refptr<net::IOBuffer> buffer, 272 scoped_refptr<net::IOBuffer> buffer,
280 int buf_len, 273 int buf_len,
281 storage::QuotaStatusCode status_code, 274 storage::QuotaStatusCode status_code,
282 int64_t usage, 275 int64_t usage,
283 int64_t quota); 276 int64_t quota);
284 void WriteSideDataDidOpenEntry(const ErrorCallback& callback, 277 void WriteSideDataDidOpenEntry(ErrorCallback callback,
285 base::Time expected_response_time, 278 base::Time expected_response_time,
286 scoped_refptr<net::IOBuffer> buffer, 279 scoped_refptr<net::IOBuffer> buffer,
287 int buf_len, 280 int buf_len,
288 std::unique_ptr<disk_cache::Entry*> entry_ptr, 281 std::unique_ptr<disk_cache::Entry*> entry_ptr,
289 int rv); 282 int rv);
290 void WriteSideDataDidReadMetaData( 283 void WriteSideDataDidReadMetaData(
291 const ErrorCallback& callback, 284 ErrorCallback callback,
292 base::Time expected_response_time, 285 base::Time expected_response_time,
293 scoped_refptr<net::IOBuffer> buffer, 286 scoped_refptr<net::IOBuffer> buffer,
294 int buf_len, 287 int buf_len,
295 disk_cache::ScopedEntryPtr entry, 288 disk_cache::ScopedEntryPtr entry,
296 std::unique_ptr<proto::CacheMetadata> headers); 289 std::unique_ptr<proto::CacheMetadata> headers);
297 void WriteSideDataDidWrite(const ErrorCallback& callback, 290 void WriteSideDataDidWrite(ErrorCallback callback,
298 disk_cache::ScopedEntryPtr entry, 291 disk_cache::ScopedEntryPtr entry,
299 int expected_bytes, 292 int expected_bytes,
300 int rv); 293 int rv);
301 294
302 // Puts the request and response object in the cache. The response body (if 295 // Puts the request and response object in the cache. The response body (if
303 // present) is stored in the cache, but not the request body. Returns OK on 296 // present) is stored in the cache, but not the request body. Returns OK on
304 // success. 297 // success.
305 void Put(const CacheStorageBatchOperation& operation, 298 void Put(const CacheStorageBatchOperation& operation, ErrorCallback callback);
306 const ErrorCallback& callback);
307 void PutImpl(std::unique_ptr<PutContext> put_context); 299 void PutImpl(std::unique_ptr<PutContext> put_context);
308 void PutDidDoomEntry(std::unique_ptr<PutContext> put_context, int rv); 300 void PutDidDoomEntry(std::unique_ptr<PutContext> put_context, int rv);
309 void PutDidGetUsageAndQuota(std::unique_ptr<PutContext> put_context, 301 void PutDidGetUsageAndQuota(std::unique_ptr<PutContext> put_context,
310 storage::QuotaStatusCode status_code, 302 storage::QuotaStatusCode status_code,
311 int64_t usage, 303 int64_t usage,
312 int64_t quota); 304 int64_t quota);
313 void PutDidCreateEntry(std::unique_ptr<disk_cache::Entry*> entry_ptr, 305 void PutDidCreateEntry(std::unique_ptr<disk_cache::Entry*> entry_ptr,
314 std::unique_ptr<PutContext> put_context, 306 std::unique_ptr<PutContext> put_context,
315 int rv); 307 int rv);
316 void PutDidWriteHeaders(std::unique_ptr<PutContext> put_context, 308 void PutDidWriteHeaders(std::unique_ptr<PutContext> put_context,
317 int expected_bytes, 309 int expected_bytes,
318 int rv); 310 int rv);
319 void PutDidWriteBlobToCache(std::unique_ptr<PutContext> put_context, 311 void PutDidWriteBlobToCache(std::unique_ptr<PutContext> put_context,
320 BlobToDiskCacheIDMap::KeyType blob_to_cache_key, 312 BlobToDiskCacheIDMap::KeyType blob_to_cache_key,
321 disk_cache::ScopedEntryPtr entry, 313 disk_cache::ScopedEntryPtr entry,
322 bool success); 314 bool success);
323 315
324 // Asynchronously calculates the current cache size, notifies the quota 316 // Asynchronously calculates the current cache size, notifies the quota
325 // manager of any change from the last report, and sets cache_size_ to the new 317 // manager of any change from the last report, and sets cache_size_ to the new
326 // size. 318 // size.
327 void UpdateCacheSize(const base::Closure& callback); 319 void UpdateCacheSize(base::OnceClosure callback);
328 void UpdateCacheSizeGotSize(std::unique_ptr<CacheStorageCacheHandle>, 320 void UpdateCacheSizeGotSize(std::unique_ptr<CacheStorageCacheHandle>,
329 const base::Closure& callback, 321 base::OnceClosure callback,
330 int current_cache_size); 322 int current_cache_size);
331 323
332 // Returns ERROR_NOT_FOUND if not found. Otherwise deletes and returns OK. 324 // Returns ERROR_NOT_FOUND if not found. Otherwise deletes and returns OK.
333 void Delete(const CacheStorageBatchOperation& operation, 325 void Delete(const CacheStorageBatchOperation& operation,
334 const ErrorCallback& callback); 326 ErrorCallback callback);
335 void DeleteImpl(std::unique_ptr<ServiceWorkerFetchRequest> request, 327 void DeleteImpl(std::unique_ptr<ServiceWorkerFetchRequest> request,
336 const CacheStorageCacheQueryParams& match_params, 328 const CacheStorageCacheQueryParams& match_params,
337 const ErrorCallback& callback); 329 ErrorCallback callback);
338 void DeleteDidQueryCache( 330 void DeleteDidQueryCache(
339 const ErrorCallback& callback, 331 ErrorCallback callback,
340 CacheStorageError error, 332 CacheStorageError error,
341 std::unique_ptr<QueryCacheResults> query_cache_results); 333 std::unique_ptr<QueryCacheResults> query_cache_results);
342 334
343 // Keys callbacks. 335 // Keys callbacks.
344 void KeysImpl(std::unique_ptr<ServiceWorkerFetchRequest> request, 336 void KeysImpl(std::unique_ptr<ServiceWorkerFetchRequest> request,
345 const CacheStorageCacheQueryParams& options, 337 const CacheStorageCacheQueryParams& options,
346 const RequestsCallback& callback); 338 RequestsCallback callback);
347 void KeysDidQueryCache( 339 void KeysDidQueryCache(
348 const RequestsCallback& callback, 340 RequestsCallback callback,
349 CacheStorageError error, 341 CacheStorageError error,
350 std::unique_ptr<QueryCacheResults> query_cache_results); 342 std::unique_ptr<QueryCacheResults> query_cache_results);
351 343
352 void CloseImpl(const base::Closure& callback); 344 void CloseImpl(base::OnceClosure callback);
353 345
354 void SizeImpl(const SizeCallback& callback); 346 void SizeImpl(SizeCallback callback);
355 347
356 void GetSizeThenCloseDidGetSize(const SizeCallback& callback, 348 void GetSizeThenCloseDidGetSize(SizeCallback callback, int64_t cache_size);
357 int64_t cache_size);
358 349
359 // Loads the backend and calls the callback with the result (true for 350 // Loads the backend and calls the callback with the result (true for
360 // success). The callback will always be called. Virtual for tests. 351 // success). The callback will always be called. Virtual for tests.
361 virtual void CreateBackend(const ErrorCallback& callback); 352 virtual void CreateBackend(ErrorCallback callback);
362 void CreateBackendDidCreate(const CacheStorageCache::ErrorCallback& callback, 353 void CreateBackendDidCreate(ErrorCallback callback,
363 std::unique_ptr<ScopedBackendPtr> backend_ptr, 354 std::unique_ptr<ScopedBackendPtr> backend_ptr,
364 int rv); 355 int rv);
365 356
366 void InitBackend(); 357 void InitBackend();
367 void InitDidCreateBackend(const base::Closure& callback, 358 void InitDidCreateBackend(base::OnceClosure callback,
368 CacheStorageError cache_create_error); 359 CacheStorageError cache_create_error);
369 void InitGotCacheSize(const base::Closure& callback, 360 void InitGotCacheSize(base::OnceClosure callback,
370 CacheStorageError cache_create_error, 361 CacheStorageError cache_create_error,
371 int cache_size); 362 int cache_size);
372 363
373 std::unique_ptr<storage::BlobDataHandle> PopulateResponseBody( 364 std::unique_ptr<storage::BlobDataHandle> PopulateResponseBody(
374 disk_cache::ScopedEntryPtr entry, 365 disk_cache::ScopedEntryPtr entry,
375 ServiceWorkerResponse* response); 366 ServiceWorkerResponse* response);
376 367
377 // Virtual for testing. 368 // Virtual for testing.
378 virtual std::unique_ptr<CacheStorageCacheHandle> CreateCacheHandle(); 369 virtual std::unique_ptr<CacheStorageCacheHandle> CreateCacheHandle();
379 370
(...skipping 24 matching lines...) Expand all
404 bool memory_only_; 395 bool memory_only_;
405 396
406 base::WeakPtrFactory<CacheStorageCache> weak_ptr_factory_; 397 base::WeakPtrFactory<CacheStorageCache> weak_ptr_factory_;
407 398
408 DISALLOW_COPY_AND_ASSIGN(CacheStorageCache); 399 DISALLOW_COPY_AND_ASSIGN(CacheStorageCache);
409 }; 400 };
410 401
411 } // namespace content 402 } // namespace content
412 403
413 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CACHE_H_ 404 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698