Commit 925ea86b authored by Ryan Hamilton's avatar Ryan Hamilton Committed by Commit Bot

Unify the two identical implementations of ParseQuicVersions into

quic_utils_chromium.{h,cc}

This was suggested on
https://chromium-review.googlesource.com/c/chromium/src/+/2005825
but autosubmit landed the CL before it could be addressed.

Change-Id: Iebd6fee046714db75ee3a6a47443e60e63ced120
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2013201
Auto-Submit: Ryan Hamilton <rch@chromium.org>
Reviewed-by: default avatarNick Harper <nharper@chromium.org>
Commit-Queue: Ryan Hamilton <rch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#734012}
parent 81bc9bb4
......@@ -207,37 +207,6 @@ ParseNetworkErrorLoggingHeaders(
return result;
}
quic::ParsedQuicVersionVector ParseQuicVersions(
const std::string& quic_versions) {
quic::ParsedQuicVersionVector supported_versions;
quic::QuicTransportVersionVector all_supported_versions =
quic::AllSupportedTransportVersions();
for (const base::StringPiece& version : base::SplitStringPiece(
quic_versions, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
auto it = all_supported_versions.begin();
while (it != all_supported_versions.end()) {
if (quic::QuicVersionToString(*it) == version) {
supported_versions.push_back(
quic::ParsedQuicVersion(quic::PROTOCOL_QUIC_CRYPTO, *it));
// Remove the supported version to deduplicate versions extracted from
// |quic_versions|.
all_supported_versions.erase(it);
break;
}
++it;
}
for (const auto& supported_version : quic::AllSupportedVersions()) {
if (quic::AlpnForVersion(supported_version) == version) {
supported_versions.push_back(supported_version);
break;
}
}
}
return supported_versions;
}
} // namespace
URLRequestContextConfig::QuicHint::QuicHint(const std::string& host,
......@@ -347,7 +316,7 @@ void URLRequestContextConfig::ParseAndSetExperimentalOptions(
std::string quic_version_string;
if (quic_args->GetString(kQuicVersion, &quic_version_string)) {
quic::ParsedQuicVersionVector supported_versions =
ParseQuicVersions(quic_version_string);
net::ParseQuicVersions(quic_version_string);
if (!supported_versions.empty())
quic_params->supported_versions = supported_versions;
}
......
......@@ -454,7 +454,7 @@ size_t GetQuicMaxPacketLength(const VariationParameters& quic_trial_params) {
quic::ParsedQuicVersionVector GetQuicVersions(
const VariationParameters& quic_trial_params) {
return network_session_configurator::ParseQuicVersions(
return net::ParseQuicVersions(
GetVariationParam(quic_trial_params, "quic_version"));
}
......@@ -600,36 +600,6 @@ void ConfigureQuicParams(base::StringPiece quic_trial_group,
namespace network_session_configurator {
quic::ParsedQuicVersionVector ParseQuicVersions(
const std::string& quic_versions) {
quic::ParsedQuicVersionVector supported_versions;
quic::QuicTransportVersionVector all_supported_versions =
quic::AllSupportedTransportVersions();
for (const base::StringPiece& version : base::SplitStringPiece(
quic_versions, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
auto it = all_supported_versions.begin();
while (it != all_supported_versions.end()) {
if (quic::QuicVersionToString(*it) == version) {
supported_versions.push_back(
quic::ParsedQuicVersion(quic::PROTOCOL_QUIC_CRYPTO, *it));
// Remove the supported version to deduplicate versions extracted from
// |quic_versions|.
all_supported_versions.erase(it);
break;
}
it++;
}
for (const auto& supported_version : quic::AllSupportedVersions()) {
if (quic::AlpnForVersion(supported_version) == version) {
supported_versions.push_back(supported_version);
break;
}
}
}
return supported_versions;
}
void ParseCommandLineAndFieldTrials(const base::CommandLine& command_line,
bool is_quic_force_disabled,
const std::string& quic_user_agent_id,
......@@ -676,9 +646,8 @@ void ParseCommandLineAndFieldTrials(const base::CommandLine& command_line,
}
if (command_line.HasSwitch(switches::kQuicVersion)) {
quic::ParsedQuicVersionVector supported_versions =
network_session_configurator::ParseQuicVersions(
command_line.GetSwitchValueASCII(switches::kQuicVersion));
quic::ParsedQuicVersionVector supported_versions = net::ParseQuicVersions(
command_line.GetSwitchValueASCII(switches::kQuicVersion));
if (!supported_versions.empty())
quic_params->supported_versions = supported_versions;
}
......
......@@ -20,10 +20,6 @@ namespace network_session_configurator {
// Helper functions to configure HttpNetworkSession::Params based on field
// trials and command line.
// Parse serialized QUIC versions string.
quic::ParsedQuicVersionVector ParseQuicVersions(
const std::string& quic_versions);
// Configure |params| based on field trials and command line,
// and forcing (policy or other command line) arguments.
void ParseCommandLineAndFieldTrials(const base::CommandLine& command_line,
......
......@@ -28,4 +28,34 @@ quic::QuicTagVector ParseQuicConnectionOptions(
return options;
}
quic::ParsedQuicVersionVector ParseQuicVersions(
const std::string& quic_versions) {
quic::ParsedQuicVersionVector supported_versions;
quic::QuicTransportVersionVector all_supported_versions =
quic::AllSupportedTransportVersions();
for (const base::StringPiece& version : base::SplitStringPiece(
quic_versions, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
auto it = all_supported_versions.begin();
while (it != all_supported_versions.end()) {
if (quic::QuicVersionToString(*it) == version) {
supported_versions.push_back(
quic::ParsedQuicVersion(quic::PROTOCOL_QUIC_CRYPTO, *it));
// Remove the supported version to deduplicate versions extracted from
// |quic_versions|.
all_supported_versions.erase(it);
break;
}
it++;
}
for (const auto& supported_version : quic::AllSupportedVersions()) {
if (quic::AlpnForVersion(supported_version) == version) {
supported_versions.push_back(supported_version);
break;
}
}
}
return supported_versions;
}
} // namespace net
......@@ -12,6 +12,7 @@
#include "base/logging.h"
#include "net/base/net_export.h"
#include "net/third_party/quiche/src/quic/core/quic_tag.h"
#include "net/third_party/quiche/src/quic/core/quic_versions.h"
namespace net {
......@@ -20,6 +21,11 @@ namespace net {
NET_EXPORT quic::QuicTagVector ParseQuicConnectionOptions(
const std::string& connection_options);
// Returns the list of QUIC versions represented by the comma separated
// string in |quic_versions|.
NET_EXPORT quic::ParsedQuicVersionVector ParseQuicVersions(
const std::string& quic_versions);
} // namespace net
#endif // NET_QUIC_QUIC_UTILS_CHROMIUM_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment