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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 scoped_ptr<PutContext> put_context, | 200 scoped_ptr<PutContext> put_context, |
201 int rv); | 201 int rv); |
202 void PutDidWriteHeaders(scoped_ptr<PutContext> put_context, | 202 void PutDidWriteHeaders(scoped_ptr<PutContext> put_context, |
203 int expected_bytes, | 203 int expected_bytes, |
204 int rv); | 204 int rv); |
205 void PutDidWriteBlobToCache(scoped_ptr<PutContext> put_context, | 205 void PutDidWriteBlobToCache(scoped_ptr<PutContext> put_context, |
206 BlobToDiskCacheIDMap::KeyType blob_to_cache_key, | 206 BlobToDiskCacheIDMap::KeyType blob_to_cache_key, |
207 disk_cache::ScopedEntryPtr entry, | 207 disk_cache::ScopedEntryPtr entry, |
208 bool success); | 208 bool success); |
209 | 209 |
| 210 // Asynchronously calculates the current cache size, notifies the quota |
| 211 // manager of any change from the last report, and sets cache_size_ to the new |
| 212 // size. Runs |callback| once complete. |
| 213 void UpdateCacheSize(const base::Closure& callback); |
| 214 void UpdateCacheSizeGotSize(const base::Closure& callback, |
| 215 int current_cache_size); |
| 216 |
210 // Returns ERROR_NOT_FOUND if not found. Otherwise deletes and returns OK. | 217 // Returns ERROR_NOT_FOUND if not found. Otherwise deletes and returns OK. |
211 void Delete(const CacheStorageBatchOperation& operation, | 218 void Delete(const CacheStorageBatchOperation& operation, |
212 const ErrorCallback& callback); | 219 const ErrorCallback& callback); |
213 void DeleteImpl(scoped_ptr<ServiceWorkerFetchRequest> request, | 220 void DeleteImpl(scoped_ptr<ServiceWorkerFetchRequest> request, |
214 const ErrorCallback& callback); | 221 const ErrorCallback& callback); |
215 void DeleteDidOpenEntry( | 222 void DeleteDidOpenEntry(const GURL& origin, |
216 const GURL& origin, | 223 scoped_ptr<ServiceWorkerFetchRequest> request, |
217 scoped_ptr<ServiceWorkerFetchRequest> request, | 224 const CacheStorageCache::ErrorCallback& callback, |
218 const CacheStorageCache::ErrorCallback& callback, | 225 scoped_ptr<disk_cache::Entry*> entryptr, |
219 scoped_ptr<disk_cache::Entry*> entryptr, | 226 int rv); |
220 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, | |
221 int rv); | |
222 | 227 |
223 // Keys callbacks. | 228 // Keys callbacks. |
224 void KeysImpl(const RequestsCallback& callback); | 229 void KeysImpl(const RequestsCallback& callback); |
225 void KeysDidOpenAllEntries(const RequestsCallback& callback, | 230 void KeysDidOpenAllEntries(const RequestsCallback& callback, |
226 scoped_ptr<OpenAllEntriesContext> entries_context, | 231 scoped_ptr<OpenAllEntriesContext> entries_context, |
227 CacheStorageError error); | 232 CacheStorageError error); |
228 void KeysProcessNextEntry(scoped_ptr<KeysContext> keys_context, | 233 void KeysProcessNextEntry(scoped_ptr<KeysContext> keys_context, |
229 const Entries::iterator& iter); | 234 const Entries::iterator& iter); |
230 void KeysDidReadMetadata(scoped_ptr<KeysContext> keys_context, | 235 void KeysDidReadMetadata(scoped_ptr<KeysContext> keys_context, |
231 const Entries::iterator& iter, | 236 const Entries::iterator& iter, |
232 scoped_ptr<CacheMetadata> metadata); | 237 scoped_ptr<CacheMetadata> metadata); |
233 | 238 |
234 void CloseImpl(const base::Closure& callback); | 239 void CloseImpl(const base::Closure& callback); |
235 | 240 |
236 void SizeImpl(const SizeCallback& callback); | 241 void SizeImpl(const SizeCallback& callback); |
237 | 242 |
238 // Loads the backend and calls the callback with the result (true for | 243 // Loads the backend and calls the callback with the result (true for |
239 // success). The callback will always be called. Virtual for tests. | 244 // success). The callback will always be called. Virtual for tests. |
240 virtual void CreateBackend(const ErrorCallback& callback); | 245 virtual void CreateBackend(const ErrorCallback& callback); |
241 void CreateBackendDidCreate(const CacheStorageCache::ErrorCallback& callback, | 246 void CreateBackendDidCreate(const CacheStorageCache::ErrorCallback& callback, |
242 scoped_ptr<ScopedBackendPtr> backend_ptr, | 247 scoped_ptr<ScopedBackendPtr> backend_ptr, |
243 int rv); | 248 int rv); |
244 | 249 |
245 void InitBackend(); | 250 void InitBackend(); |
246 void InitDone(CacheStorageError error); | 251 void InitDidCreateBackend(CacheStorageError cache_create_error); |
| 252 void InitGotCacheSize(CacheStorageError cache_create_error, int cache_size); |
247 | 253 |
248 void PendingClosure(const base::Closure& callback); | 254 void PendingClosure(const base::Closure& callback); |
249 void PendingErrorCallback(const ErrorCallback& callback, | 255 void PendingErrorCallback(const ErrorCallback& callback, |
250 CacheStorageError error); | 256 CacheStorageError error); |
251 void PendingResponseCallback( | 257 void PendingResponseCallback( |
252 const ResponseCallback& callback, | 258 const ResponseCallback& callback, |
253 CacheStorageError error, | 259 CacheStorageError error, |
254 scoped_ptr<ServiceWorkerResponse> response, | 260 scoped_ptr<ServiceWorkerResponse> response, |
255 scoped_ptr<storage::BlobDataHandle> blob_data_handle); | 261 scoped_ptr<storage::BlobDataHandle> blob_data_handle); |
256 void PendingResponsesCallback(const ResponsesCallback& callback, | 262 void PendingResponsesCallback(const ResponsesCallback& callback, |
(...skipping 12 matching lines...) Expand all Loading... |
269 ServiceWorkerResponse* response); | 275 ServiceWorkerResponse* response); |
270 | 276 |
271 // Be sure to check |backend_state_| before use. | 277 // Be sure to check |backend_state_| before use. |
272 scoped_ptr<disk_cache::Backend> backend_; | 278 scoped_ptr<disk_cache::Backend> backend_; |
273 | 279 |
274 GURL origin_; | 280 GURL origin_; |
275 base::FilePath path_; | 281 base::FilePath path_; |
276 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | 282 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
277 scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy_; | 283 scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy_; |
278 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_; | 284 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_; |
279 BackendState backend_state_; | 285 BackendState backend_state_ = BACKEND_UNINITIALIZED; |
280 scoped_ptr<CacheStorageScheduler> scheduler_; | 286 scoped_ptr<CacheStorageScheduler> scheduler_; |
281 bool initializing_; | 287 bool initializing_ = false; |
| 288 int64_t cache_size_ = 0; |
282 | 289 |
283 // Owns the elements of the list | 290 // Owns the elements of the list |
284 BlobToDiskCacheIDMap active_blob_to_disk_cache_writers_; | 291 BlobToDiskCacheIDMap active_blob_to_disk_cache_writers_; |
285 | 292 |
286 // Whether or not to store data in disk or memory. | 293 // Whether or not to store data in disk or memory. |
287 bool memory_only_; | 294 bool memory_only_; |
288 | 295 |
289 base::WeakPtrFactory<CacheStorageCache> weak_ptr_factory_; | 296 base::WeakPtrFactory<CacheStorageCache> weak_ptr_factory_; |
290 | 297 |
291 DISALLOW_COPY_AND_ASSIGN(CacheStorageCache); | 298 DISALLOW_COPY_AND_ASSIGN(CacheStorageCache); |
292 }; | 299 }; |
293 | 300 |
294 } // namespace content | 301 } // namespace content |
295 | 302 |
296 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CACHE_H_ | 303 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_CACHE_H_ |
OLD | NEW |