diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-12 17:52:47 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-12 17:52:47 +0000 |
commit | 5c04f72431dc072fded17be7a9620b724f314821 (patch) | |
tree | b1aad621601276eaca1bd018454b29e9b9a9db52 /net/http/http_cache_unittest.cc | |
parent | 071162a96601d92c90feb60f75b74af07ec4934a (diff) | |
download | chromium_src-5c04f72431dc072fded17be7a9620b724f314821.zip chromium_src-5c04f72431dc072fded17be7a9620b724f314821.tar.gz chromium_src-5c04f72431dc072fded17be7a9620b724f314821.tar.bz2 |
net: Notify the http job and cache transaction about a filter
completing the request (returning 0 bytes from a read).
BUG=91898
TEST=net_unittests
Review URL: http://codereview.chromium.org/7569027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96576 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_cache_unittest.cc')
-rw-r--r-- | net/http/http_cache_unittest.cc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc index b467dc5..9fbd49e 100644 --- a/net/http/http_cache_unittest.cc +++ b/net/http/http_cache_unittest.cc @@ -5101,3 +5101,37 @@ TEST(HttpCache, ReadMetadata) { EXPECT_EQ(4, cache.disk_cache()->open_count()); EXPECT_EQ(1, cache.disk_cache()->create_count()); } + +// Tests that we don't mark entries as truncated when a filter detects the end +// of the stream. +TEST(HttpCache, FilterCompletion) { + MockHttpCache cache; + TestCompletionCallback callback; + + { + scoped_ptr<net::HttpTransaction> trans; + int rv = cache.http_cache()->CreateTransaction(&trans); + EXPECT_EQ(net::OK, rv); + + MockHttpRequest request(kSimpleGET_Transaction); + rv = trans->Start(&request, &callback, net::BoundNetLog()); + EXPECT_EQ(net::OK, callback.GetResult(rv)); + + scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(256)); + rv = trans->Read(buf, 256, &callback); + EXPECT_GT(callback.GetResult(rv), 0); + + // Now make sure that the entry is preserved. + trans->DoneReading(); + } + + // Make sure that teh ActiveEntry is gone. + MessageLoop::current()->RunAllPending(); + + // Read from the cache. + RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); + + EXPECT_EQ(1, cache.network_layer()->transaction_count()); + EXPECT_EQ(1, cache.disk_cache()->open_count()); + EXPECT_EQ(1, cache.disk_cache()->create_count()); +} |