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

Side by Side Diff: content/shell/shell_url_request_context_getter.cc

Issue 11053007: Make content shell support some testing flags. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove switch from chrome_switches.h and add CONTENT_EXPORT Created 8 years, 2 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 | « content/shell/shell_url_request_context_getter.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/shell/shell_url_request_context_getter.h" 5 #include "content/shell/shell_url_request_context_getter.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_number_conversions.h"
9 #include "base/string_split.h" 10 #include "base/string_split.h"
10 #include "base/threading/worker_pool.h" 11 #include "base/threading/worker_pool.h"
11 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/common/content_switches.h"
12 #include "content/shell/shell_network_delegate.h" 14 #include "content/shell/shell_network_delegate.h"
13 #include "net/base/cert_verifier.h" 15 #include "net/base/cert_verifier.h"
14 #include "net/base/default_server_bound_cert_store.h" 16 #include "net/base/default_server_bound_cert_store.h"
15 #include "net/base/host_resolver.h" 17 #include "net/base/host_resolver.h"
18 #include "net/base/mapped_host_resolver.h"
16 #include "net/base/server_bound_cert_service.h" 19 #include "net/base/server_bound_cert_service.h"
17 #include "net/base/ssl_config_service_defaults.h" 20 #include "net/base/ssl_config_service_defaults.h"
18 #include "net/cookies/cookie_monster.h" 21 #include "net/cookies/cookie_monster.h"
19 #include "net/http/http_auth_handler_factory.h" 22 #include "net/http/http_auth_handler_factory.h"
20 #include "net/http/http_cache.h" 23 #include "net/http/http_cache.h"
21 #include "net/http/http_network_session.h" 24 #include "net/http/http_network_session.h"
22 #include "net/http/http_server_properties_impl.h" 25 #include "net/http/http_server_properties_impl.h"
23 #include "net/proxy/proxy_service.h" 26 #include "net/proxy/proxy_service.h"
24 #include "net/url_request/url_request_context.h" 27 #include "net/url_request/url_request_context.h"
25 #include "net/url_request/url_request_context_storage.h" 28 #include "net/url_request/url_request_context_storage.h"
(...skipping 21 matching lines...) Expand all
47 io_loop_->message_loop_proxy(), file_loop_)); 50 io_loop_->message_loop_proxy(), file_loop_));
48 } 51 }
49 52
50 ShellURLRequestContextGetter::~ShellURLRequestContextGetter() { 53 ShellURLRequestContextGetter::~ShellURLRequestContextGetter() {
51 } 54 }
52 55
53 net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() { 56 net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() {
54 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
55 58
56 if (!url_request_context_.get()) { 59 if (!url_request_context_.get()) {
60 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
61
57 url_request_context_.reset(new net::URLRequestContext()); 62 url_request_context_.reset(new net::URLRequestContext());
58 network_delegate_.reset(new ShellNetworkDelegate); 63 network_delegate_.reset(new ShellNetworkDelegate);
59 url_request_context_->set_network_delegate(network_delegate_.get()); 64 url_request_context_->set_network_delegate(network_delegate_.get());
60 storage_.reset( 65 storage_.reset(
61 new net::URLRequestContextStorage(url_request_context_.get())); 66 new net::URLRequestContextStorage(url_request_context_.get()));
62 storage_->set_cookie_store(new net::CookieMonster(NULL, NULL)); 67 storage_->set_cookie_store(new net::CookieMonster(NULL, NULL));
63 storage_->set_server_bound_cert_service(new net::ServerBoundCertService( 68 storage_->set_server_bound_cert_service(new net::ServerBoundCertService(
64 new net::DefaultServerBoundCertStore(NULL), 69 new net::DefaultServerBoundCertStore(NULL),
65 base::WorkerPool::GetTaskRunner(true))); 70 base::WorkerPool::GetTaskRunner(true)));
66 url_request_context_->set_accept_language("en-us,en"); 71 url_request_context_->set_accept_language("en-us,en");
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 network_session_params.ssl_config_service = 109 network_session_params.ssl_config_service =
105 url_request_context_->ssl_config_service(); 110 url_request_context_->ssl_config_service();
106 network_session_params.http_auth_handler_factory = 111 network_session_params.http_auth_handler_factory =
107 url_request_context_->http_auth_handler_factory(); 112 url_request_context_->http_auth_handler_factory();
108 network_session_params.network_delegate = 113 network_session_params.network_delegate =
109 url_request_context_->network_delegate(); 114 url_request_context_->network_delegate();
110 network_session_params.http_server_properties = 115 network_session_params.http_server_properties =
111 url_request_context_->http_server_properties(); 116 url_request_context_->http_server_properties();
112 network_session_params.ignore_certificate_errors = 117 network_session_params.ignore_certificate_errors =
113 ignore_certificate_errors_; 118 ignore_certificate_errors_;
119 if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) {
120 int value;
121 base::StringToInt(command_line.GetSwitchValueASCII(
122 switches::kTestingFixedHttpPort), &value);
123 network_session_params.testing_fixed_http_port = value;
124 }
125 if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) {
126 int value;
127 base::StringToInt(command_line.GetSwitchValueASCII(
128 switches::kTestingFixedHttpsPort), &value);
129 network_session_params.testing_fixed_https_port = value;
130 }
131 if (command_line.HasSwitch(switches::kHostResolverRules)) {
132 mapped_host_resolver_.reset(
133 new net::MappedHostResolver(network_session_params.host_resolver));
szym 2012/10/10 17:21:04 IMPORTANT: this will cause double-free! The Mapped
134 mapped_host_resolver_->SetRulesFromString(
135 command_line.GetSwitchValueASCII(switches::kHostResolverRules));
136 network_session_params.host_resolver = mapped_host_resolver_.get();
137 }
114 138
115 net::HttpCache* main_cache = new net::HttpCache( 139 net::HttpCache* main_cache = new net::HttpCache(
116 network_session_params, main_backend); 140 network_session_params, main_backend);
117 storage_->set_http_transaction_factory(main_cache); 141 storage_->set_http_transaction_factory(main_cache);
118 142
119 storage_->set_job_factory(new net::URLRequestJobFactoryImpl); 143 storage_->set_job_factory(new net::URLRequestJobFactoryImpl);
120 } 144 }
121 145
122 return url_request_context_.get(); 146 return url_request_context_.get();
123 } 147 }
124 148
125 scoped_refptr<base::SingleThreadTaskRunner> 149 scoped_refptr<base::SingleThreadTaskRunner>
126 ShellURLRequestContextGetter::GetNetworkTaskRunner() const { 150 ShellURLRequestContextGetter::GetNetworkTaskRunner() const {
127 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); 151 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
128 } 152 }
129 153
130 net::HostResolver* ShellURLRequestContextGetter::host_resolver() { 154 net::HostResolver* ShellURLRequestContextGetter::host_resolver() {
131 return url_request_context_->host_resolver(); 155 return url_request_context_->host_resolver();
132 } 156 }
133 157
134 } // namespace content 158 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/shell_url_request_context_getter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698