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

Unified Diff: content/browser/cache_storage/cache_storage_blob_to_disk_cache.cc

Issue 2947753002: CacheStorage: Migrate to BindOnce/OnceCallback/OnceClosure (Closed)
Patch Set: Untangle Batch logic (relies on AdaptCallbackForRepeating) Created 3 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/cache_storage/cache_storage_blob_to_disk_cache.cc
diff --git a/content/browser/cache_storage/cache_storage_blob_to_disk_cache.cc b/content/browser/cache_storage/cache_storage_blob_to_disk_cache.cc
index 10c0fa672d8c8bfa70a6702c6230cc19d26542c1..7933918ffc51350b078d7a9e4b7c80af7ac01f83 100644
--- a/content/browser/cache_storage/cache_storage_blob_to_disk_cache.cc
+++ b/content/browser/cache_storage/cache_storage_blob_to_disk_cache.cc
@@ -35,7 +35,7 @@ void CacheStorageBlobToDiskCache::StreamBlobToCache(
int disk_cache_body_index,
net::URLRequestContextGetter* request_context_getter,
std::unique_ptr<storage::BlobDataHandle> blob_data_handle,
- const EntryAndBoolCallback& callback) {
+ EntryAndBoolCallback callback) {
DCHECK(entry);
DCHECK_LE(0, disk_cache_body_index);
DCHECK(blob_data_handle);
@@ -43,14 +43,14 @@ void CacheStorageBlobToDiskCache::StreamBlobToCache(
DCHECK(request_context_getter);
if (!request_context_getter->GetURLRequestContext()) {
- callback.Run(std::move(entry), false /* success */);
+ std::move(callback).Run(std::move(entry), false /* success */);
return;
}
disk_cache_body_index_ = disk_cache_body_index;
entry_ = std::move(entry);
- callback_ = callback;
+ callback_ = std::move(callback);
request_context_getter_ = request_context_getter;
blob_request_ = storage::BlobProtocolHandler::CreateBlobRequest(
@@ -87,8 +87,9 @@ void CacheStorageBlobToDiskCache::OnReadCompleted(net::URLRequest* request,
}
net::CompletionCallback cache_write_callback =
- base::Bind(&CacheStorageBlobToDiskCache::DidWriteDataToEntry,
- weak_ptr_factory_.GetWeakPtr(), bytes_read);
+ base::AdaptCallbackForRepeating(
+ base::BindOnce(&CacheStorageBlobToDiskCache::DidWriteDataToEntry,
+ weak_ptr_factory_.GetWeakPtr(), bytes_read));
int rv = entry_->WriteData(disk_cache_body_index_, cache_entry_offset_,
buffer_.get(), bytes_read, cache_write_callback,
@@ -149,7 +150,7 @@ void CacheStorageBlobToDiskCache::RunCallbackAndRemoveObserver(bool success) {
request_context_getter_->RemoveObserver(this);
blob_request_.reset();
- callback_.Run(std::move(entry_), success);
+ std::move(callback_).Run(std::move(entry_), success);
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698