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

Unified Diff: net/http/http_cache_unittest.cc

Issue 2671793002: Correct handling of ERR_CACHE_LOCK_TIMEOUT for read only transactions. (Closed)
Patch Set: Feedback addressed Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_cache_transaction.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_cache_unittest.cc
diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc
index 60c7ed7c8d75d286465b15c12b4806d86acc6b87..de5ddd0d4c2e6b33ae0ab370055c36fdaf802335 100644
--- a/net/http/http_cache_unittest.cc
+++ b/net/http/http_cache_unittest.cc
@@ -1769,6 +1769,36 @@ TEST(HttpCache, SimpleGET_WriterTimeout) {
ReadAndVerifyTransaction(c1.trans.get(), kSimpleGET_Transaction);
}
+// Tests that a (simulated) timeout allows transactions waiting on the cache
+// lock to continue but read only transactions to error out.
+TEST(HttpCache, SimpleGET_WriterTimeoutReadOnlyError) {
+ MockHttpCache cache;
+
+ // Simulate timeout.
+ cache.BypassCacheLock();
asanka 2017/02/07 22:56:03 This method is poorly named :-(
shivanisha 2017/02/08 19:14:13 Updated to SimulateCacheLockTimeout for clarity an
+
+ MockHttpRequest request(kSimpleGET_Transaction);
+ Context c1, c2;
+ ASSERT_THAT(cache.CreateTransaction(&c1.trans), IsOk());
+ ASSERT_EQ(ERR_IO_PENDING, c1.trans->Start(&request, c1.callback.callback(),
+ NetLogWithSource()));
+
+ // Using load flags similar to MetadataWriter.
asanka 2017/02/07 22:56:03 There are two things to test: 1) That HttpCache::
shivanisha 2017/02/08 19:14:13 Done. The new test added for WriteMetadata_* grou
+ request.load_flags =
+ LOAD_ONLY_FROM_CACHE | LOAD_SKIP_CACHE_VALIDATION | LOAD_SKIP_VARY_CHECK;
+ ASSERT_THAT(cache.CreateTransaction(&c2.trans), IsOk());
+ ASSERT_EQ(ERR_IO_PENDING, c2.trans->Start(&request, c2.callback.callback(),
+ NetLogWithSource()));
+
+ // The second request is queued after the first one.
+ int res = c2.callback.WaitForResult();
+ ASSERT_EQ(ERR_CACHE_MISS, res);
+
+ // Complete the first transaction.
+ c1.callback.WaitForResult();
+ ReadAndVerifyTransaction(c1.trans.get(), kSimpleGET_Transaction);
+}
+
TEST(HttpCache, SimpleGET_AbandonedCacheRead) {
MockHttpCache cache;
« no previous file with comments | « net/http/http_cache_transaction.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698