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/chrome_url_request_context.h" | 33 #include "chrome/browser/net/chrome_url_request_context.h" |
34 #include "chrome/browser/net/connect_interceptor.h" | 34 #include "chrome/browser/net/connect_interceptor.h" |
35 #include "chrome/browser/net/dns_probe_service.h" | 35 #include "chrome/browser/net/dns_probe_service.h" |
36 #include "chrome/browser/net/pref_proxy_config_tracker.h" | 36 #include "chrome/browser/net/pref_proxy_config_tracker.h" |
37 #include "chrome/browser/net/proxy_service_factory.h" | 37 #include "chrome/browser/net/proxy_service_factory.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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 | 91 |
88 #if !defined(USE_OPENSSL) | 92 #if !defined(USE_OPENSSL) |
89 #include "net/cert/ct_log_verifier.h" | 93 #include "net/cert/ct_log_verifier.h" |
90 #include "net/cert/multi_log_ct_verifier.h" | 94 #include "net/cert/multi_log_ct_verifier.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(OS_ANDROID) || defined(OS_IOS) | |
98 #include "components/data_reduction_proxy/browser/data_reduction_proxy_auth_requ est_handler.h" | |
99 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" | |
100 #include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol. h" | |
101 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings. h" | |
102 #endif | |
103 | |
104 #if defined(OS_CHROMEOS) | 101 #if defined(OS_CHROMEOS) |
105 #include "chrome/browser/chromeos/login/users/user_manager.h" | 102 #include "chrome/browser/chromeos/login/users/user_manager.h" |
106 #include "chrome/browser/chromeos/net/cert_verify_proc_chromeos.h" | 103 #include "chrome/browser/chromeos/net/cert_verify_proc_chromeos.h" |
107 #include "chromeos/network/host_resolver_impl_chromeos.h" | 104 #include "chromeos/network/host_resolver_impl_chromeos.h" |
108 #endif | 105 #endif |
109 | 106 |
110 using content::BrowserThread; | 107 using content::BrowserThread; |
111 | |
112 #if defined(OS_ANDROID) || defined(OS_IOS) | |
113 using data_reduction_proxy::DataReductionProxyAuthRequestHandler; | 108 using data_reduction_proxy::DataReductionProxyAuthRequestHandler; |
114 using data_reduction_proxy::DataReductionProxyParams; | 109 using data_reduction_proxy::DataReductionProxyParams; |
115 using data_reduction_proxy::DataReductionProxyUsageStats; | 110 using data_reduction_proxy::DataReductionProxyUsageStats; |
116 using data_reduction_proxy::DataReductionProxySettings; | 111 using data_reduction_proxy::DataReductionProxySettings; |
117 #endif | |
118 | 112 |
119 class SafeBrowsingURLRequestContext; | 113 class SafeBrowsingURLRequestContext; |
120 | 114 |
121 // The IOThread object must outlive any tasks posted to the IO thread before the | 115 // The IOThread object must outlive any tasks posted to the IO thread before the |
122 // Quit task, so base::Bind() calls are not refcounted. | 116 // Quit task, so base::Bind() calls are not refcounted. |
123 | 117 |
124 namespace { | 118 namespace { |
125 | 119 |
126 const char kQuicFieldTrialName[] = "QUIC"; | 120 const char kQuicFieldTrialName[] = "QUIC"; |
127 const char kQuicFieldTrialEnabledGroupName[] = "Enabled"; | 121 const char kQuicFieldTrialEnabledGroupName[] = "Enabled"; |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
538 InitSystemRequestContext(); | 532 InitSystemRequestContext(); |
539 } | 533 } |
540 return system_url_request_context_getter_.get(); | 534 return system_url_request_context_getter_.get(); |
541 } | 535 } |
542 | 536 |
543 void IOThread::Init() { | 537 void IOThread::Init() { |
544 // Prefer to use InitAsync unless you need initialization to block | 538 // Prefer to use InitAsync unless you need initialization to block |
545 // the UI thread | 539 // the UI thread |
546 } | 540 } |
547 | 541 |
542 void IOThread::SetupDataReductionProxy( | |
543 ChromeNetworkDelegate* network_delegate) { | |
544 int drp_flags = 0; | |
Ryan Sleevi
2014/07/22 01:56:30
drop the drp_. Don't abbreviate like that, but thi
Not at Google. Contact bengr
2014/07/22 23:03:52
Done.
| |
545 // TODO(kundaji): Gate instantitation of all data reduction classes based | |
546 // on this method. | |
547 if (DataReductionProxyParams::IsIncludedInFieldTrial()) { | |
Ryan Sleevi
2014/07/23 00:54:44
Procedurally, this has the effect of enabling the
Not at Google. Contact bengr
2014/08/26 17:31:08
Removed trial code. Launching for all users.
| |
548 drp_flags = DataReductionProxyParams::kAllowed | | |
549 DataReductionProxyParams::kFallbackAllowed; | |
550 if (DataReductionProxyParams::IsIncludedInAlternativeFieldTrial()) | |
551 drp_flags |= DataReductionProxyParams::kAlternativeAllowed; | |
552 if (DataReductionProxyParams::IsIncludedInPromoFieldTrial()) | |
553 drp_flags |= DataReductionProxyParams::kPromoAllowed; | |
554 } | |
555 DataReductionProxyParams* proxy_params = | |
556 new DataReductionProxyParams(drp_flags); | |
557 globals_->data_reduction_proxy_params.reset(proxy_params); | |
558 globals_->data_reduction_proxy_auth_request_handler.reset( | |
559 new DataReductionProxyAuthRequestHandler(proxy_params)); | |
560 globals_->on_resolve_proxy_handler = | |
561 ChromeNetworkDelegate::OnResolveProxyHandler( | |
562 base::Bind(data_reduction_proxy::OnResolveProxyHandler)); | |
Ryan Sleevi
2014/07/22 08:22:24
As mentioned in past discussions, there are concer
bengr
2014/07/22 18:26:55
What past discussions are you referring to? I had
| |
563 DataReductionProxyUsageStats* proxy_usage_stats = | |
564 new DataReductionProxyUsageStats(proxy_params, | |
565 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), | |
566 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | |
567 network_delegate->set_data_reduction_proxy_params(proxy_params); | |
568 globals_->data_reduction_proxy_usage_stats.reset(proxy_usage_stats); | |
569 network_delegate->set_data_reduction_proxy_usage_stats(proxy_usage_stats); | |
570 network_delegate->set_data_reduction_proxy_auth_request_handler( | |
571 globals_->data_reduction_proxy_auth_request_handler.get()); | |
572 } | |
573 | |
548 void IOThread::InitAsync() { | 574 void IOThread::InitAsync() { |
549 TRACE_EVENT0("startup", "IOThread::InitAsync"); | 575 TRACE_EVENT0("startup", "IOThread::InitAsync"); |
550 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 576 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
551 | 577 |
552 #if defined(USE_NSS) || defined(OS_IOS) | 578 #if defined(USE_NSS) || defined(OS_IOS) |
553 net::SetMessageLoopForNSSHttpIO(); | 579 net::SetMessageLoopForNSSHttpIO(); |
554 #endif | 580 #endif |
555 | 581 |
556 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 582 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
557 | 583 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
631 ct_verifier->AddLog(external_log_verifier.Pass()); | 657 ct_verifier->AddLog(external_log_verifier.Pass()); |
632 } | 658 } |
633 } | 659 } |
634 #else | 660 #else |
635 if (command_line.HasSwitch(switches::kCertificateTransparencyLog)) { | 661 if (command_line.HasSwitch(switches::kCertificateTransparencyLog)) { |
636 LOG(DFATAL) << "Certificate Transparency is not yet supported in Chrome " | 662 LOG(DFATAL) << "Certificate Transparency is not yet supported in Chrome " |
637 "builds using OpenSSL."; | 663 "builds using OpenSSL."; |
638 } | 664 } |
639 #endif | 665 #endif |
640 globals_->ssl_config_service = GetSSLConfigService(); | 666 globals_->ssl_config_service = GetSSLConfigService(); |
641 #if defined(OS_ANDROID) || defined(OS_IOS) | 667 SetupDataReductionProxy(network_delegate); |
642 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
643 int drp_flags = DataReductionProxyParams::kFallbackAllowed; | |
644 if (DataReductionProxyParams::IsIncludedInFieldTrial()) | |
645 drp_flags |= DataReductionProxyParams::kAllowed; | |
646 if (DataReductionProxyParams::IsIncludedInAlternativeFieldTrial()) | |
647 drp_flags |= DataReductionProxyParams::kAlternativeAllowed; | |
648 if (DataReductionProxyParams::IsIncludedInPromoFieldTrial()) | |
649 drp_flags |= DataReductionProxyParams::kPromoAllowed; | |
650 DataReductionProxyParams* proxy_params = | |
651 new DataReductionProxyParams(drp_flags); | |
652 globals_->data_reduction_proxy_params.reset(proxy_params); | |
653 globals_->data_reduction_proxy_auth_request_handler.reset( | |
654 new DataReductionProxyAuthRequestHandler(proxy_params)); | |
655 globals_->on_resolve_proxy_handler = | |
656 ChromeNetworkDelegate::OnResolveProxyHandler( | |
657 base::Bind(data_reduction_proxy::OnResolveProxyHandler)); | |
658 DataReductionProxyUsageStats* proxy_usage_stats = | |
659 new DataReductionProxyUsageStats(proxy_params, | |
660 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), | |
661 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | |
662 network_delegate->set_data_reduction_proxy_params(proxy_params); | |
663 globals_->data_reduction_proxy_usage_stats.reset(proxy_usage_stats); | |
664 network_delegate->set_data_reduction_proxy_usage_stats(proxy_usage_stats); | |
665 network_delegate->set_data_reduction_proxy_auth_request_handler( | |
666 globals_->data_reduction_proxy_auth_request_handler.get()); | |
667 network_delegate->set_on_resolve_proxy_handler( | 668 network_delegate->set_on_resolve_proxy_handler( |
668 globals_->on_resolve_proxy_handler); | 669 globals_->on_resolve_proxy_handler); |
669 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) | |
670 #endif // defined(OS_ANDROID) || defined(OS_IOS) | |
671 globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( | 670 globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( |
672 globals_->host_resolver.get())); | 671 globals_->host_resolver.get())); |
673 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); | 672 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); |
674 // For the ProxyScriptFetcher, we use a direct ProxyService. | 673 // For the ProxyScriptFetcher, we use a direct ProxyService. |
675 globals_->proxy_script_fetcher_proxy_service.reset( | 674 globals_->proxy_script_fetcher_proxy_service.reset( |
676 net::ProxyService::CreateDirectWithNetLog(net_log_)); | 675 net::ProxyService::CreateDirectWithNetLog(net_log_)); |
677 // In-memory cookie store. | 676 // In-memory cookie store. |
678 globals_->system_cookie_store = | 677 globals_->system_cookie_store = |
679 content::CreateCookieStore(content::CookieStoreConfig()); | 678 content::CreateCookieStore(content::CookieStoreConfig()); |
680 // In-memory server bound cert store. | 679 // In-memory server bound cert store. |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1097 | 1096 |
1098 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 1097 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
1099 globals_->system_proxy_service.reset( | 1098 globals_->system_proxy_service.reset( |
1100 ProxyServiceFactory::CreateProxyService( | 1099 ProxyServiceFactory::CreateProxyService( |
1101 net_log_, | 1100 net_log_, |
1102 globals_->proxy_script_fetcher_context.get(), | 1101 globals_->proxy_script_fetcher_context.get(), |
1103 globals_->system_network_delegate.get(), | 1102 globals_->system_network_delegate.get(), |
1104 system_proxy_config_service_.release(), | 1103 system_proxy_config_service_.release(), |
1105 command_line, | 1104 command_line, |
1106 quick_check_enabled_.GetValue())); | 1105 quick_check_enabled_.GetValue())); |
1106 DCHECK(globals_->data_reduction_proxy_params); | |
1107 | |
1108 // This is temporary until the histogram code is factored out of | |
1109 // Proxy{Server|Service}. | |
Ryan Sleevi
2014/07/22 01:56:30
Based on the team, I have trouble believing this.
bengr
2014/07/22 20:08:20
Ryan, factoring the data reduction proxy out of ne
Not at Google. Contact bengr
2014/07/22 23:03:52
Done. Filed bug 396222.
Not at Google. Contact bengr
2014/08/26 17:31:08
Fixed https://code.google.com/p/chromium/issues/de
| |
1110 globals_->system_proxy_service->SetDataReductionProxyOrigins( | |
1111 globals_->data_reduction_proxy_params->origin(), | |
1112 globals_->data_reduction_proxy_params->fallback_origin()); | |
1107 | 1113 |
1108 net::HttpNetworkSession::Params system_params; | 1114 net::HttpNetworkSession::Params system_params; |
1109 InitializeNetworkSessionParams(&system_params); | 1115 InitializeNetworkSessionParams(&system_params); |
1110 system_params.net_log = net_log_; | 1116 system_params.net_log = net_log_; |
1111 system_params.proxy_service = globals_->system_proxy_service.get(); | 1117 system_params.proxy_service = globals_->system_proxy_service.get(); |
1112 | 1118 |
1113 globals_->system_http_transaction_factory.reset( | 1119 globals_->system_http_transaction_factory.reset( |
1114 new net::HttpNetworkLayer( | 1120 new net::HttpNetworkLayer( |
1115 new net::HttpNetworkSession(system_params))); | 1121 new net::HttpNetworkSession(system_params))); |
1116 globals_->system_url_request_job_factory.reset( | 1122 globals_->system_url_request_job_factory.reset( |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1380 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); | 1386 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); |
1381 for (size_t i = 0; i < supported_versions.size(); ++i) { | 1387 for (size_t i = 0; i < supported_versions.size(); ++i) { |
1382 net::QuicVersion version = supported_versions[i]; | 1388 net::QuicVersion version = supported_versions[i]; |
1383 if (net::QuicVersionToString(version) == quic_version) { | 1389 if (net::QuicVersionToString(version) == quic_version) { |
1384 return version; | 1390 return version; |
1385 } | 1391 } |
1386 } | 1392 } |
1387 | 1393 |
1388 return net::QUIC_VERSION_UNSUPPORTED; | 1394 return net::QUIC_VERSION_UNSUPPORTED; |
1389 } | 1395 } |
OLD | NEW |