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