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/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 #include "chrome/browser/net/chrome_network_delegate.h" | 32 #include "chrome/browser/net/chrome_network_delegate.h" |
| 33 #include "chrome/browser/net/connect_interceptor.h" | 33 #include "chrome/browser/net/connect_interceptor.h" |
| 34 #include "chrome/browser/net/dns_probe_service.h" | 34 #include "chrome/browser/net/dns_probe_service.h" |
| 35 #include "chrome/browser/net/pref_proxy_config_tracker.h" | 35 #include "chrome/browser/net/pref_proxy_config_tracker.h" |
| 36 #include "chrome/browser/net/proxy_service_factory.h" | 36 #include "chrome/browser/net/proxy_service_factory.h" |
| 37 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" | 37 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" |
| 38 #include "chrome/common/chrome_content_client.h" | 38 #include "chrome/common/chrome_content_client.h" |
| 39 #include "chrome/common/chrome_switches.h" | 39 #include "chrome/common/chrome_switches.h" |
| 40 #include "chrome/common/chrome_version_info.h" | 40 #include "chrome/common/chrome_version_info.h" |
| 41 #include "chrome/common/pref_names.h" | 41 #include "chrome/common/pref_names.h" |
| 42 #include "components/data_reduction_proxy/browser/data_reduction_proxy_auth_requ est_handler.h" | |
| 43 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" | |
| 42 #include "components/data_reduction_proxy/browser/data_reduction_proxy_prefs.h" | 44 #include "components/data_reduction_proxy/browser/data_reduction_proxy_prefs.h" |
| 45 #include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol. h" | |
| 46 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings. h" | |
| 43 #include "components/policy/core/common/policy_service.h" | 47 #include "components/policy/core/common/policy_service.h" |
| 44 #include "components/variations/variations_associated_data.h" | 48 #include "components/variations/variations_associated_data.h" |
| 45 #include "content/public/browser/browser_thread.h" | 49 #include "content/public/browser/browser_thread.h" |
| 46 #include "content/public/browser/cookie_store_factory.h" | 50 #include "content/public/browser/cookie_store_factory.h" |
| 47 #include "net/base/host_mapping_rules.h" | 51 #include "net/base/host_mapping_rules.h" |
| 48 #include "net/base/net_util.h" | 52 #include "net/base/net_util.h" |
| 49 #include "net/cert/cert_verifier.h" | 53 #include "net/cert/cert_verifier.h" |
| 50 #include "net/cert/cert_verify_proc.h" | 54 #include "net/cert/cert_verify_proc.h" |
| 51 #include "net/cert/ct_known_logs.h" | 55 #include "net/cert/ct_known_logs.h" |
| 52 #include "net/cert/ct_log_verifier.h" | 56 #include "net/cert/ct_log_verifier.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 #endif | 91 #endif |
| 88 | 92 |
| 89 #if defined(ENABLE_EXTENSIONS) | 93 #if defined(ENABLE_EXTENSIONS) |
| 90 #include "chrome/browser/extensions/event_router_forwarder.h" | 94 #include "chrome/browser/extensions/event_router_forwarder.h" |
| 91 #endif | 95 #endif |
| 92 | 96 |
| 93 #if defined(USE_NSS) || defined(OS_IOS) | 97 #if defined(USE_NSS) || defined(OS_IOS) |
| 94 #include "net/ocsp/nss_ocsp.h" | 98 #include "net/ocsp/nss_ocsp.h" |
| 95 #endif | 99 #endif |
| 96 | 100 |
| 97 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
| 98 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" | |
| 99 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.h" | |
| 100 #include "components/data_reduction_proxy/browser/data_reduction_proxy_auth_requ est_handler.h" | |
| 101 #include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol. h" | |
| 102 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) | |
| 103 | |
| 104 #if defined(OS_CHROMEOS) | 101 #if defined(OS_CHROMEOS) |
| 105 #include "chrome/browser/chromeos/net/cert_verify_proc_chromeos.h" | 102 #include "chrome/browser/chromeos/net/cert_verify_proc_chromeos.h" |
| 106 #include "chromeos/network/host_resolver_impl_chromeos.h" | 103 #include "chromeos/network/host_resolver_impl_chromeos.h" |
| 107 #endif | 104 #endif |
| 108 | 105 |
| 109 using content::BrowserThread; | 106 using content::BrowserThread; |
| 110 | 107 |
| 111 class SafeBrowsingURLRequestContext; | 108 class SafeBrowsingURLRequestContext; |
| 112 | 109 |
| 113 // The IOThread object must outlive any tasks posted to the IO thread before the | 110 // The IOThread object must outlive any tasks posted to the IO thread before the |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 532 InitSystemRequestContext(); | 529 InitSystemRequestContext(); |
| 533 } | 530 } |
| 534 return system_url_request_context_getter_.get(); | 531 return system_url_request_context_getter_.get(); |
| 535 } | 532 } |
| 536 | 533 |
| 537 void IOThread::Init() { | 534 void IOThread::Init() { |
| 538 // Prefer to use InitAsync unless you need initialization to block | 535 // Prefer to use InitAsync unless you need initialization to block |
| 539 // the UI thread | 536 // the UI thread |
| 540 } | 537 } |
| 541 | 538 |
| 539 void IOThread::SetupDataReductionProxy( | |
| 540 ChromeNetworkDelegate* network_delegate) { | |
|
mmenke
2014/09/05 16:29:09
Definition order should match declaration order.
Not at Google. Contact bengr
2014/09/05 21:24:35
Done.
| |
| 541 int flags = data_reduction_proxy::DataReductionProxyParams::kAllowed | | |
| 542 data_reduction_proxy::DataReductionProxyParams::kFallbackAllowed; | |
| 543 if (data_reduction_proxy::DataReductionProxyParams:: | |
| 544 IsIncludedInAlternativeFieldTrial()) | |
|
mmenke
2014/09/05 16:29:10
Use braces in multi-line if statements (x3).
Not at Google. Contact bengr
2014/09/05 21:24:35
Done.
| |
| 545 flags |= | |
| 546 data_reduction_proxy::DataReductionProxyParams::kAlternativeAllowed; | |
| 547 if (data_reduction_proxy::DataReductionProxyParams:: | |
| 548 IsIncludedInPromoFieldTrial()) | |
| 549 flags |= data_reduction_proxy::DataReductionProxyParams::kPromoAllowed; | |
| 550 if (data_reduction_proxy::DataReductionProxyParams:: | |
| 551 IsIncludedInHoldbackFieldTrial()) | |
| 552 flags |= data_reduction_proxy::DataReductionProxyParams::kHoldback; | |
| 553 globals_->data_reduction_proxy_params.reset( | |
| 554 new data_reduction_proxy::DataReductionProxyParams(flags)); | |
| 555 globals_->data_reduction_proxy_auth_request_handler.reset( | |
| 556 new data_reduction_proxy::DataReductionProxyAuthRequestHandler( | |
| 557 DataReductionProxyChromeSettings::GetClient(), | |
| 558 DataReductionProxyChromeSettings::GetBuildAndPatchNumber(), | |
| 559 globals_->data_reduction_proxy_params.get(), | |
| 560 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); | |
| 561 // This is the same as in ProfileImplIOData except that we do not collect | |
| 562 // usage stats. | |
| 563 network_delegate->set_data_reduction_proxy_params( | |
| 564 globals_->data_reduction_proxy_params.get()); | |
| 565 network_delegate->set_data_reduction_proxy_auth_request_handler( | |
| 566 globals_->data_reduction_proxy_auth_request_handler.get()); | |
| 567 network_delegate->set_on_resolve_proxy_handler( | |
| 568 base::Bind(data_reduction_proxy::OnResolveProxyHandler)); | |
| 569 } | |
| 570 | |
| 542 void IOThread::InitAsync() { | 571 void IOThread::InitAsync() { |
| 543 TRACE_EVENT0("startup", "IOThread::InitAsync"); | 572 TRACE_EVENT0("startup", "IOThread::InitAsync"); |
| 544 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 573 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 545 | 574 |
| 546 #if defined(USE_NSS) || defined(OS_IOS) | 575 #if defined(USE_NSS) || defined(OS_IOS) |
| 547 net::SetMessageLoopForNSSHttpIO(); | 576 net::SetMessageLoopForNSSHttpIO(); |
| 548 #endif | 577 #endif |
| 549 | 578 |
| 550 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 579 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 551 | 580 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 618 << "Unable to decode CT public key."; | 647 << "Unable to decode CT public key."; |
| 619 scoped_ptr<net::CTLogVerifier> external_log_verifier( | 648 scoped_ptr<net::CTLogVerifier> external_log_verifier( |
| 620 net::CTLogVerifier::Create(ct_public_key_data, log_description)); | 649 net::CTLogVerifier::Create(ct_public_key_data, log_description)); |
| 621 CHECK(external_log_verifier) << "Unable to parse CT public key."; | 650 CHECK(external_log_verifier) << "Unable to parse CT public key."; |
| 622 VLOG(1) << "Adding log with description " << log_description; | 651 VLOG(1) << "Adding log with description " << log_description; |
| 623 ct_verifier->AddLog(external_log_verifier.Pass()); | 652 ct_verifier->AddLog(external_log_verifier.Pass()); |
| 624 } | 653 } |
| 625 } | 654 } |
| 626 | 655 |
| 627 globals_->ssl_config_service = GetSSLConfigService(); | 656 globals_->ssl_config_service = GetSSLConfigService(); |
| 628 | 657 SetupDataReductionProxy(network_delegate); |
|
mmenke
2014/09/05 16:29:09
Question: The NetworkDelegate for system context
mmenke
2014/09/05 16:29:10
Also, we never call InitDataReductionProxySettings
Not at Google. Contact bengr
2014/09/05 21:24:35
Currently, data reduction proxy is turned on and o
| |
| 629 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
| 630 int drp_flags = 0; | |
| 631 if (data_reduction_proxy::DataReductionProxyParams:: | |
| 632 IsIncludedInFieldTrial()) { | |
| 633 drp_flags |= | |
| 634 (data_reduction_proxy::DataReductionProxyParams::kAllowed | | |
| 635 data_reduction_proxy::DataReductionProxyParams::kFallbackAllowed); | |
| 636 } | |
| 637 if (data_reduction_proxy::DataReductionProxyParams:: | |
| 638 IsIncludedInAlternativeFieldTrial()) { | |
| 639 drp_flags |= | |
| 640 data_reduction_proxy::DataReductionProxyParams::kAlternativeAllowed; | |
| 641 } | |
| 642 if (data_reduction_proxy::DataReductionProxyParams:: | |
| 643 IsIncludedInPromoFieldTrial()) | |
| 644 drp_flags |= data_reduction_proxy::DataReductionProxyParams::kPromoAllowed; | |
| 645 if (data_reduction_proxy::DataReductionProxyParams:: | |
| 646 IsIncludedInHoldbackFieldTrial()) | |
| 647 drp_flags |= data_reduction_proxy::DataReductionProxyParams::kHoldback; | |
| 648 globals_->data_reduction_proxy_params.reset( | |
| 649 new data_reduction_proxy::DataReductionProxyParams(drp_flags)); | |
| 650 globals_->data_reduction_proxy_auth_request_handler.reset( | |
| 651 new data_reduction_proxy::DataReductionProxyAuthRequestHandler( | |
| 652 DataReductionProxyChromeSettings::GetClient(), | |
| 653 DataReductionProxyChromeSettings::GetBuildAndPatchNumber(), | |
| 654 globals_->data_reduction_proxy_params.get(), | |
| 655 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); | |
| 656 // This is the same as in ProfileImplIOData except that we do not collect | |
| 657 // usage stats. | |
| 658 network_delegate->set_data_reduction_proxy_params( | |
| 659 globals_->data_reduction_proxy_params.get()); | |
| 660 network_delegate->set_data_reduction_proxy_auth_request_handler( | |
| 661 globals_->data_reduction_proxy_auth_request_handler.get()); | |
| 662 network_delegate->set_on_resolve_proxy_handler( | |
| 663 base::Bind(data_reduction_proxy::OnResolveProxyHandler)); | |
| 664 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) | |
| 665 | |
| 666 globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( | 658 globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( |
| 667 globals_->host_resolver.get())); | 659 globals_->host_resolver.get())); |
| 668 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); | 660 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); |
| 669 // For the ProxyScriptFetcher, we use a direct ProxyService. | 661 // For the ProxyScriptFetcher, we use a direct ProxyService. |
| 670 globals_->proxy_script_fetcher_proxy_service.reset( | 662 globals_->proxy_script_fetcher_proxy_service.reset( |
| 671 net::ProxyService::CreateDirectWithNetLog(net_log_)); | 663 net::ProxyService::CreateDirectWithNetLog(net_log_)); |
| 672 // In-memory cookie store. | 664 // In-memory cookie store. |
| 673 globals_->system_cookie_store = | 665 globals_->system_cookie_store = |
| 674 content::CreateCookieStore(content::CookieStoreConfig()); | 666 content::CreateCookieStore(content::CookieStoreConfig()); |
| 675 // In-memory channel ID store. | 667 // In-memory channel ID store. |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1095 | 1087 |
| 1096 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 1088 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 1097 globals_->system_proxy_service.reset( | 1089 globals_->system_proxy_service.reset( |
| 1098 ProxyServiceFactory::CreateProxyService( | 1090 ProxyServiceFactory::CreateProxyService( |
| 1099 net_log_, | 1091 net_log_, |
| 1100 globals_->proxy_script_fetcher_context.get(), | 1092 globals_->proxy_script_fetcher_context.get(), |
| 1101 globals_->system_network_delegate.get(), | 1093 globals_->system_network_delegate.get(), |
| 1102 system_proxy_config_service_.release(), | 1094 system_proxy_config_service_.release(), |
| 1103 command_line, | 1095 command_line, |
| 1104 quick_check_enabled_.GetValue())); | 1096 quick_check_enabled_.GetValue())); |
| 1097 DCHECK(globals_->data_reduction_proxy_params); | |
| 1105 | 1098 |
| 1106 net::HttpNetworkSession::Params system_params; | 1099 net::HttpNetworkSession::Params system_params; |
| 1107 InitializeNetworkSessionParams(&system_params); | 1100 InitializeNetworkSessionParams(&system_params); |
| 1108 system_params.net_log = net_log_; | 1101 system_params.net_log = net_log_; |
| 1109 system_params.proxy_service = globals_->system_proxy_service.get(); | 1102 system_params.proxy_service = globals_->system_proxy_service.get(); |
| 1110 | 1103 |
| 1111 globals_->system_http_transaction_factory.reset( | 1104 globals_->system_http_transaction_factory.reset( |
| 1112 new net::HttpNetworkLayer( | 1105 new net::HttpNetworkLayer( |
| 1113 new net::HttpNetworkSession(system_params))); | 1106 new net::HttpNetworkSession(system_params))); |
| 1114 globals_->system_url_request_job_factory.reset( | 1107 globals_->system_url_request_job_factory.reset( |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1395 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); | 1388 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); |
| 1396 for (size_t i = 0; i < supported_versions.size(); ++i) { | 1389 for (size_t i = 0; i < supported_versions.size(); ++i) { |
| 1397 net::QuicVersion version = supported_versions[i]; | 1390 net::QuicVersion version = supported_versions[i]; |
| 1398 if (net::QuicVersionToString(version) == quic_version) { | 1391 if (net::QuicVersionToString(version) == quic_version) { |
| 1399 return version; | 1392 return version; |
| 1400 } | 1393 } |
| 1401 } | 1394 } |
| 1402 | 1395 |
| 1403 return net::QUIC_VERSION_UNSUPPORTED; | 1396 return net::QUIC_VERSION_UNSUPPORTED; |
| 1404 } | 1397 } |
| OLD | NEW |