diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-26 16:51:10 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-26 16:51:10 +0000 |
commit | d5b94c7b5748d2d97aeb01b6d3a6e7493f87f3aa (patch) | |
tree | 3c31e288218fb30898a151d3f8761a124ae5fc92 /net/http/http_cache_unittest.cc | |
parent | 11651ca8e83aeead41d145aa7a5a943dd0392919 (diff) | |
download | chromium_src-d5b94c7b5748d2d97aeb01b6d3a6e7493f87f3aa.zip chromium_src-d5b94c7b5748d2d97aeb01b6d3a6e7493f87f3aa.tar.gz chromium_src-d5b94c7b5748d2d97aeb01b6d3a6e7493f87f3aa.tar.bz2 |
Http cache: Make sure that we remove pending transactions
when they belong to a doomed entry.
BUG=25588
TEST=unittests
Review URL: http://codereview.chromium.org/335015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30054 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_cache_unittest.cc')
-rw-r--r-- | net/http/http_cache_unittest.cc | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc index 371ef2586..1206598 100644 --- a/net/http/http_cache_unittest.cc +++ b/net/http/http_cache_unittest.cc @@ -6,6 +6,7 @@ #include "base/hash_tables.h" #include "base/message_loop.h" +#include "base/scoped_vector.h" #include "base/string_util.h" #include "net/base/net_errors.h" #include "net/base/load_flags.h" @@ -1140,6 +1141,55 @@ TEST(HttpCache, SimpleGET_RacingReaders) { } } +// Tests that we can doom an entry with pending transactions and delete one of +// the pending transactions before the first one completes. +// See http://code.google.com/p/chromium/issues/detail?id=25588 +TEST(HttpCache, SimpleGET_DoomWithPending) { + // We need simultaneous doomed / not_doomed entries so let's use a real cache. + disk_cache::Backend* disk_cache = + disk_cache::CreateInMemoryCacheBackend(1024 * 1024); + MockHttpCache cache(disk_cache); + + MockHttpRequest request(kSimpleGET_Transaction); + MockHttpRequest writer_request(kSimpleGET_Transaction); + writer_request.load_flags = net::LOAD_BYPASS_CACHE; + + ScopedVector<Context> context_list; + const int kNumTransactions = 4; + + for (int i = 0; i < kNumTransactions; ++i) { + context_list.push_back(new Context()); + Context* c = context_list[i]; + + c->result = cache.http_cache()->CreateTransaction(&c->trans); + EXPECT_EQ(net::OK, c->result); + + MockHttpRequest* this_request = &request; + if (i == 3) + this_request = &writer_request; + + c->result = c->trans->Start(this_request, &c->callback, NULL); + } + + // The first request should be a writer at this point, and the two subsequent + // requests should be pending. The last request doomed the first entry. + + EXPECT_EQ(2, cache.network_layer()->transaction_count()); + + // Cancel the first queued transaction. + delete context_list[1]; + context_list.get()[1] = NULL; + + for (int i = 0; i < kNumTransactions; ++i) { + if (i == 1) + continue; + Context* c = context_list[i]; + ASSERT_EQ(net::ERR_IO_PENDING, c->result); + c->result = c->callback.WaitForResult(); + ReadAndVerifyTransaction(c->trans.get(), kSimpleGET_Transaction); + } +} + // This is a test for http://code.google.com/p/chromium/issues/detail?id=4731. // We may attempt to delete an entry synchronously with the act of adding a new // transaction to said entry. |