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

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

Issue 501082: Implement delaying resource requests until privacy blacklists are ready. (Closed)
Patch Set: don't get stuck on errors Created 10 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
« no previous file with comments | « net/url_request/url_request_unittest.h ('k') | no next file » | 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) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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/url_request_unittest.h" 5 #include "net/url_request/url_request_unittest.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include <windows.h> 10 #include <windows.h>
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "net/url_request/url_request_file_dir_job.h" 42 #include "net/url_request/url_request_file_dir_job.h"
43 #include "net/url_request/url_request_http_job.h" 43 #include "net/url_request/url_request_http_job.h"
44 #include "net/url_request/url_request_test_job.h" 44 #include "net/url_request/url_request_test_job.h"
45 #include "testing/gtest/include/gtest/gtest.h" 45 #include "testing/gtest/include/gtest/gtest.h"
46 #include "testing/platform_test.h" 46 #include "testing/platform_test.h"
47 47
48 using base::Time; 48 using base::Time;
49 49
50 namespace { 50 namespace {
51 51
52 class URLRequestTestContext : public URLRequestContext {
53 public:
54 URLRequestTestContext() {
55 host_resolver_ = net::CreateSystemHostResolver();
56 proxy_service_ = net::ProxyService::CreateNull();
57 ftp_transaction_factory_ = new net::FtpNetworkLayer(host_resolver_);
58 ssl_config_service_ = new net::SSLConfigServiceDefaults;
59 http_transaction_factory_ =
60 new net::HttpCache(
61 net::HttpNetworkLayer::CreateFactory(host_resolver_, proxy_service_,
62 ssl_config_service_),
63 disk_cache::CreateInMemoryCacheBackend(0));
64 // In-memory cookie store.
65 cookie_store_ = new net::CookieMonster();
66 accept_language_ = "en-us,fr";
67 accept_charset_ = "iso-8859-1,*,utf-8";
68 }
69
70 private:
71 virtual ~URLRequestTestContext() {
72 delete ftp_transaction_factory_;
73 delete http_transaction_factory_;
74 }
75 };
76
77 class TestURLRequest : public URLRequest {
78 public:
79 TestURLRequest(const GURL& url, Delegate* delegate)
80 : URLRequest(url, delegate) {
81 set_context(new URLRequestTestContext());
82 }
83 };
84
85 base::StringPiece TestNetResourceProvider(int key) { 52 base::StringPiece TestNetResourceProvider(int key) {
86 return "header"; 53 return "header";
87 } 54 }
88 55
89 // Do a case-insensitive search through |haystack| for |needle|. 56 // Do a case-insensitive search through |haystack| for |needle|.
90 bool ContainsString(const std::string& haystack, const char* needle) { 57 bool ContainsString(const std::string& haystack, const char* needle) {
91 std::string::const_iterator it = 58 std::string::const_iterator it =
92 std::search(haystack.begin(), 59 std::search(haystack.begin(),
93 haystack.end(), 60 haystack.end(),
94 needle, 61 needle,
(...skipping 2094 matching lines...) Expand 10 before | Expand all | Expand 10 after
2189 ASSERT_TRUE(NULL != server_.get()); 2156 ASSERT_TRUE(NULL != server_.get());
2190 TestDelegate d; 2157 TestDelegate d;
2191 TestURLRequest 2158 TestURLRequest
2192 req(server_->TestServerPage("echoheaderoverride?Accept-Charset"), &d); 2159 req(server_->TestServerPage("echoheaderoverride?Accept-Charset"), &d);
2193 req.set_context(new URLRequestTestContext()); 2160 req.set_context(new URLRequestTestContext());
2194 req.SetExtraRequestHeaders("Accept-Charset: koi-8r"); 2161 req.SetExtraRequestHeaders("Accept-Charset: koi-8r");
2195 req.Start(); 2162 req.Start();
2196 MessageLoop::current()->Run(); 2163 MessageLoop::current()->Run();
2197 EXPECT_EQ(std::string("koi-8r"), d.data_received()); 2164 EXPECT_EQ(std::string("koi-8r"), d.data_received());
2198 } 2165 }
OLDNEW
« no previous file with comments | « net/url_request/url_request_unittest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698