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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 #include "net/cookies/cookie_monster.h" | 45 #include "net/cookies/cookie_monster.h" |
| 46 #include "net/ftp/ftp_network_layer.h" | 46 #include "net/ftp/ftp_network_layer.h" |
| 47 #include "net/http/http_auth_filter.h" | 47 #include "net/http/http_auth_filter.h" |
| 48 #include "net/http/http_auth_handler_factory.h" | 48 #include "net/http/http_auth_handler_factory.h" |
| 49 #include "net/http/http_network_layer.h" | 49 #include "net/http/http_network_layer.h" |
| 50 #include "net/http/http_network_session.h" | 50 #include "net/http/http_network_session.h" |
| 51 #include "net/http/http_server_properties_impl.h" | 51 #include "net/http/http_server_properties_impl.h" |
| 52 #include "net/proxy/proxy_config_service.h" | 52 #include "net/proxy/proxy_config_service.h" |
| 53 #include "net/proxy/proxy_script_fetcher_impl.h" | 53 #include "net/proxy/proxy_script_fetcher_impl.h" |
| 54 #include "net/proxy/proxy_service.h" | 54 #include "net/proxy/proxy_service.h" |
| 55 #include "net/url_request/url_request_throttler_manager.h" | |
| 55 | 56 |
| 56 #if defined(USE_NSS) | 57 #if defined(USE_NSS) |
| 57 #include "net/ocsp/nss_ocsp.h" | 58 #include "net/ocsp/nss_ocsp.h" |
| 58 #endif // defined(USE_NSS) | 59 #endif // defined(USE_NSS) |
| 59 | 60 |
| 60 #if defined(OS_CHROMEOS) | 61 #if defined(OS_CHROMEOS) |
| 61 #include "chrome/browser/chromeos/proxy_config_service_impl.h" | 62 #include "chrome/browser/chromeos/proxy_config_service_impl.h" |
| 62 #endif // defined(OS_CHROMEOS) | 63 #endif // defined(OS_CHROMEOS) |
| 63 | 64 |
| 64 using content::BrowserThread; | 65 using content::BrowserThread; |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 globals->http_auth_handler_factory.get()); | 212 globals->http_auth_handler_factory.get()); |
| 212 context->set_proxy_service(globals->proxy_script_fetcher_proxy_service.get()); | 213 context->set_proxy_service(globals->proxy_script_fetcher_proxy_service.get()); |
| 213 context->set_http_transaction_factory( | 214 context->set_http_transaction_factory( |
| 214 globals->proxy_script_fetcher_http_transaction_factory.get()); | 215 globals->proxy_script_fetcher_http_transaction_factory.get()); |
| 215 context->set_ftp_transaction_factory( | 216 context->set_ftp_transaction_factory( |
| 216 globals->proxy_script_fetcher_ftp_transaction_factory.get()); | 217 globals->proxy_script_fetcher_ftp_transaction_factory.get()); |
| 217 context->set_cookie_store(globals->system_cookie_store.get()); | 218 context->set_cookie_store(globals->system_cookie_store.get()); |
| 218 context->set_server_bound_cert_service( | 219 context->set_server_bound_cert_service( |
| 219 globals->system_server_bound_cert_service.get()); | 220 globals->system_server_bound_cert_service.get()); |
| 220 context->set_network_delegate(globals->system_network_delegate.get()); | 221 context->set_network_delegate(globals->system_network_delegate.get()); |
| 222 context->set_throttler_manager(globals->throttler_manager.get()); | |
|
willchan no longer on Chromium
2012/05/02 16:40:07
Just doublechecking you want this one. This is for
Jói
2012/05/02 16:45:28
On further reflection I don't think we need it the
| |
| 221 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the | 223 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the |
| 222 // system URLRequestContext too. There's no reason this should be tied to a | 224 // system URLRequestContext too. There's no reason this should be tied to a |
| 223 // profile. | 225 // profile. |
| 224 return context; | 226 return context; |
| 225 } | 227 } |
| 226 | 228 |
| 227 scoped_refptr<net::URLRequestContext> | 229 scoped_refptr<net::URLRequestContext> |
| 228 ConstructSystemRequestContext(IOThread::Globals* globals, | 230 ConstructSystemRequestContext(IOThread::Globals* globals, |
| 229 net::NetLog* net_log) { | 231 net::NetLog* net_log) { |
| 230 scoped_refptr<net::URLRequestContext> context( | 232 scoped_refptr<net::URLRequestContext> context( |
| 231 new SystemURLRequestContext); | 233 new SystemURLRequestContext); |
| 232 context->set_net_log(net_log); | 234 context->set_net_log(net_log); |
| 233 context->set_host_resolver(globals->host_resolver.get()); | 235 context->set_host_resolver(globals->host_resolver.get()); |
| 234 context->set_cert_verifier(globals->cert_verifier.get()); | 236 context->set_cert_verifier(globals->cert_verifier.get()); |
| 235 context->set_transport_security_state( | 237 context->set_transport_security_state( |
| 236 globals->transport_security_state.get()); | 238 globals->transport_security_state.get()); |
| 237 context->set_http_auth_handler_factory( | 239 context->set_http_auth_handler_factory( |
| 238 globals->http_auth_handler_factory.get()); | 240 globals->http_auth_handler_factory.get()); |
| 239 context->set_proxy_service(globals->system_proxy_service.get()); | 241 context->set_proxy_service(globals->system_proxy_service.get()); |
| 240 context->set_http_transaction_factory( | 242 context->set_http_transaction_factory( |
| 241 globals->system_http_transaction_factory.get()); | 243 globals->system_http_transaction_factory.get()); |
| 242 context->set_ftp_transaction_factory( | 244 context->set_ftp_transaction_factory( |
| 243 globals->system_ftp_transaction_factory.get()); | 245 globals->system_ftp_transaction_factory.get()); |
| 244 context->set_cookie_store(globals->system_cookie_store.get()); | 246 context->set_cookie_store(globals->system_cookie_store.get()); |
| 245 context->set_server_bound_cert_service( | 247 context->set_server_bound_cert_service( |
| 246 globals->system_server_bound_cert_service.get()); | 248 globals->system_server_bound_cert_service.get()); |
| 249 context->set_throttler_manager(globals->throttler_manager.get()); | |
| 247 return context; | 250 return context; |
| 248 } | 251 } |
| 249 | 252 |
| 250 } // namespace | 253 } // namespace |
| 251 | 254 |
| 252 class SystemURLRequestContextGetter : public net::URLRequestContextGetter { | 255 class SystemURLRequestContextGetter : public net::URLRequestContextGetter { |
| 253 public: | 256 public: |
| 254 explicit SystemURLRequestContextGetter(IOThread* io_thread); | 257 explicit SystemURLRequestContextGetter(IOThread* io_thread); |
| 255 | 258 |
| 256 // Implementation for net::UrlRequestContextGetter. | 259 // Implementation for net::UrlRequestContextGetter. |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 436 globals_->http_server_properties.get(); | 439 globals_->http_server_properties.get(); |
| 437 session_params.net_log = net_log_; | 440 session_params.net_log = net_log_; |
| 438 session_params.ssl_config_service = globals_->ssl_config_service; | 441 session_params.ssl_config_service = globals_->ssl_config_service; |
| 439 scoped_refptr<net::HttpNetworkSession> network_session( | 442 scoped_refptr<net::HttpNetworkSession> network_session( |
| 440 new net::HttpNetworkSession(session_params)); | 443 new net::HttpNetworkSession(session_params)); |
| 441 globals_->proxy_script_fetcher_http_transaction_factory.reset( | 444 globals_->proxy_script_fetcher_http_transaction_factory.reset( |
| 442 new net::HttpNetworkLayer(network_session)); | 445 new net::HttpNetworkLayer(network_session)); |
| 443 globals_->proxy_script_fetcher_ftp_transaction_factory.reset( | 446 globals_->proxy_script_fetcher_ftp_transaction_factory.reset( |
| 444 new net::FtpNetworkLayer(globals_->host_resolver.get())); | 447 new net::FtpNetworkLayer(globals_->host_resolver.get())); |
| 445 | 448 |
| 449 globals_->throttler_manager.reset(new net::URLRequestThrottlerManager()); | |
| 450 // Always done in production, disabled only for unit tests. | |
| 451 globals_->throttler_manager->set_enable_thread_checks(true); | |
| 452 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 453 switches::kDisableExtensionsHttpThrottling)) { | |
| 454 globals_->throttler_manager->set_enforce_throttling(false); | |
| 455 } | |
| 456 globals_->throttler_manager->set_net_log(net_log_); | |
| 457 | |
| 446 globals_->proxy_script_fetcher_context = | 458 globals_->proxy_script_fetcher_context = |
| 447 ConstructProxyScriptFetcherContext(globals_, net_log_); | 459 ConstructProxyScriptFetcherContext(globals_, net_log_); |
| 448 | 460 |
| 449 sdch_manager_ = new net::SdchManager(); | 461 sdch_manager_ = new net::SdchManager(); |
| 450 | 462 |
| 451 // InitSystemRequestContext turns right around and posts a task back | 463 // InitSystemRequestContext turns right around and posts a task back |
| 452 // to the IO thread, so we can't let it run until we know the IO | 464 // to the IO thread, so we can't let it run until we know the IO |
| 453 // thread has started. | 465 // thread has started. |
| 454 // | 466 // |
| 455 // Note that since we are at BrowserThread::Init time, the UI thread | 467 // Note that since we are at BrowserThread::Init time, the UI thread |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 611 new net::HttpNetworkLayer( | 623 new net::HttpNetworkLayer( |
| 612 new net::HttpNetworkSession(system_params))); | 624 new net::HttpNetworkSession(system_params))); |
| 613 globals_->system_ftp_transaction_factory.reset( | 625 globals_->system_ftp_transaction_factory.reset( |
| 614 new net::FtpNetworkLayer(globals_->host_resolver.get())); | 626 new net::FtpNetworkLayer(globals_->host_resolver.get())); |
| 615 globals_->system_request_context = | 627 globals_->system_request_context = |
| 616 ConstructSystemRequestContext(globals_, net_log_); | 628 ConstructSystemRequestContext(globals_, net_log_); |
| 617 | 629 |
| 618 sdch_manager_->set_sdch_fetcher( | 630 sdch_manager_->set_sdch_fetcher( |
| 619 new SdchDictionaryFetcher(system_url_request_context_getter_.get())); | 631 new SdchDictionaryFetcher(system_url_request_context_getter_.get())); |
| 620 } | 632 } |
| OLD | NEW |