Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "chrome/browser/io_thread.h" | 5 #include "chrome/browser/io_thread.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 | 189 |
| 190 net_log_->AddGlobalEntry(net::NetLog::TYPE_NETWORK_IP_ADDRESSES_CHANGED, | 190 net_log_->AddGlobalEntry(net::NetLog::TYPE_NETWORK_IP_ADDRESSES_CHANGED, |
| 191 NULL); | 191 NULL); |
| 192 } | 192 } |
| 193 | 193 |
| 194 private: | 194 private: |
| 195 net::NetLog* net_log_; | 195 net::NetLog* net_log_; |
| 196 DISALLOW_COPY_AND_ASSIGN(LoggingNetworkChangeObserver); | 196 DISALLOW_COPY_AND_ASSIGN(LoggingNetworkChangeObserver); |
| 197 }; | 197 }; |
| 198 | 198 |
| 199 // Create a separate request context for PAC fetches to avoid reference cycles. | 199 // Create a separate request context for PAC fetches to avoid reference cycles. |
|
eroman
2012/05/04 04:27:02
nit: I wander if "reference cycles" is the right w
| |
| 200 // See IOThread::Globals for details. | 200 // See IOThread::Globals for details. |
| 201 scoped_refptr<net::URLRequestContext> | 201 net::URLRequestContext* |
| 202 ConstructProxyScriptFetcherContext(IOThread::Globals* globals, | 202 ConstructProxyScriptFetcherContext(IOThread::Globals* globals, |
| 203 net::NetLog* net_log) { | 203 net::NetLog* net_log) { |
| 204 scoped_refptr<net::URLRequestContext> context( | 204 net::URLRequestContext* context = new URLRequestContextWithUserAgent; |
| 205 new URLRequestContextWithUserAgent); | |
| 206 context->set_net_log(net_log); | 205 context->set_net_log(net_log); |
| 207 context->set_host_resolver(globals->host_resolver.get()); | 206 context->set_host_resolver(globals->host_resolver.get()); |
| 208 context->set_cert_verifier(globals->cert_verifier.get()); | 207 context->set_cert_verifier(globals->cert_verifier.get()); |
| 209 context->set_transport_security_state( | 208 context->set_transport_security_state( |
| 210 globals->transport_security_state.get()); | 209 globals->transport_security_state.get()); |
| 211 context->set_http_auth_handler_factory( | 210 context->set_http_auth_handler_factory( |
| 212 globals->http_auth_handler_factory.get()); | 211 globals->http_auth_handler_factory.get()); |
| 213 context->set_proxy_service(globals->proxy_script_fetcher_proxy_service.get()); | 212 context->set_proxy_service(globals->proxy_script_fetcher_proxy_service.get()); |
| 214 context->set_http_transaction_factory( | 213 context->set_http_transaction_factory( |
| 215 globals->proxy_script_fetcher_http_transaction_factory.get()); | 214 globals->proxy_script_fetcher_http_transaction_factory.get()); |
| 216 context->set_ftp_transaction_factory( | 215 context->set_ftp_transaction_factory( |
| 217 globals->proxy_script_fetcher_ftp_transaction_factory.get()); | 216 globals->proxy_script_fetcher_ftp_transaction_factory.get()); |
| 218 context->set_cookie_store(globals->system_cookie_store.get()); | 217 context->set_cookie_store(globals->system_cookie_store.get()); |
| 219 context->set_server_bound_cert_service( | 218 context->set_server_bound_cert_service( |
| 220 globals->system_server_bound_cert_service.get()); | 219 globals->system_server_bound_cert_service.get()); |
| 221 context->set_network_delegate(globals->system_network_delegate.get()); | 220 context->set_network_delegate(globals->system_network_delegate.get()); |
| 222 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the | 221 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the |
| 223 // system URLRequestContext too. There's no reason this should be tied to a | 222 // system URLRequestContext too. There's no reason this should be tied to a |
| 224 // profile. | 223 // profile. |
| 225 return context; | 224 return context; |
| 226 } | 225 } |
| 227 | 226 |
| 228 scoped_refptr<net::URLRequestContext> | 227 net::URLRequestContext* |
| 229 ConstructSystemRequestContext(IOThread::Globals* globals, | 228 ConstructSystemRequestContext(IOThread::Globals* globals, |
| 230 net::NetLog* net_log) { | 229 net::NetLog* net_log) { |
| 231 scoped_refptr<net::URLRequestContext> context( | 230 net::URLRequestContext* context = new SystemURLRequestContext; |
| 232 new SystemURLRequestContext); | |
| 233 context->set_net_log(net_log); | 231 context->set_net_log(net_log); |
| 234 context->set_host_resolver(globals->host_resolver.get()); | 232 context->set_host_resolver(globals->host_resolver.get()); |
| 235 context->set_cert_verifier(globals->cert_verifier.get()); | 233 context->set_cert_verifier(globals->cert_verifier.get()); |
| 236 context->set_transport_security_state( | 234 context->set_transport_security_state( |
| 237 globals->transport_security_state.get()); | 235 globals->transport_security_state.get()); |
| 238 context->set_http_auth_handler_factory( | 236 context->set_http_auth_handler_factory( |
| 239 globals->http_auth_handler_factory.get()); | 237 globals->http_auth_handler_factory.get()); |
| 240 context->set_proxy_service(globals->system_proxy_service.get()); | 238 context->set_proxy_service(globals->system_proxy_service.get()); |
| 241 context->set_http_transaction_factory( | 239 context->set_http_transaction_factory( |
| 242 globals->system_http_transaction_factory.get()); | 240 globals->system_http_transaction_factory.get()); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 273 IOThread* io_thread) | 271 IOThread* io_thread) |
| 274 : io_thread_(io_thread), | 272 : io_thread_(io_thread), |
| 275 io_message_loop_proxy_( | 273 io_message_loop_proxy_( |
| 276 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)) { | 274 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)) { |
| 277 } | 275 } |
| 278 | 276 |
| 279 SystemURLRequestContextGetter::~SystemURLRequestContextGetter() {} | 277 SystemURLRequestContextGetter::~SystemURLRequestContextGetter() {} |
| 280 | 278 |
| 281 net::URLRequestContext* SystemURLRequestContextGetter::GetURLRequestContext() { | 279 net::URLRequestContext* SystemURLRequestContextGetter::GetURLRequestContext() { |
| 282 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 280 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 283 DCHECK(io_thread_->globals()->system_request_context); | 281 DCHECK(io_thread_->globals()->system_request_context.get()); |
| 284 | 282 |
| 285 return io_thread_->globals()->system_request_context; | 283 return io_thread_->globals()->system_request_context.get(); |
| 286 } | 284 } |
| 287 | 285 |
| 288 scoped_refptr<base::MessageLoopProxy> | 286 scoped_refptr<base::MessageLoopProxy> |
| 289 SystemURLRequestContextGetter::GetIOMessageLoopProxy() const { | 287 SystemURLRequestContextGetter::GetIOMessageLoopProxy() const { |
| 290 return io_message_loop_proxy_; | 288 return io_message_loop_proxy_; |
| 291 } | 289 } |
| 292 | 290 |
| 293 IOThread::Globals:: | 291 IOThread::Globals:: |
| 294 SystemRequestContextLeakChecker::SystemRequestContextLeakChecker( | 292 SystemRequestContextLeakChecker::SystemRequestContextLeakChecker( |
| 295 Globals* globals) | 293 Globals* globals) |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 447 | 445 |
| 448 globals_->throttler_manager.reset(new net::URLRequestThrottlerManager()); | 446 globals_->throttler_manager.reset(new net::URLRequestThrottlerManager()); |
| 449 // Always done in production, disabled only for unit tests. | 447 // Always done in production, disabled only for unit tests. |
| 450 globals_->throttler_manager->set_enable_thread_checks(true); | 448 globals_->throttler_manager->set_enable_thread_checks(true); |
| 451 if (CommandLine::ForCurrentProcess()->HasSwitch( | 449 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 452 switches::kDisableExtensionsHttpThrottling)) { | 450 switches::kDisableExtensionsHttpThrottling)) { |
| 453 globals_->throttler_manager->set_enforce_throttling(false); | 451 globals_->throttler_manager->set_enforce_throttling(false); |
| 454 } | 452 } |
| 455 globals_->throttler_manager->set_net_log(net_log_); | 453 globals_->throttler_manager->set_net_log(net_log_); |
| 456 | 454 |
| 457 globals_->proxy_script_fetcher_context = | 455 globals_->proxy_script_fetcher_context.reset( |
| 458 ConstructProxyScriptFetcherContext(globals_, net_log_); | 456 ConstructProxyScriptFetcherContext(globals_, net_log_)); |
| 459 | 457 |
| 460 sdch_manager_ = new net::SdchManager(); | 458 sdch_manager_ = new net::SdchManager(); |
| 461 | 459 |
| 462 // InitSystemRequestContext turns right around and posts a task back | 460 // InitSystemRequestContext turns right around and posts a task back |
| 463 // to the IO thread, so we can't let it run until we know the IO | 461 // to the IO thread, so we can't let it run until we know the IO |
| 464 // thread has started. | 462 // thread has started. |
| 465 // | 463 // |
| 466 // Note that since we are at BrowserThread::Init time, the UI thread | 464 // Note that since we are at BrowserThread::Init time, the UI thread |
| 467 // is blocked waiting for the thread to start. Therefore, posting | 465 // is blocked waiting for the thread to start. Therefore, posting |
| 468 // this task to the main thread's message loop here is guaranteed to | 466 // this task to the main thread's message loop here is guaranteed to |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 593 | 591 |
| 594 void IOThread::InitSystemRequestContextOnIOThread() { | 592 void IOThread::InitSystemRequestContextOnIOThread() { |
| 595 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 593 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 596 DCHECK(!globals_->system_proxy_service.get()); | 594 DCHECK(!globals_->system_proxy_service.get()); |
| 597 DCHECK(system_proxy_config_service_.get()); | 595 DCHECK(system_proxy_config_service_.get()); |
| 598 | 596 |
| 599 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 597 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 600 globals_->system_proxy_service.reset( | 598 globals_->system_proxy_service.reset( |
| 601 ProxyServiceFactory::CreateProxyService( | 599 ProxyServiceFactory::CreateProxyService( |
| 602 net_log_, | 600 net_log_, |
| 603 globals_->proxy_script_fetcher_context, | 601 globals_->proxy_script_fetcher_context.get(), |
| 604 system_proxy_config_service_.release(), | 602 system_proxy_config_service_.release(), |
| 605 command_line)); | 603 command_line)); |
| 606 net::HttpNetworkSession::Params system_params; | 604 net::HttpNetworkSession::Params system_params; |
| 607 system_params.host_resolver = globals_->host_resolver.get(); | 605 system_params.host_resolver = globals_->host_resolver.get(); |
| 608 system_params.cert_verifier = globals_->cert_verifier.get(); | 606 system_params.cert_verifier = globals_->cert_verifier.get(); |
| 609 system_params.server_bound_cert_service = | 607 system_params.server_bound_cert_service = |
| 610 globals_->system_server_bound_cert_service.get(); | 608 globals_->system_server_bound_cert_service.get(); |
| 611 system_params.transport_security_state = | 609 system_params.transport_security_state = |
| 612 globals_->transport_security_state.get(); | 610 globals_->transport_security_state.get(); |
| 613 system_params.ssl_host_info_factory = NULL; | 611 system_params.ssl_host_info_factory = NULL; |
| 614 system_params.proxy_service = globals_->system_proxy_service.get(); | 612 system_params.proxy_service = globals_->system_proxy_service.get(); |
| 615 system_params.ssl_config_service = globals_->ssl_config_service.get(); | 613 system_params.ssl_config_service = globals_->ssl_config_service.get(); |
| 616 system_params.http_auth_handler_factory = | 614 system_params.http_auth_handler_factory = |
| 617 globals_->http_auth_handler_factory.get(); | 615 globals_->http_auth_handler_factory.get(); |
| 618 system_params.http_server_properties = globals_->http_server_properties.get(); | 616 system_params.http_server_properties = globals_->http_server_properties.get(); |
| 619 system_params.network_delegate = globals_->system_network_delegate.get(); | 617 system_params.network_delegate = globals_->system_network_delegate.get(); |
| 620 system_params.net_log = net_log_; | 618 system_params.net_log = net_log_; |
| 621 globals_->system_http_transaction_factory.reset( | 619 globals_->system_http_transaction_factory.reset( |
| 622 new net::HttpNetworkLayer( | 620 new net::HttpNetworkLayer( |
| 623 new net::HttpNetworkSession(system_params))); | 621 new net::HttpNetworkSession(system_params))); |
| 624 globals_->system_ftp_transaction_factory.reset( | 622 globals_->system_ftp_transaction_factory.reset( |
| 625 new net::FtpNetworkLayer(globals_->host_resolver.get())); | 623 new net::FtpNetworkLayer(globals_->host_resolver.get())); |
| 626 globals_->system_request_context = | 624 globals_->system_request_context.reset( |
| 627 ConstructSystemRequestContext(globals_, net_log_); | 625 ConstructSystemRequestContext(globals_, net_log_)); |
| 628 | 626 |
| 629 sdch_manager_->set_sdch_fetcher( | 627 sdch_manager_->set_sdch_fetcher( |
| 630 new SdchDictionaryFetcher(system_url_request_context_getter_.get())); | 628 new SdchDictionaryFetcher(system_url_request_context_getter_.get())); |
| 631 } | 629 } |
| OLD | NEW |