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 #include "content/browser/cache_storage/cache_storage_cache.h" | 5 #include "content/browser/cache_storage/cache_storage_cache.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 const base::FilePath& path, | 298 const base::FilePath& path, |
299 scoped_refptr<net::URLRequestContextGetter> request_context_getter, | 299 scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
300 scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy, | 300 scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy, |
301 base::WeakPtr<storage::BlobStorageContext> blob_context) { | 301 base::WeakPtr<storage::BlobStorageContext> blob_context) { |
302 return make_scoped_refptr( | 302 return make_scoped_refptr( |
303 new CacheStorageCache(origin, path, std::move(request_context_getter), | 303 new CacheStorageCache(origin, path, std::move(request_context_getter), |
304 std::move(quota_manager_proxy), blob_context)); | 304 std::move(quota_manager_proxy), blob_context)); |
305 } | 305 } |
306 | 306 |
307 CacheStorageCache::~CacheStorageCache() { | 307 CacheStorageCache::~CacheStorageCache() { |
| 308 quota_manager_proxy_->NotifyOriginNoLongerInUse(origin_); |
308 } | 309 } |
309 | 310 |
310 base::WeakPtr<CacheStorageCache> CacheStorageCache::AsWeakPtr() { | 311 base::WeakPtr<CacheStorageCache> CacheStorageCache::AsWeakPtr() { |
311 return weak_ptr_factory_.GetWeakPtr(); | 312 return weak_ptr_factory_.GetWeakPtr(); |
312 } | 313 } |
313 | 314 |
314 void CacheStorageCache::Match(scoped_ptr<ServiceWorkerFetchRequest> request, | 315 void CacheStorageCache::Match(scoped_ptr<ServiceWorkerFetchRequest> request, |
315 const ResponseCallback& callback) { | 316 const ResponseCallback& callback) { |
316 if (!LazyInitialize()) { | 317 if (!LazyInitialize()) { |
317 callback.Run(CACHE_STORAGE_ERROR_STORAGE, | 318 callback.Run(CACHE_STORAGE_ERROR_STORAGE, |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 scoped_refptr<net::URLRequestContextGetter> request_context_getter, | 483 scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
483 scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy, | 484 scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy, |
484 base::WeakPtr<storage::BlobStorageContext> blob_context) | 485 base::WeakPtr<storage::BlobStorageContext> blob_context) |
485 : origin_(origin), | 486 : origin_(origin), |
486 path_(path), | 487 path_(path), |
487 request_context_getter_(std::move(request_context_getter)), | 488 request_context_getter_(std::move(request_context_getter)), |
488 quota_manager_proxy_(std::move(quota_manager_proxy)), | 489 quota_manager_proxy_(std::move(quota_manager_proxy)), |
489 blob_storage_context_(blob_context), | 490 blob_storage_context_(blob_context), |
490 scheduler_(new CacheStorageScheduler()), | 491 scheduler_(new CacheStorageScheduler()), |
491 memory_only_(path.empty()), | 492 memory_only_(path.empty()), |
492 weak_ptr_factory_(this) {} | 493 weak_ptr_factory_(this) { |
| 494 DCHECK(!origin_.is_empty()); |
| 495 DCHECK(quota_manager_proxy_.get()); |
| 496 |
| 497 quota_manager_proxy_->NotifyOriginInUse(origin_); |
| 498 } |
493 | 499 |
494 bool CacheStorageCache::LazyInitialize() { | 500 bool CacheStorageCache::LazyInitialize() { |
495 switch (backend_state_) { | 501 switch (backend_state_) { |
496 case BACKEND_UNINITIALIZED: | 502 case BACKEND_UNINITIALIZED: |
497 InitBackend(); | 503 InitBackend(); |
498 return true; | 504 return true; |
499 case BACKEND_CLOSED: | 505 case BACKEND_CLOSED: |
500 return false; | 506 return false; |
501 case BACKEND_OPEN: | 507 case BACKEND_OPEN: |
502 DCHECK(backend_); | 508 DCHECK(backend_); |
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1393 storage::BlobDataBuilder blob_data(response->blob_uuid); | 1399 storage::BlobDataBuilder blob_data(response->blob_uuid); |
1394 | 1400 |
1395 disk_cache::Entry* temp_entry = entry.get(); | 1401 disk_cache::Entry* temp_entry = entry.get(); |
1396 blob_data.AppendDiskCacheEntry( | 1402 blob_data.AppendDiskCacheEntry( |
1397 new CacheStorageCacheDataHandle(this, std::move(entry)), temp_entry, | 1403 new CacheStorageCacheDataHandle(this, std::move(entry)), temp_entry, |
1398 INDEX_RESPONSE_BODY); | 1404 INDEX_RESPONSE_BODY); |
1399 return blob_storage_context_->AddFinishedBlob(&blob_data); | 1405 return blob_storage_context_->AddFinishedBlob(&blob_data); |
1400 } | 1406 } |
1401 | 1407 |
1402 } // namespace content | 1408 } // namespace content |
OLD | NEW |