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

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

Issue 2040173002: [CacheStorage] Clean up CacheStorageCache lifetimes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplify and caught one more reference Created 4 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 #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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 const std::vector<CacheStorageBatchOperation>& operations, 374 const std::vector<CacheStorageBatchOperation>& operations,
375 const ErrorCallback& callback) { 375 const ErrorCallback& callback) {
376 if (!LazyInitialize()) { 376 if (!LazyInitialize()) {
377 callback.Run(CACHE_STORAGE_ERROR_STORAGE); 377 callback.Run(CACHE_STORAGE_ERROR_STORAGE);
378 return; 378 return;
379 } 379 }
380 380
381 std::unique_ptr<ErrorCallback> callback_copy(new ErrorCallback(callback)); 381 std::unique_ptr<ErrorCallback> callback_copy(new ErrorCallback(callback));
382 ErrorCallback* callback_ptr = callback_copy.get(); 382 ErrorCallback* callback_ptr = callback_copy.get();
383 base::Closure barrier_closure = base::BarrierClosure( 383 base::Closure barrier_closure = base::BarrierClosure(
384 operations.size(), 384 operations.size(), base::Bind(&CacheStorageCache::BatchDidAllOperations,
385 base::Bind(&CacheStorageCache::BatchDidAllOperations, this, 385 weak_ptr_factory_.GetWeakPtr(),
386 base::Passed(std::move(callback_copy)))); 386 base::Passed(std::move(callback_copy))));
387 ErrorCallback completion_callback = 387 ErrorCallback completion_callback =
388 base::Bind(&CacheStorageCache::BatchDidOneOperation, this, 388 base::Bind(&CacheStorageCache::BatchDidOneOperation,
389 barrier_closure, callback_ptr); 389 weak_ptr_factory_.GetWeakPtr(), barrier_closure, callback_ptr);
390 390
391 for (const auto& operation : operations) { 391 for (const auto& operation : operations) {
392 switch (operation.operation_type) { 392 switch (operation.operation_type) {
393 case CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT: 393 case CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT:
394 Put(operation, completion_callback); 394 Put(operation, completion_callback);
395 break; 395 break;
396 case CACHE_STORAGE_CACHE_OPERATION_TYPE_DELETE: 396 case CACHE_STORAGE_CACHE_OPERATION_TYPE_DELETE:
397 DCHECK_EQ(1u, operations.size()); 397 DCHECK_EQ(1u, operations.size());
398 Delete(operation, completion_callback); 398 Delete(operation, completion_callback);
399 break; 399 break;
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1544 storage::BlobDataBuilder blob_data(response->blob_uuid); 1544 storage::BlobDataBuilder blob_data(response->blob_uuid);
1545 1545
1546 disk_cache::Entry* temp_entry = entry.get(); 1546 disk_cache::Entry* temp_entry = entry.get();
1547 blob_data.AppendDiskCacheEntryWithSideData( 1547 blob_data.AppendDiskCacheEntryWithSideData(
1548 new CacheStorageCacheDataHandle(this, std::move(entry)), temp_entry, 1548 new CacheStorageCacheDataHandle(this, std::move(entry)), temp_entry,
1549 INDEX_RESPONSE_BODY, INDEX_SIDE_DATA); 1549 INDEX_RESPONSE_BODY, INDEX_SIDE_DATA);
1550 return blob_storage_context_->AddFinishedBlob(&blob_data); 1550 return blob_storage_context_->AddFinishedBlob(&blob_data);
1551 } 1551 }
1552 1552
1553 } // namespace content 1553 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/cache_storage/cache_storage.cc ('k') | content/browser/cache_storage/cache_storage_dispatcher_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698