diff options
author | nhiroki <nhiroki@chromium.org> | 2015-05-05 21:45:28 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-06 04:46:06 +0000 |
commit | 5e37c0bd9ba5c2062ff9841171cc070d0dafdbf3 (patch) | |
tree | 040eb48f5907cef3a0214e13e2e2f2155d0461f0 /content | |
parent | ab02bdea435576536bddd172d82e21e93715890f (diff) | |
download | chromium_src-5e37c0bd9ba5c2062ff9841171cc070d0dafdbf3.zip chromium_src-5e37c0bd9ba5c2062ff9841171cc070d0dafdbf3.tar.gz chromium_src-5e37c0bd9ba5c2062ff9841171cc070d0dafdbf3.tar.bz2 |
CacheStorage: Remove unused return value from put operation
Cache.put() and other batch operations no longer require responses as a return
value.
BUG=482827
TEST=should pass all existing tests (no functional changes)
TBR=nasko@chromium.org
Review URL: https://codereview.chromium.org/1111253003
Cr-Commit-Position: refs/heads/master@{#328486}
Diffstat (limited to 'content')
9 files changed, 49 insertions, 99 deletions
diff --git a/content/browser/cache_storage/cache_storage_cache.cc b/content/browser/cache_storage/cache_storage_cache.cc index 0727555..5443552 100644 --- a/content/browser/cache_storage/cache_storage_cache.cc +++ b/content/browser/cache_storage/cache_storage_cache.cc @@ -340,7 +340,7 @@ struct CacheStorageCache::PutContext { scoped_ptr<ServiceWorkerFetchRequest> request, scoped_ptr<ServiceWorkerResponse> response, scoped_ptr<storage::BlobDataHandle> blob_data_handle, - const CacheStorageCache::ResponseCallback& callback, + const CacheStorageCache::ErrorCallback& callback, net::URLRequestContext* request_context, const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy) : origin(origin), @@ -361,7 +361,7 @@ struct CacheStorageCache::PutContext { scoped_ptr<ServiceWorkerFetchRequest> request; scoped_ptr<ServiceWorkerResponse> response; scoped_ptr<storage::BlobDataHandle> blob_data_handle; - CacheStorageCache::ResponseCallback callback; + CacheStorageCache::ErrorCallback callback; net::URLRequestContext* request_context; scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy; @@ -369,9 +369,6 @@ struct CacheStorageCache::PutContext { // CreateEntry. disk_cache::Entry* cache_entry; - // The BlobDataHandle for the output ServiceWorkerResponse. - scoped_ptr<storage::BlobDataHandle> out_blob_data_handle; - DISALLOW_COPY_AND_ASSIGN(PutContext); }; @@ -406,39 +403,30 @@ base::WeakPtr<CacheStorageCache> CacheStorageCache::AsWeakPtr() { void CacheStorageCache::Put(scoped_ptr<ServiceWorkerFetchRequest> request, scoped_ptr<ServiceWorkerResponse> response, - const ResponseCallback& callback) { + const ErrorCallback& callback) { scoped_ptr<storage::BlobDataHandle> blob_data_handle; if (!response->blob_uuid.empty()) { if (!blob_storage_context_) { - callback.Run(ERROR_TYPE_STORAGE, scoped_ptr<ServiceWorkerResponse>(), - scoped_ptr<storage::BlobDataHandle>()); + callback.Run(ERROR_TYPE_STORAGE); return; } blob_data_handle = blob_storage_context_->GetBlobDataFromUUID(response->blob_uuid); if (!blob_data_handle) { - callback.Run(ERROR_TYPE_STORAGE, scoped_ptr<ServiceWorkerResponse>(), - scoped_ptr<storage::BlobDataHandle>()); + callback.Run(ERROR_TYPE_STORAGE); return; } } - ResponseCallback pending_callback = - base::Bind(&CacheStorageCache::PendingResponseCallback, + ErrorCallback pending_callback = + base::Bind(&CacheStorageCache::PendingErrorCallback, weak_ptr_factory_.GetWeakPtr(), callback); scoped_ptr<PutContext> put_context(new PutContext( origin_, request.Pass(), response.Pass(), blob_data_handle.Pass(), pending_callback, request_context_, quota_manager_proxy_)); - if (put_context->blob_data_handle) { - // Grab another handle to the blob for the callback response. - put_context->out_blob_data_handle = - blob_storage_context_->GetBlobDataFromUUID( - put_context->response->blob_uuid); - } - if (backend_state_ == BACKEND_UNINITIALIZED) InitBackend(); @@ -761,9 +749,7 @@ void CacheStorageCache::MatchDoneWithBody( void CacheStorageCache::PutImpl(scoped_ptr<PutContext> put_context) { DCHECK(backend_state_ != BACKEND_UNINITIALIZED); if (backend_state_ != BACKEND_OPEN) { - put_context->callback.Run(ERROR_TYPE_STORAGE, - scoped_ptr<ServiceWorkerResponse>(), - scoped_ptr<storage::BlobDataHandle>()); + put_context->callback.Run(ERROR_TYPE_STORAGE); return; } @@ -778,9 +764,7 @@ void CacheStorageCache::PutImpl(scoped_ptr<PutContext> put_context) { void CacheStorageCache::PutDidDelete(scoped_ptr<PutContext> put_context, ErrorType delete_error) { if (backend_state_ != BACKEND_OPEN) { - put_context->callback.Run(ERROR_TYPE_STORAGE, - scoped_ptr<ServiceWorkerResponse>(), - scoped_ptr<storage::BlobDataHandle>()); + put_context->callback.Run(ERROR_TYPE_STORAGE); return; } @@ -802,9 +786,7 @@ void CacheStorageCache::PutDidDelete(scoped_ptr<PutContext> put_context, void CacheStorageCache::PutDidCreateEntry(scoped_ptr<PutContext> put_context, int rv) { if (rv != net::OK) { - put_context->callback.Run(CacheStorageCache::ERROR_TYPE_EXISTS, - scoped_ptr<ServiceWorkerResponse>(), - scoped_ptr<storage::BlobDataHandle>()); + put_context->callback.Run(CacheStorageCache::ERROR_TYPE_EXISTS); return; } @@ -841,9 +823,7 @@ void CacheStorageCache::PutDidCreateEntry(scoped_ptr<PutContext> put_context, scoped_ptr<std::string> serialized(new std::string()); if (!metadata.SerializeToString(serialized.get())) { - put_context->callback.Run(CacheStorageCache::ERROR_TYPE_STORAGE, - scoped_ptr<ServiceWorkerResponse>(), - scoped_ptr<storage::BlobDataHandle>()); + put_context->callback.Run(CacheStorageCache::ERROR_TYPE_STORAGE); return; } @@ -870,9 +850,7 @@ void CacheStorageCache::PutDidWriteHeaders(scoped_ptr<PutContext> put_context, int rv) { if (rv != expected_bytes) { put_context->cache_entry->Doom(); - put_context->callback.Run(CacheStorageCache::ERROR_TYPE_STORAGE, - scoped_ptr<ServiceWorkerResponse>(), - scoped_ptr<storage::BlobDataHandle>()); + put_context->callback.Run(CacheStorageCache::ERROR_TYPE_STORAGE); return; } @@ -887,9 +865,7 @@ void CacheStorageCache::PutDidWriteHeaders(scoped_ptr<PutContext> put_context, put_context->cache_entry->GetDataSize(INDEX_HEADERS)); } - put_context->callback.Run(CacheStorageCache::ERROR_TYPE_OK, - put_context->response.Pass(), - scoped_ptr<storage::BlobDataHandle>()); + put_context->callback.Run(CacheStorageCache::ERROR_TYPE_OK); return; } @@ -923,9 +899,7 @@ void CacheStorageCache::PutDidWriteBlobToCache( if (!success) { put_context->cache_entry->Doom(); - put_context->callback.Run(CacheStorageCache::ERROR_TYPE_STORAGE, - scoped_ptr<ServiceWorkerResponse>(), - scoped_ptr<storage::BlobDataHandle>()); + put_context->callback.Run(CacheStorageCache::ERROR_TYPE_STORAGE); return; } @@ -937,9 +911,7 @@ void CacheStorageCache::PutDidWriteBlobToCache( put_context->cache_entry->GetDataSize(INDEX_RESPONSE_BODY)); } - put_context->callback.Run(CacheStorageCache::ERROR_TYPE_OK, - put_context->response.Pass(), - put_context->out_blob_data_handle.Pass()); + put_context->callback.Run(CacheStorageCache::ERROR_TYPE_OK); } void CacheStorageCache::DeleteImpl( diff --git a/content/browser/cache_storage/cache_storage_cache.h b/content/browser/cache_storage/cache_storage_cache.h index e63cac4..c558e2e 100644 --- a/content/browser/cache_storage/cache_storage_cache.h +++ b/content/browser/cache_storage/cache_storage_cache.h @@ -79,7 +79,7 @@ class CONTENT_EXPORT CacheStorageCache // ERROR_TYPE_OK on success. void Put(scoped_ptr<ServiceWorkerFetchRequest> request, scoped_ptr<ServiceWorkerResponse> response, - const ResponseCallback& callback); + const ErrorCallback& callback); // Returns ErrorNotFound if not found. Otherwise deletes and returns // ERROR_TYPE_OK. diff --git a/content/browser/cache_storage/cache_storage_cache_unittest.cc b/content/browser/cache_storage/cache_storage_cache_unittest.cc index 40a0256..3da11ec 100644 --- a/content/browser/cache_storage/cache_storage_cache_unittest.cc +++ b/content/browser/cache_storage/cache_storage_cache_unittest.cc @@ -267,7 +267,7 @@ class CacheStorageCacheTest : public testing::Test { cache_->Put( CopyFetchRequest(request), CopyFetchResponse(response), - base::Bind(&CacheStorageCacheTest::ResponseAndErrorCallback, + base::Bind(&CacheStorageCacheTest::ErrorTypeCallback, base::Unretained(this), base::Unretained(loop.get()))); // TODO(jkarlin): These functions should use base::RunLoop().RunUntilIdle() // once the cache uses a passed in MessageLoopProxy instead of the CACHE @@ -342,6 +342,16 @@ class CacheStorageCacheTest : public testing::Test { run_loop->Quit(); } + void SequenceCallback(int sequence, + int* sequence_out, + base::RunLoop* run_loop, + CacheStorageCache::ErrorType error) { + *sequence_out = sequence; + callback_error_ = error; + if (run_loop) + run_loop->Quit(); + } + void ResponseAndErrorCallback( base::RunLoop* run_loop, CacheStorageCache::ErrorType error, @@ -443,26 +453,10 @@ class CacheStorageCacheMemoryOnlyTest TEST_P(CacheStorageCacheTestP, PutNoBody) { EXPECT_TRUE(Put(no_body_request_, no_body_response_)); - EXPECT_TRUE(callback_response_); - EXPECT_STREQ(no_body_response_.url.spec().c_str(), - callback_response_->url.spec().c_str()); - EXPECT_FALSE(callback_response_data_); - EXPECT_STREQ("", callback_response_->blob_uuid.c_str()); - EXPECT_EQ(0u, callback_response_->blob_size); } TEST_P(CacheStorageCacheTestP, PutBody) { EXPECT_TRUE(Put(body_request_, body_response_)); - EXPECT_TRUE(callback_response_); - EXPECT_STREQ(body_response_.url.spec().c_str(), - callback_response_->url.spec().c_str()); - EXPECT_TRUE(callback_response_data_); - EXPECT_STRNE("", callback_response_->blob_uuid.c_str()); - EXPECT_EQ(expected_blob_data_.size(), callback_response_->blob_size); - - std::string response_body; - CopyBody(callback_response_data_.get(), &response_body); - EXPECT_STREQ(expected_blob_data_.c_str(), response_body.c_str()); } TEST_P(CacheStorageCacheTestP, ResponseURLDiffersFromRequestURL) { @@ -487,7 +481,7 @@ TEST_F(CacheStorageCacheTest, PutBodyDropBlobRef) { scoped_ptr<base::RunLoop> loop(new base::RunLoop()); cache_->Put(CopyFetchRequest(body_request_), CopyFetchResponse(body_response_), - base::Bind(&CacheStorageCacheTestP::ResponseAndErrorCallback, + base::Bind(&CacheStorageCacheTestP::ErrorTypeCallback, base::Unretained(this), base::Unretained(loop.get()))); // The handle should be held by the cache now so the deref here should be // okay. @@ -768,14 +762,15 @@ TEST_P(CacheStorageCacheTestP, VerifySerialScheduling) { DelayableBackend* delayable_backend = cache_->UseDelayableBackend(); delayable_backend->set_delay_open(true); + int sequence_out = -1; + scoped_ptr<ServiceWorkerResponse> response1 = CopyFetchResponse(body_response_); - response1->status_code = 1; - scoped_ptr<base::RunLoop> close_loop1(new base::RunLoop()); - cache_->Put(CopyFetchRequest(body_request_), response1.Pass(), - base::Bind(&CacheStorageCacheTest::ResponseAndErrorCallback, - base::Unretained(this), close_loop1.get())); + cache_->Put( + CopyFetchRequest(body_request_), response1.Pass(), + base::Bind(&CacheStorageCacheTest::SequenceCallback, + base::Unretained(this), 1, &sequence_out, close_loop1.get())); // Blocks on opening the cache entry. base::RunLoop().RunUntilIdle(); @@ -783,11 +778,11 @@ TEST_P(CacheStorageCacheTestP, VerifySerialScheduling) { delayable_backend->set_delay_open(false); scoped_ptr<ServiceWorkerResponse> response2 = CopyFetchResponse(body_response_); - response2->status_code = 2; scoped_ptr<base::RunLoop> close_loop2(new base::RunLoop()); - cache_->Put(CopyFetchRequest(body_request_), response2.Pass(), - base::Bind(&CacheStorageCacheTest::ResponseAndErrorCallback, - base::Unretained(this), close_loop2.get())); + cache_->Put( + CopyFetchRequest(body_request_), response2.Pass(), + base::Bind(&CacheStorageCacheTest::SequenceCallback, + base::Unretained(this), 2, &sequence_out, close_loop2.get())); // The second put operation should wait for the first to complete. base::RunLoop().RunUntilIdle(); @@ -795,9 +790,9 @@ TEST_P(CacheStorageCacheTestP, VerifySerialScheduling) { delayable_backend->OpenEntryContinue(); close_loop1->Run(); - EXPECT_EQ(1, callback_response_->status_code); + EXPECT_EQ(1, sequence_out); close_loop2->Run(); - EXPECT_EQ(2, callback_response_->status_code); + EXPECT_EQ(2, sequence_out); } INSTANTIATE_TEST_CASE_P(CacheStorageCacheTest, diff --git a/content/browser/cache_storage/cache_storage_dispatcher_host.cc b/content/browser/cache_storage/cache_storage_dispatcher_host.cc index bb9ae48..faa3779 100644 --- a/content/browser/cache_storage/cache_storage_dispatcher_host.cc +++ b/content/browser/cache_storage/cache_storage_dispatcher_host.cc @@ -453,29 +453,21 @@ void CacheStorageDispatcherHost::OnCacheDeleteCallback( return; } - Send(new CacheStorageMsg_CacheBatchSuccess( - thread_id, request_id, std::vector<ServiceWorkerResponse>())); + Send(new CacheStorageMsg_CacheBatchSuccess(thread_id, request_id)); } void CacheStorageDispatcherHost::OnCachePutCallback( int thread_id, int request_id, const scoped_refptr<CacheStorageCache>& cache, - CacheStorageCache::ErrorType error, - scoped_ptr<ServiceWorkerResponse> response, - scoped_ptr<storage::BlobDataHandle> blob_data_handle) { + CacheStorageCache::ErrorType error) { if (error != CacheStorageCache::ERROR_TYPE_OK) { Send(new CacheStorageMsg_CacheBatchError( thread_id, request_id, CacheErrorToWebServiceWorkerCacheError(error))); return; } - if (blob_data_handle) - StoreBlobDataHandle(blob_data_handle.Pass()); - - std::vector<ServiceWorkerResponse> responses; - responses.push_back(*response); - Send(new CacheStorageMsg_CacheBatchSuccess(thread_id, request_id, responses)); + Send(new CacheStorageMsg_CacheBatchSuccess(thread_id, request_id)); } CacheStorageDispatcherHost::CacheID diff --git a/content/browser/cache_storage/cache_storage_dispatcher_host.h b/content/browser/cache_storage/cache_storage_dispatcher_host.h index 7d3833a..36a9d39 100644 --- a/content/browser/cache_storage/cache_storage_dispatcher_host.h +++ b/content/browser/cache_storage/cache_storage_dispatcher_host.h @@ -130,9 +130,7 @@ class CONTENT_EXPORT CacheStorageDispatcherHost : public BrowserMessageFilter { void OnCachePutCallback(int thread_id, int request_id, const scoped_refptr<CacheStorageCache>& cache, - CacheStorageCache::ErrorType error, - scoped_ptr<ServiceWorkerResponse> response, - scoped_ptr<storage::BlobDataHandle> blob_data_handle); + CacheStorageCache::ErrorType error); // Hangs onto a scoped_refptr for the cache if it isn't already doing so. // Returns a unique cache_id. Call DropCacheReference when the client is done diff --git a/content/browser/cache_storage/cache_storage_manager_unittest.cc b/content/browser/cache_storage/cache_storage_manager_unittest.cc index 6bd7914..5c40251 100644 --- a/content/browser/cache_storage/cache_storage_manager_unittest.cc +++ b/content/browser/cache_storage/cache_storage_manager_unittest.cc @@ -91,9 +91,7 @@ class CacheStorageManagerTest : public testing::Test { } void CachePutCallback(base::RunLoop* run_loop, - CacheStorageCache::ErrorType error, - scoped_ptr<ServiceWorkerResponse> response, - scoped_ptr<storage::BlobDataHandle> blob_data_handle) { + CacheStorageCache::ErrorType error) { callback_cache_error_ = error; run_loop->Quit(); } diff --git a/content/common/cache_storage/cache_storage_messages.h b/content/common/cache_storage/cache_storage_messages.h index 6402d0f..dc1de3c 100644 --- a/content/common/cache_storage/cache_storage_messages.h +++ b/content/common/cache_storage/cache_storage_messages.h @@ -174,10 +174,9 @@ IPC_MESSAGE_CONTROL3(CacheStorageMsg_CacheKeysSuccess, int /* thread_id */, int /* request_id */, std::vector<content::ServiceWorkerFetchRequest>) -IPC_MESSAGE_CONTROL3(CacheStorageMsg_CacheBatchSuccess, +IPC_MESSAGE_CONTROL2(CacheStorageMsg_CacheBatchSuccess, int /* thread_id */, - int /* request_id */, - std::vector<content::ServiceWorkerResponse>) + int /* request_id */) // Sent at erroneous completion of CacheStorage operations. IPC_MESSAGE_CONTROL3(CacheStorageMsg_CacheMatchError, diff --git a/content/renderer/cache_storage/cache_storage_dispatcher.cc b/content/renderer/cache_storage/cache_storage_dispatcher.cc index 3bd974f..da40cbf 100644 --- a/content/renderer/cache_storage/cache_storage_dispatcher.cc +++ b/content/renderer/cache_storage/cache_storage_dispatcher.cc @@ -461,11 +461,8 @@ void CacheStorageDispatcher::OnCacheKeysSuccess( void CacheStorageDispatcher::OnCacheBatchSuccess( int thread_id, - int request_id, - const std::vector<ServiceWorkerResponse>& responses) { + int request_id) { DCHECK_EQ(thread_id, CurrentWorkerId()); - blink::WebVector<blink::WebServiceWorkerResponse> web_responses = - WebResponsesFromResponses(responses); UMA_HISTOGRAM_TIMES("ServiceWorkerCache.Cache.Batch", TimeTicks::Now() - cache_batch_times_[request_id]); diff --git a/content/renderer/cache_storage/cache_storage_dispatcher.h b/content/renderer/cache_storage/cache_storage_dispatcher.h index 3db1e5a..de46d58 100644 --- a/content/renderer/cache_storage/cache_storage_dispatcher.h +++ b/content/renderer/cache_storage/cache_storage_dispatcher.h @@ -84,8 +84,7 @@ class CacheStorageDispatcher : public WorkerTaskRunner::Observer { int request_id, const std::vector<ServiceWorkerFetchRequest>& response); void OnCacheBatchSuccess(int thread_id, - int request_id, - const std::vector<ServiceWorkerResponse>& response); + int request_id); void OnCacheMatchError(int thread_id, int request_id, |