| 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 27 matching lines...) Expand all Loading... |
| 38 // operators to do feature detection rather than UA-sniffing. As such, this | 38 // operators to do feature detection rather than UA-sniffing. As such, this |
| 39 // trial runs continuously. | 39 // trial runs continuously. |
| 40 // * A SPDY/4 experiment, for SPDY/4 (aka HTTP/2) vs SPDY/3.1 comparisons and | 40 // * A SPDY/4 experiment, for SPDY/4 (aka HTTP/2) vs SPDY/3.1 comparisons and |
| 41 // eventual SPDY/4 deployment. | 41 // eventual SPDY/4 deployment. |
| 42 const char kSpdyFieldTrialName[] = "SPDY"; | 42 const char kSpdyFieldTrialName[] = "SPDY"; |
| 43 const char kSpdyFieldTrialHoldbackGroupNamePrefix[] = "SpdyDisabled"; | 43 const char kSpdyFieldTrialHoldbackGroupNamePrefix[] = "SpdyDisabled"; |
| 44 const char kSpdyFieldTrialSpdy31GroupNamePrefix[] = "Spdy31Enabled"; | 44 const char kSpdyFieldTrialSpdy31GroupNamePrefix[] = "Spdy31Enabled"; |
| 45 const char kSpdyFieldTrialSpdy4GroupNamePrefix[] = "Spdy4Enabled"; | 45 const char kSpdyFieldTrialSpdy4GroupNamePrefix[] = "Spdy4Enabled"; |
| 46 const char kSpdyFieldTrialParametrizedPrefix[] = "Parametrized"; | 46 const char kSpdyFieldTrialParametrizedPrefix[] = "Parametrized"; |
| 47 | 47 |
| 48 // The AltSvc trial controls whether Alt-Svc headers are parsed. | |
| 49 // Disabled: | |
| 50 // Alt-Svc headers are not parsed. | |
| 51 // Alternate-Protocol headers are parsed. | |
| 52 // Enabled: | |
| 53 // Alt-Svc headers are parsed, but only same-host entries are used by | |
| 54 // default. (Use "enable_alternative_service_with_different_host" QUIC | |
| 55 // parameter to enable entries with different hosts.) | |
| 56 // Alternate-Protocol headers are ignored for responses that have an Alt-Svc | |
| 57 // header. | |
| 58 const char kAltSvcFieldTrialName[] = "ParseAltSvc"; | |
| 59 const char kAltSvcFieldTrialDisabledPrefix[] = "AltSvcDisabled"; | |
| 60 const char kAltSvcFieldTrialEnabledPrefix[] = "AltSvcEnabled"; | |
| 61 | |
| 62 // Field trial for NPN. | 48 // Field trial for NPN. |
| 63 const char kNpnTrialName[] = "NPN"; | 49 const char kNpnTrialName[] = "NPN"; |
| 64 const char kNpnTrialEnabledGroupNamePrefix[] = "Enable"; | 50 const char kNpnTrialEnabledGroupNamePrefix[] = "Enable"; |
| 65 const char kNpnTrialDisabledGroupNamePrefix[] = "Disable"; | 51 const char kNpnTrialDisabledGroupNamePrefix[] = "Disable"; |
| 66 | 52 |
| 67 // Field trial for priority dependencies. | 53 // Field trial for priority dependencies. |
| 68 const char kSpdyDependenciesFieldTrial[] = "SpdyEnableDependencies"; | 54 const char kSpdyDependenciesFieldTrial[] = "SpdyEnableDependencies"; |
| 69 const char kSpdyDependenciesFieldTrialEnable[] = "Enable"; | 55 const char kSpdyDependenciesFieldTrialEnable[] = "Enable"; |
| 70 const char kSpdyDepencenciesFieldTrialDisable[] = "Disable"; | 56 const char kSpdyDepencenciesFieldTrialDisable[] = "Disable"; |
| 71 | 57 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 params->enable_spdy31 = true; | 133 params->enable_spdy31 = true; |
| 148 } | 134 } |
| 149 // TODO(bnc): https://crbug.com/521597 | 135 // TODO(bnc): https://crbug.com/521597 |
| 150 // HttpStreamFactory::spdy_enabled_ is redundant with params->enable_http2 | 136 // HttpStreamFactory::spdy_enabled_ is redundant with params->enable_http2 |
| 151 // and enable_spdy31, can it be eliminated? | 137 // and enable_spdy31, can it be eliminated? |
| 152 net::HttpStreamFactory::set_spdy_enabled(spdy_enabled); | 138 net::HttpStreamFactory::set_spdy_enabled(spdy_enabled); |
| 153 return; | 139 return; |
| 154 } | 140 } |
| 155 } | 141 } |
| 156 | 142 |
| 157 void ConfigureAltSvcParams(const base::CommandLine& command_line, | |
| 158 base::StringPiece altsvc_trial_group, | |
| 159 net::HttpNetworkSession::Params* params) { | |
| 160 if (altsvc_trial_group.starts_with(kAltSvcFieldTrialEnabledPrefix)) { | |
| 161 params->parse_alternative_services = true; | |
| 162 return; | |
| 163 } | |
| 164 if (altsvc_trial_group.starts_with(kAltSvcFieldTrialDisabledPrefix)) { | |
| 165 params->parse_alternative_services = false; | |
| 166 } | |
| 167 } | |
| 168 | |
| 169 void ConfigureNPNParams(const base::CommandLine& command_line, | 143 void ConfigureNPNParams(const base::CommandLine& command_line, |
| 170 base::StringPiece npn_trial_group, | 144 base::StringPiece npn_trial_group, |
| 171 net::HttpNetworkSession::Params* params) { | 145 net::HttpNetworkSession::Params* params) { |
| 172 if (npn_trial_group.starts_with(kNpnTrialEnabledGroupNamePrefix)) { | 146 if (npn_trial_group.starts_with(kNpnTrialEnabledGroupNamePrefix)) { |
| 173 params->enable_npn = true; | 147 params->enable_npn = true; |
| 174 } else if (npn_trial_group.starts_with(kNpnTrialDisabledGroupNamePrefix)) { | 148 } else if (npn_trial_group.starts_with(kNpnTrialDisabledGroupNamePrefix)) { |
| 175 params->enable_npn = false; | 149 params->enable_npn = false; |
| 176 } | 150 } |
| 177 } | 151 } |
| 178 | 152 |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 } | 514 } |
| 541 if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) { | 515 if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) { |
| 542 params->testing_fixed_https_port = | 516 params->testing_fixed_https_port = |
| 543 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpsPort); | 517 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpsPort); |
| 544 } | 518 } |
| 545 | 519 |
| 546 // Always fetch the field trial groups to ensure they are reported correctly. | 520 // Always fetch the field trial groups to ensure they are reported correctly. |
| 547 // The command line flags will be associated with a group that is reported so | 521 // The command line flags will be associated with a group that is reported so |
| 548 // long as trial is actually queried. | 522 // long as trial is actually queried. |
| 549 | 523 |
| 550 std::string altsvc_trial_group = | |
| 551 base::FieldTrialList::FindFullName(kAltSvcFieldTrialName); | |
| 552 ConfigureAltSvcParams(command_line, altsvc_trial_group, params); | |
| 553 | |
| 554 std::string quic_trial_group = | 524 std::string quic_trial_group = |
| 555 base::FieldTrialList::FindFullName(kQuicFieldTrialName); | 525 base::FieldTrialList::FindFullName(kQuicFieldTrialName); |
| 556 VariationParameters quic_trial_params; | 526 VariationParameters quic_trial_params; |
| 557 if (!variations::GetVariationParams(kQuicFieldTrialName, &quic_trial_params)) | 527 if (!variations::GetVariationParams(kQuicFieldTrialName, &quic_trial_params)) |
| 558 quic_trial_params.clear(); | 528 quic_trial_params.clear(); |
| 559 ConfigureQuicParams(command_line, quic_trial_group, quic_trial_params, | 529 ConfigureQuicParams(command_line, quic_trial_group, quic_trial_params, |
| 560 is_quic_allowed_by_policy, quic_user_agent_id, params); | 530 is_quic_allowed_by_policy, quic_user_agent_id, params); |
| 561 | 531 |
| 562 if (!is_spdy_allowed_by_policy) { | 532 if (!is_spdy_allowed_by_policy) { |
| 563 base::FieldTrial* trial = base::FieldTrialList::Find(kSpdyFieldTrialName); | 533 base::FieldTrial* trial = base::FieldTrialList::Find(kSpdyFieldTrialName); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 const std::string& quic_user_agent_id, | 574 const std::string& quic_user_agent_id, |
| 605 net::HttpNetworkSession::Params* params) { | 575 net::HttpNetworkSession::Params* params) { |
| 606 const base::CommandLine& command_line = | 576 const base::CommandLine& command_line = |
| 607 *base::CommandLine::ForCurrentProcess(); | 577 *base::CommandLine::ForCurrentProcess(); |
| 608 ParseFieldTrialsAndCommandLineInternal( | 578 ParseFieldTrialsAndCommandLineInternal( |
| 609 command_line, is_spdy_allowed_by_policy, is_quic_allowed_by_policy, | 579 command_line, is_spdy_allowed_by_policy, is_quic_allowed_by_policy, |
| 610 quic_user_agent_id, params); | 580 quic_user_agent_id, params); |
| 611 } | 581 } |
| 612 | 582 |
| 613 } // namespace network_session_configurator | 583 } // namespace network_session_configurator |
| OLD | NEW |