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

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

Issue 10912132: Move ProxyConfigService construction onto the IO thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adjust comments 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
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 "net/url_request/url_request_context_builder.h" 5 #include "net/url_request/url_request_context_builder.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 base::Thread::Options(MessageLoop::TYPE_IO, 0)); 138 base::Thread::Options(MessageLoop::TYPE_IO, 0));
139 } 139 }
140 140
141 scoped_refptr<base::MessageLoopProxy> cache_message_loop_proxy() { 141 scoped_refptr<base::MessageLoopProxy> cache_message_loop_proxy() {
142 DCHECK(cache_thread_.IsRunning()); 142 DCHECK(cache_thread_.IsRunning());
143 return cache_thread_.message_loop_proxy(); 143 return cache_thread_.message_loop_proxy();
144 } 144 }
145 145
146 void StartFileThread() { 146 void StartFileThread() {
147 file_thread_.StartWithOptions( 147 file_thread_.StartWithOptions(
148 base::Thread::Options(MessageLoop::TYPE_DEFAULT, 0)); 148 base::Thread::Options(MessageLoop::TYPE_IO, 0));
149 } 149 }
150 150
151 MessageLoop* file_message_loop() { 151 MessageLoop* file_message_loop() {
152 DCHECK(file_thread_.IsRunning()); 152 DCHECK(file_thread_.IsRunning());
153 return file_thread_.message_loop(); 153 return file_thread_.message_loop();
154 } 154 }
155 155
156 virtual const std::string& GetUserAgent( 156 virtual const std::string& GetUserAgent(
157 const GURL& /* url */) const OVERRIDE { 157 const GURL& /* url */) const OVERRIDE {
158 return user_agent_; 158 return user_agent_;
(...skipping 28 matching lines...) Expand all
187 http_pipelining_enabled(false), 187 http_pipelining_enabled(false),
188 testing_fixed_http_port(0), 188 testing_fixed_http_port(0),
189 testing_fixed_https_port(0), 189 testing_fixed_https_port(0),
190 trusted_spdy_proxy() {} 190 trusted_spdy_proxy() {}
191 191
192 URLRequestContextBuilder::HttpNetworkSessionParams::~HttpNetworkSessionParams() 192 URLRequestContextBuilder::HttpNetworkSessionParams::~HttpNetworkSessionParams()
193 {} 193 {}
194 194
195 URLRequestContextBuilder::URLRequestContextBuilder() 195 URLRequestContextBuilder::URLRequestContextBuilder()
196 : ftp_enabled_(false), 196 : ftp_enabled_(false),
197 #if defined(OS_LINUX)
198 glib_task_runner_(NULL),
199 #endif // defined(OS_LINUX)
197 http_cache_enabled_(true) {} 200 http_cache_enabled_(true) {}
201
198 URLRequestContextBuilder::~URLRequestContextBuilder() {} 202 URLRequestContextBuilder::~URLRequestContextBuilder() {}
199 203
200 #if defined(OS_LINUX) 204 #if defined(OS_LINUX)
201 void URLRequestContextBuilder::set_proxy_config_service( 205 void URLRequestContextBuilder::set_glib_task_runner(
202 ProxyConfigService* proxy_config_service) { 206 base::SingleThreadTaskRunner* glib_task_runner) {
203 proxy_config_service_.reset(proxy_config_service); 207 glib_task_runner_ = glib_task_runner;
204 } 208 }
205 #endif // defined(OS_LINUX) 209 #endif // defined(OS_LINUX)
206 210
207 URLRequestContext* URLRequestContextBuilder::Build() { 211 URLRequestContext* URLRequestContextBuilder::Build() {
208 BasicURLRequestContext* context = new BasicURLRequestContext; 212 BasicURLRequestContext* context = new BasicURLRequestContext;
209 URLRequestContextStorage* storage = context->storage(); 213 URLRequestContextStorage* storage = context->storage();
210 214
211 context->set_user_agent(user_agent_); 215 context->set_user_agent(user_agent_);
212 216
213 BasicNetworkDelegate* network_delegate = new BasicNetworkDelegate; 217 BasicNetworkDelegate* network_delegate = new BasicNetworkDelegate;
214 storage->set_network_delegate(network_delegate); 218 storage->set_network_delegate(network_delegate);
215 219
216 net::HostResolver* host_resolver = net::CreateSystemHostResolver( 220 net::HostResolver* host_resolver = net::CreateSystemHostResolver(
217 host_resolver_params_.parallelism, 221 host_resolver_params_.parallelism,
218 host_resolver_params_.retry_attempts, 222 host_resolver_params_.retry_attempts,
219 NULL /* no NetLog */); 223 NULL /* no NetLog */);
220 storage->set_host_resolver(host_resolver); 224 storage->set_host_resolver(host_resolver);
221 225
222 if (ftp_enabled_) { 226 if (ftp_enabled_) {
223 storage->set_ftp_transaction_factory(new FtpNetworkLayer(host_resolver)); 227 storage->set_ftp_transaction_factory(new FtpNetworkLayer(host_resolver));
224 } 228 }
225 229
226 context->StartFileThread(); 230 context->StartFileThread();
227 231
228 // TODO(willchan): Switch to using this code when
229 // ProxyService::CreateSystemProxyConfigService()'s signature doesn't suck.
230 #if defined(OS_LINUX)
231 ProxyConfigService* proxy_config_service = proxy_config_service_.release();
232 #else
233 ProxyConfigService* proxy_config_service =
234 ProxyService::CreateSystemProxyConfigService(
235 base::ThreadTaskRunnerHandle::Get(),
236 context->file_message_loop());
237 #endif // defined(OS_LINUX)
238 storage->set_proxy_service( 232 storage->set_proxy_service(
239 ProxyService::CreateUsingSystemProxyResolver( 233 ProxyService::CreateUsingSystemProxyResolver(
240 proxy_config_service, 234 ProxyService::CreateSystemProxyConfigService(
235 #if defined(OS_LINUX)
236 glib_task_runner_,
237 #else
238 NULL,
239 #endif // defined(OS_LINUX)
240 context->file_message_loop()),
241 4, // TODO(willchan): Find a better constant somewhere. 241 4, // TODO(willchan): Find a better constant somewhere.
242 context->net_log())); 242 context->net_log()));
243 storage->set_ssl_config_service(new net::SSLConfigServiceDefaults); 243 storage->set_ssl_config_service(new net::SSLConfigServiceDefaults);
244 storage->set_http_auth_handler_factory( 244 storage->set_http_auth_handler_factory(
245 net::HttpAuthHandlerRegistryFactory::CreateDefault(host_resolver)); 245 net::HttpAuthHandlerRegistryFactory::CreateDefault(host_resolver));
246 storage->set_cookie_store(new CookieMonster(NULL, NULL)); 246 storage->set_cookie_store(new CookieMonster(NULL, NULL));
247 storage->set_transport_security_state(new net::TransportSecurityState()); 247 storage->set_transport_security_state(new net::TransportSecurityState());
248 storage->set_http_server_properties(new net::HttpServerPropertiesImpl); 248 storage->set_http_server_properties(new net::HttpServerPropertiesImpl);
249 storage->set_cert_verifier(CertVerifier::CreateDefault()); 249 storage->set_cert_verifier(CertVerifier::CreateDefault());
250 250
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 http_transaction_factory = new HttpNetworkLayer(network_session); 302 http_transaction_factory = new HttpNetworkLayer(network_session);
303 } 303 }
304 storage->set_http_transaction_factory(http_transaction_factory); 304 storage->set_http_transaction_factory(http_transaction_factory);
305 305
306 // TODO(willchan): Support sdch. 306 // TODO(willchan): Support sdch.
307 307
308 return context; 308 return context;
309 } 309 }
310 310
311 } // namespace net 311 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698