OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/network_session_configurator/network_session_configurator.h
" | 5 #include "components/network_session_configurator/network_session_configurator.h
" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 // HttpStreamFactory::spdy_enabled_ is redundant with params->enable_http2 | 150 // HttpStreamFactory::spdy_enabled_ is redundant with params->enable_http2 |
151 // and enable_spdy31, can it be eliminated? | 151 // and enable_spdy31, can it be eliminated? |
152 net::HttpStreamFactory::set_spdy_enabled(spdy_enabled); | 152 net::HttpStreamFactory::set_spdy_enabled(spdy_enabled); |
153 return; | 153 return; |
154 } | 154 } |
155 } | 155 } |
156 | 156 |
157 void ConfigureAltSvcParams(const base::CommandLine& command_line, | 157 void ConfigureAltSvcParams(const base::CommandLine& command_line, |
158 base::StringPiece altsvc_trial_group, | 158 base::StringPiece altsvc_trial_group, |
159 net::HttpNetworkSession::Params* params) { | 159 net::HttpNetworkSession::Params* params) { |
160 if (command_line.HasSwitch(switches::kEnableAlternativeServices) || | 160 if (altsvc_trial_group.starts_with(kAltSvcFieldTrialEnabledPrefix)) { |
161 altsvc_trial_group.starts_with(kAltSvcFieldTrialEnabledPrefix)) { | |
162 params->parse_alternative_services = true; | 161 params->parse_alternative_services = true; |
163 return; | 162 return; |
164 } | 163 } |
165 if (altsvc_trial_group.starts_with(kAltSvcFieldTrialDisabledPrefix)) { | 164 if (altsvc_trial_group.starts_with(kAltSvcFieldTrialDisabledPrefix)) { |
166 params->parse_alternative_services = false; | 165 params->parse_alternative_services = false; |
167 } | 166 } |
168 } | 167 } |
169 | 168 |
170 void ConfigureNPNParams(const base::CommandLine& command_line, | 169 void ConfigureNPNParams(const base::CommandLine& command_line, |
171 base::StringPiece npn_trial_group, | 170 base::StringPiece npn_trial_group, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 bool ShouldQuicDisableConnectionPooling( | 213 bool ShouldQuicDisableConnectionPooling( |
215 const VariationParameters& quic_trial_params) { | 214 const VariationParameters& quic_trial_params) { |
216 return base::LowerCaseEqualsASCII( | 215 return base::LowerCaseEqualsASCII( |
217 GetVariationParam(quic_trial_params, "disable_connection_pooling"), | 216 GetVariationParam(quic_trial_params, "disable_connection_pooling"), |
218 "true"); | 217 "true"); |
219 } | 218 } |
220 | 219 |
221 bool ShouldQuicEnableAlternativeServicesForDifferentHost( | 220 bool ShouldQuicEnableAlternativeServicesForDifferentHost( |
222 const base::CommandLine& command_line, | 221 const base::CommandLine& command_line, |
223 const VariationParameters& quic_trial_params) { | 222 const VariationParameters& quic_trial_params) { |
224 // TODO(bnc): Remove inaccurately named "use_alternative_services" parameter. | 223 return !base::LowerCaseEqualsASCII( |
225 return command_line.HasSwitch(switches::kEnableAlternativeServices) || | 224 GetVariationParam(quic_trial_params, |
226 base::LowerCaseEqualsASCII( | 225 "enable_alternative_service_with_different_host"), |
227 GetVariationParam(quic_trial_params, "use_alternative_services"), | 226 "false"); |
228 "true") || | |
229 base::LowerCaseEqualsASCII( | |
230 GetVariationParam( | |
231 quic_trial_params, | |
232 "enable_alternative_service_with_different_host"), | |
233 "true"); | |
234 } | 227 } |
235 | 228 |
236 bool ShouldEnableQuicPortSelection(const base::CommandLine& command_line) { | 229 bool ShouldEnableQuicPortSelection(const base::CommandLine& command_line) { |
237 if (command_line.HasSwitch(switches::kDisableQuicPortSelection)) | 230 if (command_line.HasSwitch(switches::kDisableQuicPortSelection)) |
238 return false; | 231 return false; |
239 | 232 |
240 if (command_line.HasSwitch(switches::kEnableQuicPortSelection)) | 233 if (command_line.HasSwitch(switches::kEnableQuicPortSelection)) |
241 return true; | 234 return true; |
242 | 235 |
243 return false; // Default to disabling port selection on all channels. | 236 return false; // Default to disabling port selection on all channels. |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 base::StringPiece quic_trial_group, | 433 base::StringPiece quic_trial_group, |
441 const VariationParameters& quic_trial_params, | 434 const VariationParameters& quic_trial_params, |
442 bool is_quic_allowed_by_policy, | 435 bool is_quic_allowed_by_policy, |
443 const std::string& quic_user_agent_id, | 436 const std::string& quic_user_agent_id, |
444 net::HttpNetworkSession::Params* params) { | 437 net::HttpNetworkSession::Params* params) { |
445 params->enable_quic = ShouldEnableQuic(command_line, quic_trial_group, | 438 params->enable_quic = ShouldEnableQuic(command_line, quic_trial_group, |
446 is_quic_allowed_by_policy); | 439 is_quic_allowed_by_policy); |
447 params->disable_quic_on_timeout_with_open_streams = | 440 params->disable_quic_on_timeout_with_open_streams = |
448 ShouldDisableQuicWhenConnectionTimesOutWithOpenStreams(quic_trial_params); | 441 ShouldDisableQuicWhenConnectionTimesOutWithOpenStreams(quic_trial_params); |
449 | 442 |
450 if (ShouldQuicEnableAlternativeServicesForDifferentHost(command_line, | 443 params->enable_alternative_service_with_different_host = |
451 quic_trial_params)) { | 444 ShouldQuicEnableAlternativeServicesForDifferentHost(command_line, |
452 params->enable_alternative_service_with_different_host = true; | 445 quic_trial_params); |
453 params->parse_alternative_services = true; | |
454 } else { | |
455 params->enable_alternative_service_with_different_host = false; | |
456 } | |
457 | 446 |
458 if (params->enable_quic) { | 447 if (params->enable_quic) { |
459 params->quic_always_require_handshake_confirmation = | 448 params->quic_always_require_handshake_confirmation = |
460 ShouldQuicAlwaysRequireHandshakeConfirmation(quic_trial_params); | 449 ShouldQuicAlwaysRequireHandshakeConfirmation(quic_trial_params); |
461 params->quic_disable_connection_pooling = | 450 params->quic_disable_connection_pooling = |
462 ShouldQuicDisableConnectionPooling(quic_trial_params); | 451 ShouldQuicDisableConnectionPooling(quic_trial_params); |
463 int receive_buffer_size = GetQuicSocketReceiveBufferSize(quic_trial_params); | 452 int receive_buffer_size = GetQuicSocketReceiveBufferSize(quic_trial_params); |
464 if (receive_buffer_size != 0) { | 453 if (receive_buffer_size != 0) { |
465 params->quic_socket_receive_buffer_size = receive_buffer_size; | 454 params->quic_socket_receive_buffer_size = receive_buffer_size; |
466 } | 455 } |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 const std::string& quic_user_agent_id, | 604 const std::string& quic_user_agent_id, |
616 net::HttpNetworkSession::Params* params) { | 605 net::HttpNetworkSession::Params* params) { |
617 const base::CommandLine& command_line = | 606 const base::CommandLine& command_line = |
618 *base::CommandLine::ForCurrentProcess(); | 607 *base::CommandLine::ForCurrentProcess(); |
619 ParseFieldTrialsAndCommandLineInternal( | 608 ParseFieldTrialsAndCommandLineInternal( |
620 command_line, is_spdy_allowed_by_policy, is_quic_allowed_by_policy, | 609 command_line, is_spdy_allowed_by_policy, is_quic_allowed_by_policy, |
621 quic_user_agent_id, params); | 610 quic_user_agent_id, params); |
622 } | 611 } |
623 | 612 |
624 } // namespace network_session_configurator | 613 } // namespace network_session_configurator |
OLD | NEW |