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

Side by Side Diff: content/browser/cache_storage/cache_storage_cache_unittest.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 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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } 78 }
79 79
80 int CreateEntry(const std::string& key, 80 int CreateEntry(const std::string& key,
81 disk_cache::Entry** entry, 81 disk_cache::Entry** entry,
82 const CompletionCallback& callback) override { 82 const CompletionCallback& callback) override {
83 return backend_->CreateEntry(key, entry, callback); 83 return backend_->CreateEntry(key, entry, callback);
84 } 84 }
85 int DoomEntry(const std::string& key, 85 int DoomEntry(const std::string& key,
86 const CompletionCallback& callback) override { 86 const CompletionCallback& callback) override {
87 if (delay_doom_) { 87 if (delay_doom_) {
88 doom_entry_callback_ = base::Bind(&DelayableBackend::DoomEntryDelayedImpl, 88 doom_entry_callback_ =
89 base::Unretained(this), key, callback); 89 base::BindOnce(&DelayableBackend::DoomEntryDelayedImpl,
90 base::Unretained(this), key, callback);
90 return net::ERR_IO_PENDING; 91 return net::ERR_IO_PENDING;
91 } 92 }
92 93
93 return backend_->DoomEntry(key, callback); 94 return backend_->DoomEntry(key, callback);
94 } 95 }
95 int DoomAllEntries(const CompletionCallback& callback) override { 96 int DoomAllEntries(const CompletionCallback& callback) override {
96 return backend_->DoomAllEntries(callback); 97 return backend_->DoomAllEntries(callback);
97 } 98 }
98 int DoomEntriesBetween(base::Time initial_time, 99 int DoomEntriesBetween(base::Time initial_time,
99 base::Time end_time, 100 base::Time end_time,
(...skipping 21 matching lines...) Expand all
121 size_t DumpMemoryStats( 122 size_t DumpMemoryStats(
122 base::trace_event::ProcessMemoryDump* pmd, 123 base::trace_event::ProcessMemoryDump* pmd,
123 const std::string& parent_absolute_name) const override { 124 const std::string& parent_absolute_name) const override {
124 NOTREACHED(); 125 NOTREACHED();
125 return 0u; 126 return 0u;
126 } 127 }
127 128
128 // Call to continue a delayed doom. 129 // Call to continue a delayed doom.
129 void DoomEntryContinue() { 130 void DoomEntryContinue() {
130 EXPECT_FALSE(doom_entry_callback_.is_null()); 131 EXPECT_FALSE(doom_entry_callback_.is_null());
131 doom_entry_callback_.Run(); 132 std::move(doom_entry_callback_).Run();
132 } 133 }
133 134
134 void set_delay_doom(bool value) { delay_doom_ = value; } 135 void set_delay_doom(bool value) { delay_doom_ = value; }
135 136
136 private: 137 private:
137 void DoomEntryDelayedImpl(const std::string& key, 138 void DoomEntryDelayedImpl(const std::string& key,
138 const CompletionCallback& callback) { 139 const CompletionCallback& callback) {
139 int rv = backend_->DoomEntry(key, callback); 140 int rv = backend_->DoomEntry(key, callback);
140 if (rv != net::ERR_IO_PENDING) 141 if (rv != net::ERR_IO_PENDING)
141 callback.Run(rv); 142 callback.Run(rv);
142 } 143 }
143 144
144 std::unique_ptr<disk_cache::Backend> backend_; 145 std::unique_ptr<disk_cache::Backend> backend_;
145 bool delay_doom_; 146 bool delay_doom_;
146 base::Closure doom_entry_callback_; 147 base::OnceClosure doom_entry_callback_;
147 }; 148 };
148 149
149 void CopyBody(const storage::BlobDataHandle& blob_handle, std::string* output) { 150 void CopyBody(const storage::BlobDataHandle& blob_handle, std::string* output) {
150 *output = std::string(); 151 *output = std::string();
151 std::unique_ptr<storage::BlobDataSnapshot> data = 152 std::unique_ptr<storage::BlobDataSnapshot> data =
152 blob_handle.CreateSnapshot(); 153 blob_handle.CreateSnapshot();
153 const auto& items = data->items(); 154 const auto& items = data->items();
154 for (const auto& item : items) { 155 for (const auto& item : items) {
155 switch (item->type()) { 156 switch (item->type()) {
156 case storage::DataElement::TYPE_BYTES: { 157 case storage::DataElement::TYPE_BYTES: {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 : CacheStorageCache(origin, 287 : CacheStorageCache(origin,
287 cache_name, 288 cache_name,
288 path, 289 path,
289 cache_storage, 290 cache_storage,
290 request_context_getter, 291 request_context_getter,
291 quota_manager_proxy, 292 quota_manager_proxy,
292 blob_context, 293 blob_context,
293 0 /* cache_size */), 294 0 /* cache_size */),
294 delay_backend_creation_(false) {} 295 delay_backend_creation_(false) {}
295 296
296 void CreateBackend(const ErrorCallback& callback) override { 297 void CreateBackend(ErrorCallback callback) override {
297 backend_creation_callback_ = callback; 298 backend_creation_callback_ = std::move(callback);
298 if (delay_backend_creation_) 299 if (delay_backend_creation_)
299 return; 300 return;
300 ContinueCreateBackend(); 301 ContinueCreateBackend();
301 } 302 }
302 303
303 void ContinueCreateBackend() { 304 void ContinueCreateBackend() {
304 CacheStorageCache::CreateBackend(backend_creation_callback_); 305 CacheStorageCache::CreateBackend(std::move(backend_creation_callback_));
305 } 306 }
306 307
307 void set_delay_backend_creation(bool delay) { 308 void set_delay_backend_creation(bool delay) {
308 delay_backend_creation_ = delay; 309 delay_backend_creation_ = delay;
309 } 310 }
310 311
311 // Swap the existing backend with a delayable one. The backend must have been 312 // Swap the existing backend with a delayable one. The backend must have been
312 // created before calling this. 313 // created before calling this.
313 DelayableBackend* UseDelayableBackend() { 314 DelayableBackend* UseDelayableBackend() {
314 EXPECT_TRUE(backend_); 315 EXPECT_TRUE(backend_);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 request.url, request.method, request.headers, request.referrer, 458 request.url, request.method, request.headers, request.referrer,
458 request.is_reload); 459 request.is_reload);
459 } 460 }
460 461
461 CacheStorageError BatchOperation( 462 CacheStorageError BatchOperation(
462 const std::vector<CacheStorageBatchOperation>& operations) { 463 const std::vector<CacheStorageBatchOperation>& operations) {
463 std::unique_ptr<base::RunLoop> loop(new base::RunLoop()); 464 std::unique_ptr<base::RunLoop> loop(new base::RunLoop());
464 465
465 cache_->BatchOperation( 466 cache_->BatchOperation(
466 operations, 467 operations,
467 base::Bind(&CacheStorageCacheTest::ErrorTypeCallback, 468 base::BindOnce(&CacheStorageCacheTest::ErrorTypeCallback,
468 base::Unretained(this), base::Unretained(loop.get()))); 469 base::Unretained(this), base::Unretained(loop.get())));
469 // TODO(jkarlin): These functions should use base::RunLoop().RunUntilIdle() 470 // TODO(jkarlin): These functions should use base::RunLoop().RunUntilIdle()
470 // once the cache uses a passed in task runner instead of the CACHE thread. 471 // once the cache uses a passed in task runner instead of the CACHE thread.
471 loop->Run(); 472 loop->Run();
472 473
473 return callback_error_; 474 return callback_error_;
474 } 475 }
475 476
476 bool Put(const ServiceWorkerFetchRequest& request, 477 bool Put(const ServiceWorkerFetchRequest& request,
477 const ServiceWorkerResponse& response) { 478 const ServiceWorkerResponse& response) {
478 CacheStorageBatchOperation operation; 479 CacheStorageBatchOperation operation;
479 operation.operation_type = CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT; 480 operation.operation_type = CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT;
480 operation.request = request; 481 operation.request = request;
481 operation.response = response; 482 operation.response = response;
482 483
483 CacheStorageError error = 484 CacheStorageError error =
484 BatchOperation(std::vector<CacheStorageBatchOperation>(1, operation)); 485 BatchOperation(std::vector<CacheStorageBatchOperation>(1, operation));
485 return error == CACHE_STORAGE_OK; 486 return error == CACHE_STORAGE_OK;
486 } 487 }
487 488
488 bool Match(const ServiceWorkerFetchRequest& request, 489 bool Match(const ServiceWorkerFetchRequest& request,
489 const CacheStorageCacheQueryParams& match_params = 490 const CacheStorageCacheQueryParams& match_params =
490 CacheStorageCacheQueryParams()) { 491 CacheStorageCacheQueryParams()) {
491 std::unique_ptr<base::RunLoop> loop(new base::RunLoop()); 492 std::unique_ptr<base::RunLoop> loop(new base::RunLoop());
492 493
493 cache_->Match( 494 cache_->Match(
494 CopyFetchRequest(request), match_params, 495 CopyFetchRequest(request), match_params,
495 base::Bind(&CacheStorageCacheTest::ResponseAndErrorCallback, 496 base::BindOnce(&CacheStorageCacheTest::ResponseAndErrorCallback,
496 base::Unretained(this), base::Unretained(loop.get()))); 497 base::Unretained(this), base::Unretained(loop.get())));
497 loop->Run(); 498 loop->Run();
498 499
499 return callback_error_ == CACHE_STORAGE_OK; 500 return callback_error_ == CACHE_STORAGE_OK;
500 } 501 }
501 502
502 bool MatchAll( 503 bool MatchAll(
503 const ServiceWorkerFetchRequest& request, 504 const ServiceWorkerFetchRequest& request,
504 const CacheStorageCacheQueryParams& match_params, 505 const CacheStorageCacheQueryParams& match_params,
505 std::unique_ptr<CacheStorageCache::Responses>* responses, 506 std::unique_ptr<CacheStorageCache::Responses>* responses,
506 std::unique_ptr<CacheStorageCache::BlobDataHandles>* body_handles) { 507 std::unique_ptr<CacheStorageCache::BlobDataHandles>* body_handles) {
507 base::RunLoop loop; 508 base::RunLoop loop;
508 cache_->MatchAll( 509 cache_->MatchAll(
509 CopyFetchRequest(request), match_params, 510 CopyFetchRequest(request), match_params,
510 base::Bind(&CacheStorageCacheTest::ResponsesAndErrorCallback, 511 base::BindOnce(&CacheStorageCacheTest::ResponsesAndErrorCallback,
511 base::Unretained(this), loop.QuitClosure(), responses, 512 base::Unretained(this), loop.QuitClosure(), responses,
512 body_handles)); 513 body_handles));
513 loop.Run(); 514 loop.Run();
514 return callback_error_ == CACHE_STORAGE_OK; 515 return callback_error_ == CACHE_STORAGE_OK;
515 } 516 }
516 517
517 bool MatchAll( 518 bool MatchAll(
518 std::unique_ptr<CacheStorageCache::Responses>* responses, 519 std::unique_ptr<CacheStorageCache::Responses>* responses,
519 std::unique_ptr<CacheStorageCache::BlobDataHandles>* body_handles) { 520 std::unique_ptr<CacheStorageCache::BlobDataHandles>* body_handles) {
520 return MatchAll(ServiceWorkerFetchRequest(), CacheStorageCacheQueryParams(), 521 return MatchAll(ServiceWorkerFetchRequest(), CacheStorageCacheQueryParams(),
521 responses, body_handles); 522 responses, body_handles);
522 } 523 }
(...skipping 12 matching lines...) Expand all
535 } 536 }
536 537
537 bool Keys( 538 bool Keys(
538 const ServiceWorkerFetchRequest& request = ServiceWorkerFetchRequest(), 539 const ServiceWorkerFetchRequest& request = ServiceWorkerFetchRequest(),
539 const CacheStorageCacheQueryParams& match_params = 540 const CacheStorageCacheQueryParams& match_params =
540 CacheStorageCacheQueryParams()) { 541 CacheStorageCacheQueryParams()) {
541 std::unique_ptr<base::RunLoop> loop(new base::RunLoop()); 542 std::unique_ptr<base::RunLoop> loop(new base::RunLoop());
542 543
543 cache_->Keys( 544 cache_->Keys(
544 CopyFetchRequest(request), match_params, 545 CopyFetchRequest(request), match_params,
545 base::Bind(&CacheStorageCacheTest::RequestsCallback, 546 base::BindOnce(&CacheStorageCacheTest::RequestsCallback,
546 base::Unretained(this), base::Unretained(loop.get()))); 547 base::Unretained(this), base::Unretained(loop.get())));
547 loop->Run(); 548 loop->Run();
548 549
549 return callback_error_ == CACHE_STORAGE_OK; 550 return callback_error_ == CACHE_STORAGE_OK;
550 } 551 }
551 552
552 bool Close() { 553 bool Close() {
553 std::unique_ptr<base::RunLoop> loop(new base::RunLoop()); 554 std::unique_ptr<base::RunLoop> loop(new base::RunLoop());
554 555
555 cache_->Close(base::Bind(&CacheStorageCacheTest::CloseCallback, 556 cache_->Close(base::BindOnce(&CacheStorageCacheTest::CloseCallback,
556 base::Unretained(this), 557 base::Unretained(this),
557 base::Unretained(loop.get()))); 558 base::Unretained(loop.get())));
558 loop->Run(); 559 loop->Run();
559 return callback_closed_; 560 return callback_closed_;
560 } 561 }
561 562
562 bool WriteSideData(const GURL& url, 563 bool WriteSideData(const GURL& url,
563 base::Time expected_response_time, 564 base::Time expected_response_time,
564 scoped_refptr<net::IOBuffer> buffer, 565 scoped_refptr<net::IOBuffer> buffer,
565 int buf_len) { 566 int buf_len) {
566 base::RunLoop run_loop; 567 base::RunLoop run_loop;
567 cache_->WriteSideData( 568 cache_->WriteSideData(
568 base::Bind(&CacheStorageCacheTest::ErrorTypeCallback, 569 base::BindOnce(&CacheStorageCacheTest::ErrorTypeCallback,
569 base::Unretained(this), base::Unretained(&run_loop)), 570 base::Unretained(this), base::Unretained(&run_loop)),
570 url, expected_response_time, buffer, buf_len); 571 url, expected_response_time, buffer, buf_len);
571 run_loop.Run(); 572 run_loop.Run();
572 573
573 return callback_error_ == CACHE_STORAGE_OK; 574 return callback_error_ == CACHE_STORAGE_OK;
574 } 575 }
575 576
576 int64_t Size() { 577 int64_t Size() {
577 // Storage notification happens after an operation completes. Let the any 578 // Storage notification happens after an operation completes. Let the any
578 // notifications complete before calling Size. 579 // notifications complete before calling Size.
579 base::RunLoop().RunUntilIdle(); 580 base::RunLoop().RunUntilIdle();
580 581
581 base::RunLoop run_loop; 582 base::RunLoop run_loop;
582 bool callback_called = false; 583 bool callback_called = false;
583 cache_->Size(base::Bind(&CacheStorageCacheTest::SizeCallback, 584 cache_->Size(base::BindOnce(&CacheStorageCacheTest::SizeCallback,
584 base::Unretained(this), &run_loop, 585 base::Unretained(this), &run_loop,
585 &callback_called)); 586 &callback_called));
586 run_loop.Run(); 587 run_loop.Run();
587 EXPECT_TRUE(callback_called); 588 EXPECT_TRUE(callback_called);
588 return callback_size_; 589 return callback_size_;
589 } 590 }
590 591
591 int64_t GetSizeThenClose() { 592 int64_t GetSizeThenClose() {
592 base::RunLoop run_loop; 593 base::RunLoop run_loop;
593 bool callback_called = false; 594 bool callback_called = false;
594 cache_->GetSizeThenClose(base::Bind(&CacheStorageCacheTest::SizeCallback, 595 cache_->GetSizeThenClose(
595 base::Unretained(this), &run_loop, 596 base::BindOnce(&CacheStorageCacheTest::SizeCallback,
596 &callback_called)); 597 base::Unretained(this), &run_loop, &callback_called));
597 run_loop.Run(); 598 run_loop.Run();
598 EXPECT_TRUE(callback_called); 599 EXPECT_TRUE(callback_called);
599 return callback_size_; 600 return callback_size_;
600 } 601 }
601 602
602 void RequestsCallback(base::RunLoop* run_loop, 603 void RequestsCallback(base::RunLoop* run_loop,
603 CacheStorageError error, 604 CacheStorageError error,
604 std::unique_ptr<CacheStorageCache::Requests> requests) { 605 std::unique_ptr<CacheStorageCache::Requests> requests) {
605 callback_error_ = error; 606 callback_error_ = error;
606 callback_strings_.clear(); 607 callback_strings_.clear();
(...skipping 30 matching lines...) Expand all
637 callback_response_ = std::move(response); 638 callback_response_ = std::move(response);
638 callback_response_data_.reset(); 639 callback_response_data_.reset();
639 if (error == CACHE_STORAGE_OK && !callback_response_->blob_uuid.empty()) 640 if (error == CACHE_STORAGE_OK && !callback_response_->blob_uuid.empty())
640 callback_response_data_ = std::move(body_handle); 641 callback_response_data_ = std::move(body_handle);
641 642
642 if (run_loop) 643 if (run_loop)
643 run_loop->Quit(); 644 run_loop->Quit();
644 } 645 }
645 646
646 void ResponsesAndErrorCallback( 647 void ResponsesAndErrorCallback(
647 const base::Closure& quit_closure, 648 base::OnceClosure quit_closure,
648 std::unique_ptr<CacheStorageCache::Responses>* responses_out, 649 std::unique_ptr<CacheStorageCache::Responses>* responses_out,
649 std::unique_ptr<CacheStorageCache::BlobDataHandles>* body_handles_out, 650 std::unique_ptr<CacheStorageCache::BlobDataHandles>* body_handles_out,
650 CacheStorageError error, 651 CacheStorageError error,
651 std::unique_ptr<CacheStorageCache::Responses> responses, 652 std::unique_ptr<CacheStorageCache::Responses> responses,
652 std::unique_ptr<CacheStorageCache::BlobDataHandles> body_handles) { 653 std::unique_ptr<CacheStorageCache::BlobDataHandles> body_handles) {
653 callback_error_ = error; 654 callback_error_ = error;
654 responses_out->swap(responses); 655 responses_out->swap(responses);
655 body_handles_out->swap(body_handles); 656 body_handles_out->swap(body_handles);
656 quit_closure.Run(); 657 std::move(quit_closure).Run();
657 } 658 }
658 659
659 void CloseCallback(base::RunLoop* run_loop) { 660 void CloseCallback(base::RunLoop* run_loop) {
660 EXPECT_FALSE(callback_closed_); 661 EXPECT_FALSE(callback_closed_);
661 callback_closed_ = true; 662 callback_closed_ = true;
662 if (run_loop) 663 if (run_loop)
663 run_loop->Quit(); 664 run_loop->Quit();
664 } 665 }
665 666
666 void SizeCallback(base::RunLoop* run_loop, 667 void SizeCallback(base::RunLoop* run_loop,
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 860
860 TEST_F(CacheStorageCacheTest, PutBodyDropBlobRef) { 861 TEST_F(CacheStorageCacheTest, PutBodyDropBlobRef) {
861 CacheStorageBatchOperation operation; 862 CacheStorageBatchOperation operation;
862 operation.operation_type = CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT; 863 operation.operation_type = CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT;
863 operation.request = body_request_; 864 operation.request = body_request_;
864 operation.response = body_response_; 865 operation.response = body_response_;
865 866
866 std::unique_ptr<base::RunLoop> loop(new base::RunLoop()); 867 std::unique_ptr<base::RunLoop> loop(new base::RunLoop());
867 cache_->BatchOperation( 868 cache_->BatchOperation(
868 std::vector<CacheStorageBatchOperation>(1, operation), 869 std::vector<CacheStorageBatchOperation>(1, operation),
869 base::Bind(&CacheStorageCacheTestP::ErrorTypeCallback, 870 base::BindOnce(&CacheStorageCacheTestP::ErrorTypeCallback,
870 base::Unretained(this), base::Unretained(loop.get()))); 871 base::Unretained(this), base::Unretained(loop.get())));
871 // The handle should be held by the cache now so the deref here should be 872 // The handle should be held by the cache now so the deref here should be
872 // okay. 873 // okay.
873 blob_handle_.reset(); 874 blob_handle_.reset();
874 loop->Run(); 875 loop->Run();
875 876
876 EXPECT_EQ(CACHE_STORAGE_OK, callback_error_); 877 EXPECT_EQ(CACHE_STORAGE_OK, callback_error_);
877 } 878 }
878 879
879 TEST_P(CacheStorageCacheTestP, PutReplace) { 880 TEST_P(CacheStorageCacheTestP, PutReplace) {
880 EXPECT_TRUE(Put(body_request_, no_body_response_)); 881 EXPECT_TRUE(Put(body_request_, no_body_response_));
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
1618 int sequence_out = -1; 1619 int sequence_out = -1;
1619 1620
1620 CacheStorageBatchOperation operation1; 1621 CacheStorageBatchOperation operation1;
1621 operation1.operation_type = CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT; 1622 operation1.operation_type = CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT;
1622 operation1.request = body_request_; 1623 operation1.request = body_request_;
1623 operation1.response = body_response_; 1624 operation1.response = body_response_;
1624 1625
1625 std::unique_ptr<base::RunLoop> close_loop1(new base::RunLoop()); 1626 std::unique_ptr<base::RunLoop> close_loop1(new base::RunLoop());
1626 cache_->BatchOperation( 1627 cache_->BatchOperation(
1627 std::vector<CacheStorageBatchOperation>(1, operation1), 1628 std::vector<CacheStorageBatchOperation>(1, operation1),
1628 base::Bind(&CacheStorageCacheTest::SequenceCallback, 1629 base::BindOnce(&CacheStorageCacheTest::SequenceCallback,
1629 base::Unretained(this), 1, &sequence_out, close_loop1.get())); 1630 base::Unretained(this), 1, &sequence_out,
1631 close_loop1.get()));
1630 1632
1631 // Blocks on creating the cache entry. 1633 // Blocks on creating the cache entry.
1632 base::RunLoop().RunUntilIdle(); 1634 base::RunLoop().RunUntilIdle();
1633 1635
1634 CacheStorageBatchOperation operation2; 1636 CacheStorageBatchOperation operation2;
1635 operation2.operation_type = CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT; 1637 operation2.operation_type = CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT;
1636 operation2.request = body_request_; 1638 operation2.request = body_request_;
1637 operation2.response = body_response_; 1639 operation2.response = body_response_;
1638 1640
1639 delayable_backend->set_delay_doom(false); 1641 delayable_backend->set_delay_doom(false);
1640 std::unique_ptr<base::RunLoop> close_loop2(new base::RunLoop()); 1642 std::unique_ptr<base::RunLoop> close_loop2(new base::RunLoop());
1641 cache_->BatchOperation( 1643 cache_->BatchOperation(
1642 std::vector<CacheStorageBatchOperation>(1, operation2), 1644 std::vector<CacheStorageBatchOperation>(1, operation2),
1643 base::Bind(&CacheStorageCacheTest::SequenceCallback, 1645 base::BindOnce(&CacheStorageCacheTest::SequenceCallback,
1644 base::Unretained(this), 2, &sequence_out, close_loop2.get())); 1646 base::Unretained(this), 2, &sequence_out,
1647 close_loop2.get()));
1645 1648
1646 // The second put operation should wait for the first to complete. 1649 // The second put operation should wait for the first to complete.
1647 base::RunLoop().RunUntilIdle(); 1650 base::RunLoop().RunUntilIdle();
1648 EXPECT_FALSE(callback_response_); 1651 EXPECT_FALSE(callback_response_);
1649 1652
1650 delayable_backend->DoomEntryContinue(); 1653 delayable_backend->DoomEntryContinue();
1651 close_loop1->Run(); 1654 close_loop1->Run();
1652 EXPECT_EQ(1, sequence_out); 1655 EXPECT_EQ(1, sequence_out);
1653 close_loop2->Run(); 1656 close_loop2->Run();
1654 EXPECT_EQ(2, sequence_out); 1657 EXPECT_EQ(2, sequence_out);
1655 } 1658 }
1656 1659
1657 INSTANTIATE_TEST_CASE_P(CacheStorageCacheTest, 1660 INSTANTIATE_TEST_CASE_P(CacheStorageCacheTest,
1658 CacheStorageCacheTestP, 1661 CacheStorageCacheTestP,
1659 ::testing::Values(false, true)); 1662 ::testing::Values(false, true));
1660 1663
1661 } // namespace content 1664 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698