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

Side by Side Diff: net/url_request/view_cache_helper_unittest.cc

Issue 4067002: First pass at adding http/backend cache to NetLog (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Lint fixes Created 9 years, 11 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/url_request/url_request_unittest.h ('k') | webkit/appcache/appcache_disk_cache.cc » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/url_request/view_cache_helper.h" 5 #include "net/url_request/view_cache_helper.h"
6 6
7 #include "base/pickle.h" 7 #include "base/pickle.h"
8 #include "net/base/test_completion_callback.h" 8 #include "net/base/test_completion_callback.h"
9 #include "net/disk_cache/disk_cache.h" 9 #include "net/disk_cache/disk_cache.h"
10 #include "net/http/http_cache.h" 10 #include "net/http/http_cache.h"
11 #include "net/url_request/url_request_context.h" 11 #include "net/url_request/url_request_context.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace { 14 namespace {
15 15
16 class TestURLRequestContext : public URLRequestContext { 16 class TestURLRequestContext : public URLRequestContext {
17 public: 17 public:
18 TestURLRequestContext(); 18 TestURLRequestContext();
19 19
20 // Gets a pointer to the cache backend. 20 // Gets a pointer to the cache backend.
21 disk_cache::Backend* GetBackend(); 21 disk_cache::Backend* GetBackend();
22 22
23 private: 23 private:
24 net::HttpCache cache_; 24 net::HttpCache cache_;
25 }; 25 };
26 26
27 TestURLRequestContext::TestURLRequestContext() 27 TestURLRequestContext::TestURLRequestContext()
28 : cache_(reinterpret_cast<net::HttpTransactionFactory*>(NULL), 28 : cache_(reinterpret_cast<net::HttpTransactionFactory*>(NULL), NULL,
29 net::HttpCache::DefaultBackend::InMemory(0)) { 29 net::HttpCache::DefaultBackend::InMemory(0)) {
30 http_transaction_factory_ = &cache_; 30 http_transaction_factory_ = &cache_;
31 } 31 }
32 32
33 void WriteHeaders(disk_cache::Entry* entry, int flags, const std::string data) { 33 void WriteHeaders(disk_cache::Entry* entry, int flags, const std::string data) {
34 if (data.empty()) 34 if (data.empty())
35 return; 35 return;
36 36
37 Pickle pickle; 37 Pickle pickle;
38 pickle.WriteInt(flags | 1); // Version 1. 38 pickle.WriteInt(flags | 1); // Version 1.
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 int flags = 1 << 12; 192 int flags = 1 << 12;
193 WriteHeaders(entry, flags, "something"); 193 WriteHeaders(entry, flags, "something");
194 entry->Close(); 194 entry->Close();
195 195
196 std::string data; 196 std::string data;
197 rv = helper.GetEntryInfoHTML(key, context, &data, &cb); 197 rv = helper.GetEntryInfoHTML(key, context, &data, &cb);
198 EXPECT_EQ(net::OK, cb.GetResult(rv)); 198 EXPECT_EQ(net::OK, cb.GetResult(rv));
199 199
200 EXPECT_NE(std::string::npos, data.find("RESPONSE_INFO_TRUNCATED")); 200 EXPECT_NE(std::string::npos, data.find("RESPONSE_INFO_TRUNCATED"));
201 } 201 }
OLDNEW
« no previous file with comments | « net/url_request/url_request_unittest.h ('k') | webkit/appcache/appcache_disk_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698