Index: content/browser/cache_storage/cache_storage_cache_unittest.cc |
diff --git a/content/browser/cache_storage/cache_storage_cache_unittest.cc b/content/browser/cache_storage/cache_storage_cache_unittest.cc |
index 3da11ec97fe250445b9e41bccc00bbfcc145d481..e5772b0e1a035a4f10609d3f851b886e5c1de5e0 100644 |
--- a/content/browser/cache_storage/cache_storage_cache_unittest.cc |
+++ b/content/browser/cache_storage/cache_storage_cache_unittest.cc |
@@ -252,21 +252,17 @@ class CacheStorageCacheTest : public testing::Test { |
request.is_reload)); |
} |
- scoped_ptr<ServiceWorkerResponse> CopyFetchResponse( |
- const ServiceWorkerResponse& response) { |
- scoped_ptr<ServiceWorkerResponse> sw_response(new ServiceWorkerResponse( |
- response.url, response.status_code, response.status_text, |
- response.response_type, response.headers, response.blob_uuid, |
- response.blob_size, response.stream_url)); |
- return sw_response.Pass(); |
- } |
- |
bool Put(const ServiceWorkerFetchRequest& request, |
const ServiceWorkerResponse& response) { |
+ CacheStorageBatchOperation operation; |
+ operation.operation_type = CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT; |
+ operation.request = request; |
+ operation.response = response; |
+ |
scoped_ptr<base::RunLoop> loop(new base::RunLoop()); |
- cache_->Put( |
- CopyFetchRequest(request), CopyFetchResponse(response), |
+ cache_->BatchOperation( |
+ std::vector<CacheStorageBatchOperation>(1, operation), |
base::Bind(&CacheStorageCacheTest::ErrorTypeCallback, |
base::Unretained(this), base::Unretained(loop.get()))); |
// TODO(jkarlin): These functions should use base::RunLoop().RunUntilIdle() |
@@ -290,10 +286,14 @@ class CacheStorageCacheTest : public testing::Test { |
} |
bool Delete(const ServiceWorkerFetchRequest& request) { |
+ CacheStorageBatchOperation operation; |
+ operation.operation_type = CACHE_STORAGE_CACHE_OPERATION_TYPE_DELETE; |
+ operation.request = request; |
+ |
scoped_ptr<base::RunLoop> loop(new base::RunLoop()); |
- cache_->Delete( |
- CopyFetchRequest(request), |
+ cache_->BatchOperation( |
+ std::vector<CacheStorageBatchOperation>(1, operation), |
base::Bind(&CacheStorageCacheTest::ErrorTypeCallback, |
base::Unretained(this), base::Unretained(loop.get()))); |
loop->Run(); |
@@ -478,11 +478,16 @@ TEST_P(CacheStorageCacheTestP, ResponseURLEmpty) { |
} |
TEST_F(CacheStorageCacheTest, PutBodyDropBlobRef) { |
+ CacheStorageBatchOperation operation; |
+ operation.operation_type = CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT; |
+ operation.request = body_request_; |
+ operation.response = body_response_; |
+ |
scoped_ptr<base::RunLoop> loop(new base::RunLoop()); |
- cache_->Put(CopyFetchRequest(body_request_), |
- CopyFetchResponse(body_response_), |
- base::Bind(&CacheStorageCacheTestP::ErrorTypeCallback, |
- base::Unretained(this), base::Unretained(loop.get()))); |
+ cache_->BatchOperation( |
+ std::vector<CacheStorageBatchOperation>(1, operation), |
+ 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. |
blob_handle_.reset(); |
@@ -764,23 +769,29 @@ TEST_P(CacheStorageCacheTestP, VerifySerialScheduling) { |
int sequence_out = -1; |
- scoped_ptr<ServiceWorkerResponse> response1 = |
- CopyFetchResponse(body_response_); |
+ CacheStorageBatchOperation operation1; |
+ operation1.operation_type = CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT; |
+ operation1.request = body_request_; |
+ operation1.response = body_response_; |
+ |
scoped_ptr<base::RunLoop> close_loop1(new base::RunLoop()); |
- cache_->Put( |
- CopyFetchRequest(body_request_), response1.Pass(), |
+ cache_->BatchOperation( |
+ std::vector<CacheStorageBatchOperation>(1, operation1), |
base::Bind(&CacheStorageCacheTest::SequenceCallback, |
base::Unretained(this), 1, &sequence_out, close_loop1.get())); |
// Blocks on opening the cache entry. |
base::RunLoop().RunUntilIdle(); |
+ CacheStorageBatchOperation operation2; |
+ operation2.operation_type = CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT; |
+ operation2.request = body_request_; |
+ operation2.response = body_response_; |
+ |
delayable_backend->set_delay_open(false); |
- scoped_ptr<ServiceWorkerResponse> response2 = |
- CopyFetchResponse(body_response_); |
scoped_ptr<base::RunLoop> close_loop2(new base::RunLoop()); |
- cache_->Put( |
- CopyFetchRequest(body_request_), response2.Pass(), |
+ cache_->BatchOperation( |
+ std::vector<CacheStorageBatchOperation>(1, operation2), |
base::Bind(&CacheStorageCacheTest::SequenceCallback, |
base::Unretained(this), 2, &sequence_out, close_loop2.get())); |