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

Side by Side Diff: content/browser/service_worker/service_worker_cache_unittest.cc

Issue 810403004: [Storage] Blob Storage Refactoring pt 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Snapshots now created by the Handle, one more rename Created 5 years, 11 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/service_worker/service_worker_cache.h" 5 #include "content/browser/service_worker/service_worker_cache.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 ServiceWorkerFetchRequest(GURL("http://example.com/no_body.html"), 220 ServiceWorkerFetchRequest(GURL("http://example.com/no_body.html"),
221 "GET", 221 "GET",
222 headers, 222 headers,
223 GURL(), 223 GURL(),
224 false); 224 false);
225 225
226 std::string expected_response; 226 std::string expected_response;
227 for (int i = 0; i < 100; ++i) 227 for (int i = 0; i < 100; ++i)
228 expected_blob_data_ += kTestData; 228 expected_blob_data_ += kTestData;
229 229
230 scoped_refptr<storage::BlobData> blob_data( 230 scoped_ptr<storage::BlobDataBuilder> blob_data(
231 new storage::BlobData("blob-id:myblob")); 231 new storage::BlobDataBuilder("blob-id:myblob"));
232 blob_data->AppendData(expected_blob_data_); 232 blob_data->AppendData(expected_blob_data_);
233 233
234 blob_handle_ = 234 blob_handle_ =
235 blob_storage_context->context()->AddFinishedBlob(blob_data.get()); 235 blob_storage_context->context()->AddFinishedBlob(*blob_data.get());
236 236
237 body_response_ = 237 body_response_ =
238 ServiceWorkerResponse(GURL("http://example.com/body.html"), 238 ServiceWorkerResponse(GURL("http://example.com/body.html"),
239 200, 239 200,
240 "OK", 240 "OK",
241 blink::WebServiceWorkerResponseTypeDefault, 241 blink::WebServiceWorkerResponseTypeDefault,
242 headers, 242 headers,
243 blob_handle_->uuid(), 243 blob_handle_->uuid(),
244 expected_blob_data_.size(), 244 expected_blob_data_.size(),
245 GURL()); 245 GURL());
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 } 378 }
379 379
380 void CloseCallback(base::RunLoop* run_loop) { 380 void CloseCallback(base::RunLoop* run_loop) {
381 EXPECT_FALSE(callback_closed_); 381 EXPECT_FALSE(callback_closed_);
382 callback_closed_ = true; 382 callback_closed_ = true;
383 if (run_loop) 383 if (run_loop)
384 run_loop->Quit(); 384 run_loop->Quit();
385 } 385 }
386 386
387 void CopyBody(storage::BlobDataHandle* blob_handle, std::string* output) { 387 void CopyBody(storage::BlobDataHandle* blob_handle, std::string* output) {
388 storage::BlobData* data = blob_handle->data(); 388 scoped_ptr<storage::BlobDataSnapshot> data = blob_handle->CreateSnapshot();
389 std::vector<storage::BlobData::Item> items = data->items(); 389 const auto& items = data->items();
390 for (size_t i = 0, max = items.size(); i < max; ++i) 390 for (const auto& item : items) {
391 output->append(items[i].bytes(), items[i].length()); 391 output->append(item->bytes(), item->length());
392 }
392 } 393 }
393 394
394 bool VerifyKeys(const std::vector<std::string>& expected_keys) { 395 bool VerifyKeys(const std::vector<std::string>& expected_keys) {
395 if (expected_keys.size() != callback_strings_.size()) 396 if (expected_keys.size() != callback_strings_.size())
396 return false; 397 return false;
397 398
398 std::set<std::string> found_set; 399 std::set<std::string> found_set;
399 for (int i = 0, max = callback_strings_.size(); i < max; ++i) 400 for (int i = 0, max = callback_strings_.size(); i < max; ++i)
400 found_set.insert(callback_strings_[i]); 401 found_set.insert(callback_strings_[i]);
401 402
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 EXPECT_TRUE(callback_closed_); 907 EXPECT_TRUE(callback_closed_);
907 908
908 VerifyAllOpsFail(); 909 VerifyAllOpsFail();
909 } 910 }
910 911
911 INSTANTIATE_TEST_CASE_P(ServiceWorkerCacheTest, 912 INSTANTIATE_TEST_CASE_P(ServiceWorkerCacheTest,
912 ServiceWorkerCacheTestP, 913 ServiceWorkerCacheTestP,
913 ::testing::Values(false, true)); 914 ::testing::Values(false, true));
914 915
915 } // namespace content 916 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698