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

Side by Side Diff: net/http/http_cache_unittest.cc

Issue 7569027: net: Notify the http job and cache transaction about a filter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_cache_transaction.cc ('k') | net/http/http_network_transaction.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "net/http/http_cache.h" 5 #include "net/http/http_cache.h"
6 6
7 #include "base/hash_tables.h" 7 #include "base/hash_tables.h"
8 #include "base/memory/scoped_vector.h" 8 #include "base/memory/scoped_vector.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 5083 matching lines...) Expand 10 before | Expand all | Expand 10 after
5094 // Now return 200 when validating the entry so the metadata will be lost. 5094 // Now return 200 when validating the entry so the metadata will be lost.
5095 MockTransaction trans2(kTypicalGET_Transaction); 5095 MockTransaction trans2(kTypicalGET_Transaction);
5096 trans2.load_flags = net::LOAD_VALIDATE_CACHE; 5096 trans2.load_flags = net::LOAD_VALIDATE_CACHE;
5097 RunTransactionTestWithResponseInfo(cache.http_cache(), trans2, &response); 5097 RunTransactionTestWithResponseInfo(cache.http_cache(), trans2, &response);
5098 EXPECT_TRUE(response.metadata.get() == NULL); 5098 EXPECT_TRUE(response.metadata.get() == NULL);
5099 5099
5100 EXPECT_EQ(3, cache.network_layer()->transaction_count()); 5100 EXPECT_EQ(3, cache.network_layer()->transaction_count());
5101 EXPECT_EQ(4, cache.disk_cache()->open_count()); 5101 EXPECT_EQ(4, cache.disk_cache()->open_count());
5102 EXPECT_EQ(1, cache.disk_cache()->create_count()); 5102 EXPECT_EQ(1, cache.disk_cache()->create_count());
5103 } 5103 }
5104
5105 // Tests that we don't mark entries as truncated when a filter detects the end
5106 // of the stream.
5107 TEST(HttpCache, FilterCompletion) {
5108 MockHttpCache cache;
5109 TestCompletionCallback callback;
5110
5111 {
5112 scoped_ptr<net::HttpTransaction> trans;
5113 int rv = cache.http_cache()->CreateTransaction(&trans);
5114 EXPECT_EQ(net::OK, rv);
5115
5116 MockHttpRequest request(kSimpleGET_Transaction);
5117 rv = trans->Start(&request, &callback, net::BoundNetLog());
5118 EXPECT_EQ(net::OK, callback.GetResult(rv));
5119
5120 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(256));
5121 rv = trans->Read(buf, 256, &callback);
5122 EXPECT_GT(callback.GetResult(rv), 0);
5123
5124 // Now make sure that the entry is preserved.
5125 trans->DoneReading();
5126 }
5127
5128 // Make sure that teh ActiveEntry is gone.
5129 MessageLoop::current()->RunAllPending();
5130
5131 // Read from the cache.
5132 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction);
5133
5134 EXPECT_EQ(1, cache.network_layer()->transaction_count());
5135 EXPECT_EQ(1, cache.disk_cache()->open_count());
5136 EXPECT_EQ(1, cache.disk_cache()->create_count());
5137 }
OLDNEW
« no previous file with comments | « net/http/http_cache_transaction.cc ('k') | net/http/http_network_transaction.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698