OLD | NEW |
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 // The FileSystemContext and thread task runner are not actually used but a | 56 // The FileSystemContext and thread task runner are not actually used but a |
57 // task runner is needed to avoid a DCHECK in BlobURLRequestJob ctor. | 57 // task runner is needed to avoid a DCHECK in BlobURLRequestJob ctor. |
58 return base::WrapUnique(new storage::BlobProtocolHandler( | 58 return base::WrapUnique(new storage::BlobProtocolHandler( |
59 blob_storage_context, NULL, base::ThreadTaskRunnerHandle::Get().get())); | 59 blob_storage_context, NULL, base::ThreadTaskRunnerHandle::Get().get())); |
60 } | 60 } |
61 | 61 |
62 // A disk_cache::Backend wrapper that can delay operations. | 62 // A disk_cache::Backend wrapper that can delay operations. |
63 class DelayableBackend : public disk_cache::Backend { | 63 class DelayableBackend : public disk_cache::Backend { |
64 public: | 64 public: |
65 DelayableBackend(std::unique_ptr<disk_cache::Backend> backend) | 65 DelayableBackend(std::unique_ptr<disk_cache::Backend> backend) |
66 : backend_(std::move(backend)), delay_open_(false) {} | 66 : backend_(std::move(backend)), delay_doom_(false) {} |
67 | 67 |
68 // disk_cache::Backend overrides | 68 // disk_cache::Backend overrides |
69 net::CacheType GetCacheType() const override { | 69 net::CacheType GetCacheType() const override { |
70 return backend_->GetCacheType(); | 70 return backend_->GetCacheType(); |
71 } | 71 } |
72 int32_t GetEntryCount() const override { return backend_->GetEntryCount(); } | 72 int32_t GetEntryCount() const override { return backend_->GetEntryCount(); } |
73 int OpenEntry(const std::string& key, | 73 int OpenEntry(const std::string& key, |
74 disk_cache::Entry** entry, | 74 disk_cache::Entry** entry, |
75 const CompletionCallback& callback) override { | 75 const CompletionCallback& callback) override { |
76 if (delay_open_) { | |
77 open_entry_callback_ = | |
78 base::Bind(&DelayableBackend::OpenEntryDelayedImpl, | |
79 base::Unretained(this), key, entry, callback); | |
80 return net::ERR_IO_PENDING; | |
81 } | |
82 | |
83 return backend_->OpenEntry(key, entry, callback); | 76 return backend_->OpenEntry(key, entry, callback); |
84 } | 77 } |
| 78 |
85 int CreateEntry(const std::string& key, | 79 int CreateEntry(const std::string& key, |
86 disk_cache::Entry** entry, | 80 disk_cache::Entry** entry, |
87 const CompletionCallback& callback) override { | 81 const CompletionCallback& callback) override { |
88 return backend_->CreateEntry(key, entry, callback); | 82 return backend_->CreateEntry(key, entry, callback); |
89 } | 83 } |
90 int DoomEntry(const std::string& key, | 84 int DoomEntry(const std::string& key, |
91 const CompletionCallback& callback) override { | 85 const CompletionCallback& callback) override { |
| 86 if (delay_doom_) { |
| 87 doom_entry_callback_ = base::Bind(&DelayableBackend::DoomEntryDelayedImpl, |
| 88 base::Unretained(this), key, callback); |
| 89 return net::ERR_IO_PENDING; |
| 90 } |
| 91 |
92 return backend_->DoomEntry(key, callback); | 92 return backend_->DoomEntry(key, callback); |
93 } | 93 } |
94 int DoomAllEntries(const CompletionCallback& callback) override { | 94 int DoomAllEntries(const CompletionCallback& callback) override { |
95 return backend_->DoomAllEntries(callback); | 95 return backend_->DoomAllEntries(callback); |
96 } | 96 } |
97 int DoomEntriesBetween(base::Time initial_time, | 97 int DoomEntriesBetween(base::Time initial_time, |
98 base::Time end_time, | 98 base::Time end_time, |
99 const CompletionCallback& callback) override { | 99 const CompletionCallback& callback) override { |
100 return backend_->DoomEntriesBetween(initial_time, end_time, callback); | 100 return backend_->DoomEntriesBetween(initial_time, end_time, callback); |
101 } | 101 } |
102 int DoomEntriesSince(base::Time initial_time, | 102 int DoomEntriesSince(base::Time initial_time, |
103 const CompletionCallback& callback) override { | 103 const CompletionCallback& callback) override { |
104 return backend_->DoomEntriesSince(initial_time, callback); | 104 return backend_->DoomEntriesSince(initial_time, callback); |
105 } | 105 } |
106 int CalculateSizeOfAllEntries( | 106 int CalculateSizeOfAllEntries( |
107 const CompletionCallback& callback) override { | 107 const CompletionCallback& callback) override { |
108 return backend_->CalculateSizeOfAllEntries(callback); | 108 return backend_->CalculateSizeOfAllEntries(callback); |
109 } | 109 } |
110 std::unique_ptr<Iterator> CreateIterator() override { | 110 std::unique_ptr<Iterator> CreateIterator() override { |
111 return backend_->CreateIterator(); | 111 return backend_->CreateIterator(); |
112 } | 112 } |
113 void GetStats(base::StringPairs* stats) override { | 113 void GetStats(base::StringPairs* stats) override { |
114 return backend_->GetStats(stats); | 114 return backend_->GetStats(stats); |
115 } | 115 } |
116 void OnExternalCacheHit(const std::string& key) override { | 116 void OnExternalCacheHit(const std::string& key) override { |
117 return backend_->OnExternalCacheHit(key); | 117 return backend_->OnExternalCacheHit(key); |
118 } | 118 } |
119 | 119 |
120 // Call to continue a delayed open. | 120 // Call to continue a delayed doom. |
121 void OpenEntryContinue() { | 121 void DoomEntryContinue() { |
122 EXPECT_FALSE(open_entry_callback_.is_null()); | 122 EXPECT_FALSE(doom_entry_callback_.is_null()); |
123 open_entry_callback_.Run(); | 123 doom_entry_callback_.Run(); |
124 } | 124 } |
125 | 125 |
126 void set_delay_open(bool value) { delay_open_ = value; } | 126 void set_delay_doom(bool value) { delay_doom_ = value; } |
127 | 127 |
128 private: | 128 private: |
129 void OpenEntryDelayedImpl(const std::string& key, | 129 void DoomEntryDelayedImpl(const std::string& key, |
130 disk_cache::Entry** entry, | |
131 const CompletionCallback& callback) { | 130 const CompletionCallback& callback) { |
132 int rv = backend_->OpenEntry(key, entry, callback); | 131 int rv = backend_->DoomEntry(key, callback); |
133 if (rv != net::ERR_IO_PENDING) | 132 if (rv != net::ERR_IO_PENDING) |
134 callback.Run(rv); | 133 callback.Run(rv); |
135 } | 134 } |
136 | 135 |
137 std::unique_ptr<disk_cache::Backend> backend_; | 136 std::unique_ptr<disk_cache::Backend> backend_; |
138 bool delay_open_; | 137 bool delay_doom_; |
139 base::Closure open_entry_callback_; | 138 base::Closure doom_entry_callback_; |
140 }; | 139 }; |
141 | 140 |
142 void CopyBody(const storage::BlobDataHandle& blob_handle, std::string* output) { | 141 void CopyBody(const storage::BlobDataHandle& blob_handle, std::string* output) { |
143 *output = std::string(); | 142 *output = std::string(); |
144 std::unique_ptr<storage::BlobDataSnapshot> data = | 143 std::unique_ptr<storage::BlobDataSnapshot> data = |
145 blob_handle.CreateSnapshot(); | 144 blob_handle.CreateSnapshot(); |
146 const auto& items = data->items(); | 145 const auto& items = data->items(); |
147 for (const auto& item : items) { | 146 for (const auto& item : items) { |
148 switch (item->type()) { | 147 switch (item->type()) { |
149 case storage::DataElement::TYPE_BYTES: { | 148 case storage::DataElement::TYPE_BYTES: { |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 CacheStorageBatchOperation operation; | 452 CacheStorageBatchOperation operation; |
454 operation.operation_type = CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT; | 453 operation.operation_type = CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT; |
455 operation.request = request; | 454 operation.request = request; |
456 operation.response = response; | 455 operation.response = response; |
457 | 456 |
458 CacheStorageError error = | 457 CacheStorageError error = |
459 BatchOperation(std::vector<CacheStorageBatchOperation>(1, operation)); | 458 BatchOperation(std::vector<CacheStorageBatchOperation>(1, operation)); |
460 return error == CACHE_STORAGE_OK; | 459 return error == CACHE_STORAGE_OK; |
461 } | 460 } |
462 | 461 |
463 bool Match(const ServiceWorkerFetchRequest& request) { | 462 bool Match(const ServiceWorkerFetchRequest& request, |
| 463 const CacheStorageCacheQueryParams& match_params = |
| 464 CacheStorageCacheQueryParams()) { |
464 std::unique_ptr<base::RunLoop> loop(new base::RunLoop()); | 465 std::unique_ptr<base::RunLoop> loop(new base::RunLoop()); |
465 | 466 |
466 cache_->Match( | 467 cache_->Match( |
467 CopyFetchRequest(request), | 468 CopyFetchRequest(request), match_params, |
468 base::Bind(&CacheStorageCacheTest::ResponseAndErrorCallback, | 469 base::Bind(&CacheStorageCacheTest::ResponseAndErrorCallback, |
469 base::Unretained(this), base::Unretained(loop.get()))); | 470 base::Unretained(this), base::Unretained(loop.get()))); |
470 loop->Run(); | 471 loop->Run(); |
471 | 472 |
472 return callback_error_ == CACHE_STORAGE_OK; | 473 return callback_error_ == CACHE_STORAGE_OK; |
473 } | 474 } |
474 | 475 |
475 bool MatchAll( | 476 bool MatchAll( |
476 const ServiceWorkerFetchRequest& request, | 477 const ServiceWorkerFetchRequest& request, |
477 const CacheStorageCacheQueryParams& match_params, | 478 const CacheStorageCacheQueryParams& match_params, |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 | 921 |
921 EXPECT_TRUE(Delete(body_request_)); | 922 EXPECT_TRUE(Delete(body_request_)); |
922 EXPECT_TRUE(MatchAll(&responses, &body_handles)); | 923 EXPECT_TRUE(MatchAll(&responses, &body_handles)); |
923 | 924 |
924 ASSERT_EQ(1u, responses->size()); | 925 ASSERT_EQ(1u, responses->size()); |
925 EXPECT_TRUE( | 926 EXPECT_TRUE( |
926 ResponseMetadataEqual(SetCacheName(no_body_response_), responses->at(0))); | 927 ResponseMetadataEqual(SetCacheName(no_body_response_), responses->at(0))); |
927 EXPECT_TRUE(body_handles->empty()); | 928 EXPECT_TRUE(body_handles->empty()); |
928 } | 929 } |
929 | 930 |
| 931 TEST_P(CacheStorageCacheTestP, Match_IgnoreSearch) { |
| 932 EXPECT_TRUE(Put(body_request_with_query_, body_response_with_query_)); |
| 933 |
| 934 EXPECT_FALSE(Match(body_request_)); |
| 935 CacheStorageCacheQueryParams match_params; |
| 936 match_params.ignore_search = true; |
| 937 EXPECT_TRUE(Match(body_request_, match_params)); |
| 938 } |
| 939 |
| 940 TEST_P(CacheStorageCacheTestP, Match_IgnoreMethod) { |
| 941 EXPECT_TRUE(Put(body_request_, body_response_)); |
| 942 |
| 943 ServiceWorkerFetchRequest post_request = body_request_; |
| 944 post_request.method = "POST"; |
| 945 EXPECT_FALSE(Match(post_request)); |
| 946 |
| 947 CacheStorageCacheQueryParams match_params; |
| 948 match_params.ignore_method = true; |
| 949 EXPECT_TRUE(Match(post_request, match_params)); |
| 950 } |
| 951 |
| 952 TEST_P(CacheStorageCacheTestP, Match_IgnoreVary) { |
| 953 body_request_.headers["vary_foo"] = "foo"; |
| 954 body_response_.headers["vary"] = "vary_foo"; |
| 955 EXPECT_TRUE(Put(body_request_, body_response_)); |
| 956 EXPECT_TRUE(Match(body_request_)); |
| 957 |
| 958 body_request_.headers["vary_foo"] = "bar"; |
| 959 EXPECT_FALSE(Match(body_request_)); |
| 960 |
| 961 CacheStorageCacheQueryParams match_params; |
| 962 match_params.ignore_vary = true; |
| 963 EXPECT_TRUE(Match(body_request_, match_params)); |
| 964 } |
| 965 |
| 966 TEST_P(CacheStorageCacheTestP, Keys_IgnoreSearch) { |
| 967 EXPECT_TRUE(Put(body_request_with_query_, body_response_with_query_)); |
| 968 |
| 969 EXPECT_TRUE(Keys(body_request_)); |
| 970 EXPECT_EQ(0u, callback_strings_.size()); |
| 971 |
| 972 CacheStorageCacheQueryParams match_params; |
| 973 match_params.ignore_search = true; |
| 974 EXPECT_TRUE(Keys(body_request_, match_params)); |
| 975 EXPECT_EQ(1u, callback_strings_.size()); |
| 976 } |
| 977 |
| 978 TEST_P(CacheStorageCacheTestP, Keys_IgnoreMethod) { |
| 979 EXPECT_TRUE(Put(body_request_, body_response_)); |
| 980 |
| 981 ServiceWorkerFetchRequest post_request = body_request_; |
| 982 post_request.method = "POST"; |
| 983 EXPECT_TRUE(Keys(post_request)); |
| 984 EXPECT_EQ(0u, callback_strings_.size()); |
| 985 |
| 986 CacheStorageCacheQueryParams match_params; |
| 987 match_params.ignore_method = true; |
| 988 EXPECT_TRUE(Keys(post_request, match_params)); |
| 989 EXPECT_EQ(1u, callback_strings_.size()); |
| 990 } |
| 991 |
| 992 TEST_P(CacheStorageCacheTestP, Keys_IgnoreVary) { |
| 993 body_request_.headers["vary_foo"] = "foo"; |
| 994 body_response_.headers["vary"] = "vary_foo"; |
| 995 EXPECT_TRUE(Put(body_request_, body_response_)); |
| 996 EXPECT_TRUE(Keys(body_request_)); |
| 997 EXPECT_EQ(1u, callback_strings_.size()); |
| 998 |
| 999 body_request_.headers["vary_foo"] = "bar"; |
| 1000 EXPECT_TRUE(Keys(body_request_)); |
| 1001 EXPECT_EQ(0u, callback_strings_.size()); |
| 1002 |
| 1003 CacheStorageCacheQueryParams match_params; |
| 1004 match_params.ignore_vary = true; |
| 1005 EXPECT_TRUE(Keys(body_request_, match_params)); |
| 1006 EXPECT_EQ(1u, callback_strings_.size()); |
| 1007 } |
| 1008 |
| 1009 TEST_P(CacheStorageCacheTestP, Delete_IgnoreSearch) { |
| 1010 EXPECT_TRUE(Put(body_request_with_query_, body_response_with_query_)); |
| 1011 |
| 1012 EXPECT_FALSE(Delete(body_request_)); |
| 1013 CacheStorageCacheQueryParams match_params; |
| 1014 match_params.ignore_search = true; |
| 1015 EXPECT_TRUE(Delete(body_request_, match_params)); |
| 1016 } |
| 1017 |
| 1018 TEST_P(CacheStorageCacheTestP, Delete_IgnoreMethod) { |
| 1019 EXPECT_TRUE(Put(body_request_, body_response_)); |
| 1020 |
| 1021 ServiceWorkerFetchRequest post_request = body_request_; |
| 1022 post_request.method = "POST"; |
| 1023 EXPECT_FALSE(Delete(post_request)); |
| 1024 |
| 1025 CacheStorageCacheQueryParams match_params; |
| 1026 match_params.ignore_method = true; |
| 1027 EXPECT_TRUE(Delete(post_request, match_params)); |
| 1028 } |
| 1029 |
| 1030 TEST_P(CacheStorageCacheTestP, Delete_IgnoreVary) { |
| 1031 body_request_.headers["vary_foo"] = "foo"; |
| 1032 body_response_.headers["vary"] = "vary_foo"; |
| 1033 EXPECT_TRUE(Put(body_request_, body_response_)); |
| 1034 |
| 1035 body_request_.headers["vary_foo"] = "bar"; |
| 1036 EXPECT_FALSE(Delete(body_request_)); |
| 1037 |
| 1038 CacheStorageCacheQueryParams match_params; |
| 1039 match_params.ignore_vary = true; |
| 1040 EXPECT_TRUE(Delete(body_request_, match_params)); |
| 1041 } |
| 1042 |
| 1043 TEST_P(CacheStorageCacheTestP, MatchAll_IgnoreMethod) { |
| 1044 EXPECT_TRUE(Put(body_request_, body_response_)); |
| 1045 |
| 1046 ServiceWorkerFetchRequest post_request = body_request_; |
| 1047 post_request.method = "POST"; |
| 1048 std::unique_ptr<CacheStorageCache::Responses> responses; |
| 1049 std::unique_ptr<CacheStorageCache::BlobDataHandles> body_handles; |
| 1050 CacheStorageCacheQueryParams match_params; |
| 1051 |
| 1052 EXPECT_TRUE(MatchAll(post_request, match_params, &responses, &body_handles)); |
| 1053 EXPECT_EQ(0u, responses->size()); |
| 1054 |
| 1055 match_params.ignore_method = true; |
| 1056 EXPECT_TRUE(MatchAll(post_request, match_params, &responses, &body_handles)); |
| 1057 EXPECT_EQ(1u, responses->size()); |
| 1058 } |
| 1059 |
| 1060 TEST_P(CacheStorageCacheTestP, MatchAll_IgnoreVary) { |
| 1061 body_request_.headers["vary_foo"] = "foo"; |
| 1062 body_response_.headers["vary"] = "vary_foo"; |
| 1063 EXPECT_TRUE(Put(body_request_, body_response_)); |
| 1064 std::unique_ptr<CacheStorageCache::Responses> responses; |
| 1065 std::unique_ptr<CacheStorageCache::BlobDataHandles> body_handles; |
| 1066 CacheStorageCacheQueryParams match_params; |
| 1067 |
| 1068 EXPECT_TRUE(MatchAll(body_request_, match_params, &responses, &body_handles)); |
| 1069 EXPECT_EQ(1u, responses->size()); |
| 1070 body_request_.headers["vary_foo"] = "bar"; |
| 1071 |
| 1072 EXPECT_TRUE(MatchAll(body_request_, match_params, &responses, &body_handles)); |
| 1073 EXPECT_EQ(0u, responses->size()); |
| 1074 |
| 1075 match_params.ignore_vary = true; |
| 1076 EXPECT_TRUE(MatchAll(body_request_, match_params, &responses, &body_handles)); |
| 1077 EXPECT_EQ(1u, responses->size()); |
| 1078 } |
| 1079 |
930 TEST_P(CacheStorageCacheTestP, MatchAll_IgnoreSearch) { | 1080 TEST_P(CacheStorageCacheTestP, MatchAll_IgnoreSearch) { |
931 EXPECT_TRUE(Put(body_request_, body_response_)); | 1081 EXPECT_TRUE(Put(body_request_, body_response_)); |
932 EXPECT_TRUE(Put(body_request_with_query_, body_response_with_query_)); | 1082 EXPECT_TRUE(Put(body_request_with_query_, body_response_with_query_)); |
933 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); | 1083 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); |
934 | 1084 |
935 std::unique_ptr<CacheStorageCache::Responses> responses; | 1085 std::unique_ptr<CacheStorageCache::Responses> responses; |
936 std::unique_ptr<CacheStorageCache::BlobDataHandles> body_handles; | 1086 std::unique_ptr<CacheStorageCache::BlobDataHandles> body_handles; |
937 CacheStorageCacheQueryParams match_params; | 1087 CacheStorageCacheQueryParams match_params; |
938 match_params.ignore_search = true; | 1088 match_params.ignore_search = true; |
939 EXPECT_TRUE(MatchAll(body_request_, match_params, &responses, &body_handles)); | 1089 EXPECT_TRUE(MatchAll(body_request_, match_params, &responses, &body_handles)); |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1397 EXPECT_TRUE(Put(body_request_, body_response_)); | 1547 EXPECT_TRUE(Put(body_request_, body_response_)); |
1398 EXPECT_TRUE(Close()); | 1548 EXPECT_TRUE(Close()); |
1399 VerifyAllOpsFail(); | 1549 VerifyAllOpsFail(); |
1400 } | 1550 } |
1401 | 1551 |
1402 TEST_P(CacheStorageCacheTestP, VerifySerialScheduling) { | 1552 TEST_P(CacheStorageCacheTestP, VerifySerialScheduling) { |
1403 // Start two operations, the first one is delayed but the second isn't. The | 1553 // Start two operations, the first one is delayed but the second isn't. The |
1404 // second should wait for the first. | 1554 // second should wait for the first. |
1405 EXPECT_TRUE(Keys()); // Opens the backend. | 1555 EXPECT_TRUE(Keys()); // Opens the backend. |
1406 DelayableBackend* delayable_backend = cache_->UseDelayableBackend(); | 1556 DelayableBackend* delayable_backend = cache_->UseDelayableBackend(); |
1407 delayable_backend->set_delay_open(true); | 1557 delayable_backend->set_delay_doom(true); |
1408 | 1558 |
1409 int sequence_out = -1; | 1559 int sequence_out = -1; |
1410 | 1560 |
1411 CacheStorageBatchOperation operation1; | 1561 CacheStorageBatchOperation operation1; |
1412 operation1.operation_type = CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT; | 1562 operation1.operation_type = CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT; |
1413 operation1.request = body_request_; | 1563 operation1.request = body_request_; |
1414 operation1.response = body_response_; | 1564 operation1.response = body_response_; |
1415 | 1565 |
1416 std::unique_ptr<base::RunLoop> close_loop1(new base::RunLoop()); | 1566 std::unique_ptr<base::RunLoop> close_loop1(new base::RunLoop()); |
1417 cache_->BatchOperation( | 1567 cache_->BatchOperation( |
1418 std::vector<CacheStorageBatchOperation>(1, operation1), | 1568 std::vector<CacheStorageBatchOperation>(1, operation1), |
1419 base::Bind(&CacheStorageCacheTest::SequenceCallback, | 1569 base::Bind(&CacheStorageCacheTest::SequenceCallback, |
1420 base::Unretained(this), 1, &sequence_out, close_loop1.get())); | 1570 base::Unretained(this), 1, &sequence_out, close_loop1.get())); |
1421 | 1571 |
1422 // Blocks on opening the cache entry. | 1572 // Blocks on creating the cache entry. |
1423 base::RunLoop().RunUntilIdle(); | 1573 base::RunLoop().RunUntilIdle(); |
1424 | 1574 |
1425 CacheStorageBatchOperation operation2; | 1575 CacheStorageBatchOperation operation2; |
1426 operation2.operation_type = CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT; | 1576 operation2.operation_type = CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT; |
1427 operation2.request = body_request_; | 1577 operation2.request = body_request_; |
1428 operation2.response = body_response_; | 1578 operation2.response = body_response_; |
1429 | 1579 |
1430 delayable_backend->set_delay_open(false); | 1580 delayable_backend->set_delay_doom(false); |
1431 std::unique_ptr<base::RunLoop> close_loop2(new base::RunLoop()); | 1581 std::unique_ptr<base::RunLoop> close_loop2(new base::RunLoop()); |
1432 cache_->BatchOperation( | 1582 cache_->BatchOperation( |
1433 std::vector<CacheStorageBatchOperation>(1, operation2), | 1583 std::vector<CacheStorageBatchOperation>(1, operation2), |
1434 base::Bind(&CacheStorageCacheTest::SequenceCallback, | 1584 base::Bind(&CacheStorageCacheTest::SequenceCallback, |
1435 base::Unretained(this), 2, &sequence_out, close_loop2.get())); | 1585 base::Unretained(this), 2, &sequence_out, close_loop2.get())); |
1436 | 1586 |
1437 // The second put operation should wait for the first to complete. | 1587 // The second put operation should wait for the first to complete. |
1438 base::RunLoop().RunUntilIdle(); | 1588 base::RunLoop().RunUntilIdle(); |
1439 EXPECT_FALSE(callback_response_); | 1589 EXPECT_FALSE(callback_response_); |
1440 | 1590 |
1441 delayable_backend->OpenEntryContinue(); | 1591 delayable_backend->DoomEntryContinue(); |
1442 close_loop1->Run(); | 1592 close_loop1->Run(); |
1443 EXPECT_EQ(1, sequence_out); | 1593 EXPECT_EQ(1, sequence_out); |
1444 close_loop2->Run(); | 1594 close_loop2->Run(); |
1445 EXPECT_EQ(2, sequence_out); | 1595 EXPECT_EQ(2, sequence_out); |
1446 } | 1596 } |
1447 | 1597 |
1448 INSTANTIATE_TEST_CASE_P(CacheStorageCacheTest, | 1598 INSTANTIATE_TEST_CASE_P(CacheStorageCacheTest, |
1449 CacheStorageCacheTestP, | 1599 CacheStorageCacheTestP, |
1450 ::testing::Values(false, true)); | 1600 ::testing::Values(false, true)); |
1451 | 1601 |
1452 } // namespace content | 1602 } // namespace content |
OLD | NEW |