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

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

Issue 1833673003: [CacheStorage] Notify QuotaManager when a cache is in use (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits Created 4 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698