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_verifier.h" | 56 #include "net/cert/ct_verifier.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 | 94 |
91 #if !defined(USE_OPENSSL) | 95 #if !defined(USE_OPENSSL) |
92 #include "net/cert/ct_log_verifier.h" | 96 #include "net/cert/ct_log_verifier.h" |
93 #include "net/cert/multi_log_ct_verifier.h" | 97 #include "net/cert/multi_log_ct_verifier.h" |
94 #endif | 98 #endif |
95 | 99 |
96 #if defined(USE_NSS) || defined(OS_IOS) | 100 #if defined(USE_NSS) || defined(OS_IOS) |
97 #include "net/ocsp/nss_ocsp.h" | 101 #include "net/ocsp/nss_ocsp.h" |
98 #endif | 102 #endif |
99 | 103 |
100 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
101 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" | |
102 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.h" | |
103 #include "components/data_reduction_proxy/browser/data_reduction_proxy_auth_requ est_handler.h" | |
104 #include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol. h" | |
105 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) | |
106 | |
107 #if defined(OS_CHROMEOS) | 104 #if defined(OS_CHROMEOS) |
108 #include "chrome/browser/chromeos/net/cert_verify_proc_chromeos.h" | 105 #include "chrome/browser/chromeos/net/cert_verify_proc_chromeos.h" |
109 #include "chromeos/network/host_resolver_impl_chromeos.h" | 106 #include "chromeos/network/host_resolver_impl_chromeos.h" |
110 #endif | 107 #endif |
111 | 108 |
112 using content::BrowserThread; | 109 using content::BrowserThread; |
113 | 110 |
114 class SafeBrowsingURLRequestContext; | 111 class SafeBrowsingURLRequestContext; |
115 | 112 |
116 // The IOThread object must outlive any tasks posted to the IO thread before the | 113 // 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... | |
535 InitSystemRequestContext(); | 532 InitSystemRequestContext(); |
536 } | 533 } |
537 return system_url_request_context_getter_.get(); | 534 return system_url_request_context_getter_.get(); |
538 } | 535 } |
539 | 536 |
540 void IOThread::Init() { | 537 void IOThread::Init() { |
541 // Prefer to use InitAsync unless you need initialization to block | 538 // Prefer to use InitAsync unless you need initialization to block |
542 // the UI thread | 539 // the UI thread |
543 } | 540 } |
544 | 541 |
542 void IOThread::SetupDataReductionProxy( | |
543 ChromeNetworkDelegate* network_delegate) { | |
544 int flags = data_reduction_proxy::DataReductionProxyParams::kAllowed | | |
545 data_reduction_proxy::DataReductionProxyParams::kFallbackAllowed; | |
Ryan Sleevi
2014/08/28 17:21:01
Reformat
Not at Google. Contact bengr
2014/08/28 18:59:27
Done.
| |
546 if (data_reduction_proxy::DataReductionProxyParams:: | |
547 IsIncludedInAlternativeFieldTrial()) | |
548 flags |= | |
549 data_reduction_proxy::DataReductionProxyParams::kAlternativeAllowed; | |
550 if (data_reduction_proxy::DataReductionProxyParams:: | |
551 IsIncludedInPromoFieldTrial()) | |
552 flags |= data_reduction_proxy::DataReductionProxyParams::kPromoAllowed; | |
553 if (data_reduction_proxy::DataReductionProxyParams:: | |
554 IsIncludedInHoldbackFieldTrial()) | |
555 flags |= data_reduction_proxy::DataReductionProxyParams::kHoldback; | |
556 globals_->data_reduction_proxy_params.reset( | |
557 new data_reduction_proxy::DataReductionProxyParams(flags)); | |
558 globals_->data_reduction_proxy_auth_request_handler.reset( | |
559 new data_reduction_proxy::DataReductionProxyAuthRequestHandler( | |
560 DataReductionProxyChromeSettings::GetClient(), | |
561 DataReductionProxyChromeSettings::GetBuildAndPatchNumber(), | |
562 globals_->data_reduction_proxy_params.get(), | |
563 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); | |
564 // This is the same as in ProfileImplIOData except that we do not collect | |
565 // usage stats. | |
566 network_delegate->set_data_reduction_proxy_params( | |
567 globals_->data_reduction_proxy_params.get()); | |
568 network_delegate->set_data_reduction_proxy_auth_request_handler( | |
569 globals_->data_reduction_proxy_auth_request_handler.get()); | |
570 network_delegate->set_on_resolve_proxy_handler( | |
571 base::Bind(data_reduction_proxy::OnResolveProxyHandler)); | |
572 } | |
573 | |
545 void IOThread::InitAsync() { | 574 void IOThread::InitAsync() { |
546 TRACE_EVENT0("startup", "IOThread::InitAsync"); | 575 TRACE_EVENT0("startup", "IOThread::InitAsync"); |
547 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 576 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
548 | 577 |
549 #if defined(USE_NSS) || defined(OS_IOS) | 578 #if defined(USE_NSS) || defined(OS_IOS) |
550 net::SetMessageLoopForNSSHttpIO(); | 579 net::SetMessageLoopForNSSHttpIO(); |
551 #endif | 580 #endif |
552 | 581 |
553 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 582 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
554 | 583 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
628 ct_verifier->AddLog(external_log_verifier.Pass()); | 657 ct_verifier->AddLog(external_log_verifier.Pass()); |
629 } | 658 } |
630 } | 659 } |
631 #else | 660 #else |
632 if (command_line.HasSwitch(switches::kCertificateTransparencyLog)) { | 661 if (command_line.HasSwitch(switches::kCertificateTransparencyLog)) { |
633 LOG(DFATAL) << "Certificate Transparency is not yet supported in Chrome " | 662 LOG(DFATAL) << "Certificate Transparency is not yet supported in Chrome " |
634 "builds using OpenSSL."; | 663 "builds using OpenSSL."; |
635 } | 664 } |
636 #endif | 665 #endif |
637 globals_->ssl_config_service = GetSSLConfigService(); | 666 globals_->ssl_config_service = GetSSLConfigService(); |
638 | 667 SetupDataReductionProxy(network_delegate); |
639 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
640 int drp_flags = 0; | |
641 if (data_reduction_proxy::DataReductionProxyParams:: | |
642 IsIncludedInFieldTrial()) { | |
643 drp_flags |= | |
644 (data_reduction_proxy::DataReductionProxyParams::kAllowed | | |
645 data_reduction_proxy::DataReductionProxyParams::kFallbackAllowed); | |
646 } | |
647 if (data_reduction_proxy::DataReductionProxyParams:: | |
648 IsIncludedInAlternativeFieldTrial()) { | |
649 drp_flags |= | |
650 data_reduction_proxy::DataReductionProxyParams::kAlternativeAllowed; | |
651 } | |
652 if (data_reduction_proxy::DataReductionProxyParams:: | |
653 IsIncludedInPromoFieldTrial()) | |
654 drp_flags |= data_reduction_proxy::DataReductionProxyParams::kPromoAllowed; | |
655 if (data_reduction_proxy::DataReductionProxyParams:: | |
656 IsIncludedInHoldbackFieldTrial()) | |
657 drp_flags |= data_reduction_proxy::DataReductionProxyParams::kHoldback; | |
658 globals_->data_reduction_proxy_params.reset( | |
659 new data_reduction_proxy::DataReductionProxyParams(drp_flags)); | |
660 globals_->data_reduction_proxy_auth_request_handler.reset( | |
661 new data_reduction_proxy::DataReductionProxyAuthRequestHandler( | |
662 DataReductionProxyChromeSettings::GetClient(), | |
663 DataReductionProxyChromeSettings::GetBuildAndPatchNumber(), | |
664 globals_->data_reduction_proxy_params.get(), | |
665 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); | |
666 // This is the same as in ProfileImplIOData except that we do not collect | |
667 // usage stats. | |
668 network_delegate->set_data_reduction_proxy_params( | |
669 globals_->data_reduction_proxy_params.get()); | |
670 network_delegate->set_data_reduction_proxy_auth_request_handler( | |
671 globals_->data_reduction_proxy_auth_request_handler.get()); | |
672 network_delegate->set_on_resolve_proxy_handler( | |
673 base::Bind(data_reduction_proxy::OnResolveProxyHandler)); | |
674 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) | |
675 | |
676 globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( | 668 globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( |
677 globals_->host_resolver.get())); | 669 globals_->host_resolver.get())); |
678 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); | 670 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); |
679 // For the ProxyScriptFetcher, we use a direct ProxyService. | 671 // For the ProxyScriptFetcher, we use a direct ProxyService. |
680 globals_->proxy_script_fetcher_proxy_service.reset( | 672 globals_->proxy_script_fetcher_proxy_service.reset( |
681 net::ProxyService::CreateDirectWithNetLog(net_log_)); | 673 net::ProxyService::CreateDirectWithNetLog(net_log_)); |
682 // In-memory cookie store. | 674 // In-memory cookie store. |
683 globals_->system_cookie_store = | 675 globals_->system_cookie_store = |
684 content::CreateCookieStore(content::CookieStoreConfig()); | 676 content::CreateCookieStore(content::CookieStoreConfig()); |
685 // In-memory channel ID store. | 677 // In-memory channel ID store. |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1103 | 1095 |
1104 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 1096 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
1105 globals_->system_proxy_service.reset( | 1097 globals_->system_proxy_service.reset( |
1106 ProxyServiceFactory::CreateProxyService( | 1098 ProxyServiceFactory::CreateProxyService( |
1107 net_log_, | 1099 net_log_, |
1108 globals_->proxy_script_fetcher_context.get(), | 1100 globals_->proxy_script_fetcher_context.get(), |
1109 globals_->system_network_delegate.get(), | 1101 globals_->system_network_delegate.get(), |
1110 system_proxy_config_service_.release(), | 1102 system_proxy_config_service_.release(), |
1111 command_line, | 1103 command_line, |
1112 quick_check_enabled_.GetValue())); | 1104 quick_check_enabled_.GetValue())); |
1105 DCHECK(globals_->data_reduction_proxy_params); | |
1113 | 1106 |
1114 net::HttpNetworkSession::Params system_params; | 1107 net::HttpNetworkSession::Params system_params; |
1115 InitializeNetworkSessionParams(&system_params); | 1108 InitializeNetworkSessionParams(&system_params); |
1116 system_params.net_log = net_log_; | 1109 system_params.net_log = net_log_; |
1117 system_params.proxy_service = globals_->system_proxy_service.get(); | 1110 system_params.proxy_service = globals_->system_proxy_service.get(); |
1118 | 1111 |
1119 globals_->system_http_transaction_factory.reset( | 1112 globals_->system_http_transaction_factory.reset( |
1120 new net::HttpNetworkLayer( | 1113 new net::HttpNetworkLayer( |
1121 new net::HttpNetworkSession(system_params))); | 1114 new net::HttpNetworkSession(system_params))); |
1122 globals_->system_url_request_job_factory.reset( | 1115 globals_->system_url_request_job_factory.reset( |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1392 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); | 1385 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); |
1393 for (size_t i = 0; i < supported_versions.size(); ++i) { | 1386 for (size_t i = 0; i < supported_versions.size(); ++i) { |
1394 net::QuicVersion version = supported_versions[i]; | 1387 net::QuicVersion version = supported_versions[i]; |
1395 if (net::QuicVersionToString(version) == quic_version) { | 1388 if (net::QuicVersionToString(version) == quic_version) { |
1396 return version; | 1389 return version; |
1397 } | 1390 } |
1398 } | 1391 } |
1399 | 1392 |
1400 return net::QUIC_VERSION_UNSUPPORTED; | 1393 return net::QUIC_VERSION_UNSUPPORTED; |
1401 } | 1394 } |
OLD | NEW |