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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 #include "net/proxy/proxy_config_service.h" | 68 #include "net/proxy/proxy_config_service.h" |
69 #include "net/proxy/proxy_script_fetcher_impl.h" | 69 #include "net/proxy/proxy_script_fetcher_impl.h" |
70 #include "net/proxy/proxy_service.h" | 70 #include "net/proxy/proxy_service.h" |
71 #include "net/quic/crypto/crypto_protocol.h" | 71 #include "net/quic/crypto/crypto_protocol.h" |
72 #include "net/quic/quic_protocol.h" | 72 #include "net/quic/quic_protocol.h" |
73 #include "net/quic/quic_utils.h" | 73 #include "net/quic/quic_utils.h" |
74 #include "net/socket/tcp_client_socket.h" | 74 #include "net/socket/tcp_client_socket.h" |
75 #include "net/spdy/spdy_session.h" | 75 #include "net/spdy/spdy_session.h" |
76 #include "net/ssl/channel_id_service.h" | 76 #include "net/ssl/channel_id_service.h" |
77 #include "net/ssl/default_channel_id_store.h" | 77 #include "net/ssl/default_channel_id_store.h" |
| 78 #include "net/ssl/ssl_socket_config_service.h" |
78 #include "net/url_request/data_protocol_handler.h" | 79 #include "net/url_request/data_protocol_handler.h" |
79 #include "net/url_request/file_protocol_handler.h" | 80 #include "net/url_request/file_protocol_handler.h" |
80 #include "net/url_request/ftp_protocol_handler.h" | 81 #include "net/url_request/ftp_protocol_handler.h" |
81 #include "net/url_request/static_http_user_agent_settings.h" | 82 #include "net/url_request/static_http_user_agent_settings.h" |
82 #include "net/url_request/url_fetcher.h" | 83 #include "net/url_request/url_fetcher.h" |
83 #include "net/url_request/url_request_context.h" | 84 #include "net/url_request/url_request_context.h" |
84 #include "net/url_request/url_request_context_getter.h" | 85 #include "net/url_request/url_request_context_getter.h" |
85 #include "net/url_request/url_request_job_factory_impl.h" | 86 #include "net/url_request/url_request_job_factory_impl.h" |
86 #include "net/url_request/url_request_throttler_manager.h" | 87 #include "net/url_request/url_request_throttler_manager.h" |
87 #include "url/url_constants.h" | 88 #include "url/url_constants.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 const char kSpdyFieldTrialName[] = "SPDY"; | 134 const char kSpdyFieldTrialName[] = "SPDY"; |
134 const char kSpdyFieldTrialHoldbackGroupNamePrefix[] = "SpdyDisabled"; | 135 const char kSpdyFieldTrialHoldbackGroupNamePrefix[] = "SpdyDisabled"; |
135 const char kSpdyFieldTrialHoldbackControlGroupName[] = "Control"; | 136 const char kSpdyFieldTrialHoldbackControlGroupName[] = "Control"; |
136 const char kSpdyFieldTrialSpdy31GroupNamePrefix[] = "Spdy31Enabled"; | 137 const char kSpdyFieldTrialSpdy31GroupNamePrefix[] = "Spdy31Enabled"; |
137 const char kSpdyFieldTrialSpdy4GroupNamePrefix[] = "Spdy4Enabled"; | 138 const char kSpdyFieldTrialSpdy4GroupNamePrefix[] = "Spdy4Enabled"; |
138 const char kSpdyFieldTrialSpdy4ControlGroupName[] = "Spdy4Control"; | 139 const char kSpdyFieldTrialSpdy4ControlGroupName[] = "Spdy4Control"; |
139 | 140 |
140 // Field trial for Cache-Control: stale-while-revalidate directive. | 141 // Field trial for Cache-Control: stale-while-revalidate directive. |
141 const char kStaleWhileRevalidateFieldTrialName[] = "StaleWhileRevalidate"; | 142 const char kStaleWhileRevalidateFieldTrialName[] = "StaleWhileRevalidate"; |
142 | 143 |
| 144 // Field trial for ClientHello padding. |
| 145 const char kClientHelloFieldTrialName[] = "FastRadioPadding"; |
| 146 const char kClientHelloFieldTrialEnabledGroupName[] = "Enabled"; |
| 147 |
143 #if defined(OS_MACOSX) && !defined(OS_IOS) | 148 #if defined(OS_MACOSX) && !defined(OS_IOS) |
144 void ObserveKeychainEvents() { | 149 void ObserveKeychainEvents() { |
145 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 150 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
146 net::CertDatabase::GetInstance()->SetMessageLoopForKeychainEvents(); | 151 net::CertDatabase::GetInstance()->SetMessageLoopForKeychainEvents(); |
147 } | 152 } |
148 #endif | 153 #endif |
149 | 154 |
150 // Used for the "system" URLRequestContext. | 155 // Used for the "system" URLRequestContext. |
151 class SystemURLRequestContext : public net::URLRequestContext { | 156 class SystemURLRequestContext : public net::URLRequestContext { |
152 public: | 157 public: |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 globals_->proxy_script_fetcher_url_request_job_factory = job_factory.Pass(); | 731 globals_->proxy_script_fetcher_url_request_job_factory = job_factory.Pass(); |
727 | 732 |
728 globals_->throttler_manager.reset(new net::URLRequestThrottlerManager()); | 733 globals_->throttler_manager.reset(new net::URLRequestThrottlerManager()); |
729 globals_->throttler_manager->set_net_log(net_log_); | 734 globals_->throttler_manager->set_net_log(net_log_); |
730 // Always done in production, disabled only for unit tests. | 735 // Always done in production, disabled only for unit tests. |
731 globals_->throttler_manager->set_enable_thread_checks(true); | 736 globals_->throttler_manager->set_enable_thread_checks(true); |
732 | 737 |
733 globals_->proxy_script_fetcher_context.reset( | 738 globals_->proxy_script_fetcher_context.reset( |
734 ConstructProxyScriptFetcherContext(globals_, net_log_)); | 739 ConstructProxyScriptFetcherContext(globals_, net_log_)); |
735 | 740 |
| 741 ConfigureSSLSocketConfigService(command_line); |
| 742 |
736 #if defined(OS_MACOSX) && !defined(OS_IOS) | 743 #if defined(OS_MACOSX) && !defined(OS_IOS) |
737 // Start observing Keychain events. This needs to be done on the UI thread, | 744 // Start observing Keychain events. This needs to be done on the UI thread, |
738 // as Keychain services requires a CFRunLoop. | 745 // as Keychain services requires a CFRunLoop. |
739 BrowserThread::PostTask(BrowserThread::UI, | 746 BrowserThread::PostTask(BrowserThread::UI, |
740 FROM_HERE, | 747 FROM_HERE, |
741 base::Bind(&ObserveKeychainEvents)); | 748 base::Bind(&ObserveKeychainEvents)); |
742 #endif | 749 #endif |
743 | 750 |
744 // InitSystemRequestContext turns right around and posts a task back | 751 // InitSystemRequestContext turns right around and posts a task back |
745 // to the IO thread, so we can't let it run until we know the IO | 752 // to the IO thread, so we can't let it run until we know the IO |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
999 params->http_server_properties = | 1006 params->http_server_properties = |
1000 globals.http_server_properties->GetWeakPtr(); | 1007 globals.http_server_properties->GetWeakPtr(); |
1001 params->network_delegate = globals.system_network_delegate.get(); | 1008 params->network_delegate = globals.system_network_delegate.get(); |
1002 params->host_mapping_rules = globals.host_mapping_rules.get(); | 1009 params->host_mapping_rules = globals.host_mapping_rules.get(); |
1003 params->enable_ssl_connect_job_waiting = | 1010 params->enable_ssl_connect_job_waiting = |
1004 globals.enable_ssl_connect_job_waiting; | 1011 globals.enable_ssl_connect_job_waiting; |
1005 params->ignore_certificate_errors = globals.ignore_certificate_errors; | 1012 params->ignore_certificate_errors = globals.ignore_certificate_errors; |
1006 params->use_stale_while_revalidate = globals.use_stale_while_revalidate; | 1013 params->use_stale_while_revalidate = globals.use_stale_while_revalidate; |
1007 params->testing_fixed_http_port = globals.testing_fixed_http_port; | 1014 params->testing_fixed_http_port = globals.testing_fixed_http_port; |
1008 params->testing_fixed_https_port = globals.testing_fixed_https_port; | 1015 params->testing_fixed_https_port = globals.testing_fixed_https_port; |
| 1016 params->ssl_socket_config_service = globals.ssl_socket_config_service.get(); |
1009 globals.enable_tcp_fast_open_for_ssl.CopyToIfSet( | 1017 globals.enable_tcp_fast_open_for_ssl.CopyToIfSet( |
1010 ¶ms->enable_tcp_fast_open_for_ssl); | 1018 ¶ms->enable_tcp_fast_open_for_ssl); |
1011 | 1019 |
1012 globals.initial_max_spdy_concurrent_streams.CopyToIfSet( | 1020 globals.initial_max_spdy_concurrent_streams.CopyToIfSet( |
1013 ¶ms->spdy_initial_max_concurrent_streams); | 1021 ¶ms->spdy_initial_max_concurrent_streams); |
1014 globals.force_spdy_single_domain.CopyToIfSet( | 1022 globals.force_spdy_single_domain.CopyToIfSet( |
1015 ¶ms->force_spdy_single_domain); | 1023 ¶ms->force_spdy_single_domain); |
1016 globals.enable_spdy_compression.CopyToIfSet( | 1024 globals.enable_spdy_compression.CopyToIfSet( |
1017 ¶ms->enable_spdy_compression); | 1025 ¶ms->enable_spdy_compression); |
1018 globals.enable_spdy_ping_based_connection_checking.CopyToIfSet( | 1026 globals.enable_spdy_ping_based_connection_checking.CopyToIfSet( |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1135 std::string group = | 1143 std::string group = |
1136 base::FieldTrialList::FindFullName(kQuicFieldTrialName); | 1144 base::FieldTrialList::FindFullName(kQuicFieldTrialName); |
1137 VariationParameters params; | 1145 VariationParameters params; |
1138 if (!variations::GetVariationParams(kQuicFieldTrialName, ¶ms)) { | 1146 if (!variations::GetVariationParams(kQuicFieldTrialName, ¶ms)) { |
1139 params.clear(); | 1147 params.clear(); |
1140 } | 1148 } |
1141 | 1149 |
1142 ConfigureQuicGlobals(command_line, group, params, globals_); | 1150 ConfigureQuicGlobals(command_line, group, params, globals_); |
1143 } | 1151 } |
1144 | 1152 |
| 1153 void IOThread::ConfigureSSLSocketConfigService( |
| 1154 const base::CommandLine& command_line) { |
| 1155 // Always fetch the field trial group to ensure it is reported correctly. |
| 1156 std::string group = |
| 1157 base::FieldTrialList::FindFullName(kClientHelloFieldTrialName); |
| 1158 |
| 1159 ConfigureSSLSocketConfigServiceGlobals(command_line, group, globals_); |
| 1160 } |
| 1161 |
1145 // static | 1162 // static |
1146 void IOThread::ConfigureQuicGlobals( | 1163 void IOThread::ConfigureQuicGlobals( |
1147 const base::CommandLine& command_line, | 1164 const base::CommandLine& command_line, |
1148 base::StringPiece quic_trial_group, | 1165 base::StringPiece quic_trial_group, |
1149 const VariationParameters& quic_trial_params, | 1166 const VariationParameters& quic_trial_params, |
1150 IOThread::Globals* globals) { | 1167 IOThread::Globals* globals) { |
1151 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group); | 1168 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group); |
1152 globals->enable_quic.set(enable_quic); | 1169 globals->enable_quic.set(enable_quic); |
1153 if (enable_quic) { | 1170 if (enable_quic) { |
1154 globals->quic_always_require_handshake_confirmation.set( | 1171 globals->quic_always_require_handshake_confirmation.set( |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1291 if (base::StringToDouble( | 1308 if (base::StringToDouble( |
1292 GetVariationParam(quic_trial_params, | 1309 GetVariationParam(quic_trial_params, |
1293 "alternate_protocol_probability_threshold"), | 1310 "alternate_protocol_probability_threshold"), |
1294 &value)) { | 1311 &value)) { |
1295 return value; | 1312 return value; |
1296 } | 1313 } |
1297 return -1; | 1314 return -1; |
1298 } | 1315 } |
1299 | 1316 |
1300 // static | 1317 // static |
| 1318 void IOThread::ConfigureSSLSocketConfigServiceGlobals( |
| 1319 const base::CommandLine& command_line, |
| 1320 base::StringPiece client_hello_trial_group, |
| 1321 Globals* globals) { |
| 1322 globals->ssl_socket_config_service.reset(new net::SSLSocketConfigService()); |
| 1323 |
| 1324 if (client_hello_trial_group.starts_with( |
| 1325 kClientHelloFieldTrialEnabledGroupName)) { |
| 1326 globals->ssl_socket_config_service->EnableFastRadioPadding(); |
| 1327 } else { |
| 1328 globals->ssl_socket_config_service->DisableFastRadioPadding(); |
| 1329 } |
| 1330 } |
| 1331 |
| 1332 // static |
1301 bool IOThread::ShouldQuicAlwaysRequireHandshakeConfirmation( | 1333 bool IOThread::ShouldQuicAlwaysRequireHandshakeConfirmation( |
1302 const VariationParameters& quic_trial_params) { | 1334 const VariationParameters& quic_trial_params) { |
1303 return LowerCaseEqualsASCII( | 1335 return LowerCaseEqualsASCII( |
1304 GetVariationParam(quic_trial_params, | 1336 GetVariationParam(quic_trial_params, |
1305 "always_require_handshake_confirmation"), | 1337 "always_require_handshake_confirmation"), |
1306 "true"); | 1338 "true"); |
1307 } | 1339 } |
1308 | 1340 |
1309 // static | 1341 // static |
1310 bool IOThread::ShouldQuicDisableConnectionPooling( | 1342 bool IOThread::ShouldQuicDisableConnectionPooling( |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1386 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); | 1418 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); |
1387 for (size_t i = 0; i < supported_versions.size(); ++i) { | 1419 for (size_t i = 0; i < supported_versions.size(); ++i) { |
1388 net::QuicVersion version = supported_versions[i]; | 1420 net::QuicVersion version = supported_versions[i]; |
1389 if (net::QuicVersionToString(version) == quic_version) { | 1421 if (net::QuicVersionToString(version) == quic_version) { |
1390 return version; | 1422 return version; |
1391 } | 1423 } |
1392 } | 1424 } |
1393 | 1425 |
1394 return net::QUIC_VERSION_UNSUPPORTED; | 1426 return net::QUIC_VERSION_UNSUPPORTED; |
1395 } | 1427 } |
OLD | NEW |