chromium/components/network_session_configurator/browser/network_session_configurator.cc

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/network_session_configurator/browser/network_session_configurator.h"

#include <limits>
#include <map>
#include <string_view>
#include <unordered_set>
#include <utility>
#include <vector>

#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_macros.h"
#include "base/rand_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "build/build_config.h"
#include "components/network_session_configurator/common/network_features.h"
#include "components/network_session_configurator/common/network_switches.h"
#include "components/variations/variations_switches.h"
#include "net/base/features.h"
#include "net/base/host_mapping_rules.h"
#include "net/http/http_network_session.h"
#include "net/http/http_stream_factory.h"
#include "net/quic/quic_context.h"
#include "net/quic/set_quic_flag.h"
#include "net/spdy/spdy_session.h"
#include "net/spdy/spdy_session_pool.h"
#include "net/third_party/quiche/src/quiche/common/platform/api/quiche_flags.h"
#include "net/third_party/quiche/src/quiche/quic/core/quic_packets.h"
#include "net/third_party/quiche/src/quiche/quic/core/quic_tag.h"
#include "net/third_party/quiche/src/quiche/spdy/core/spdy_protocol.h"

#if BUILDFLAG(IS_MAC)
#include "base/mac/mac_util.h"
#endif

namespace {

// Map from name to value for all parameters associate with a field trial.
VariationParameters;

const char kQuicFieldTrialName[] =;

const char kHttp2FieldTrialName[] =;

// Gets the value of the specified command line switch, as an integer. If unable
// to convert it to an int (It's not an int, or the switch is not present)
// returns 0.
int GetSwitchValueAsInt(const base::CommandLine& command_line,
                        const std::string& switch_name) {}

// Returns the value associated with |key| in |params| or "" if the
// key is not present in the map.
const std::string& GetVariationParam(
    const std::map<std::string, std::string>& params,
    const std::string& key) {}

bool GetVariationBoolParamOrFeatureSetting(const VariationParameters& params,
                                           const std::string& key,
                                           bool feature_setting) {}

spdy::SettingsMap GetHttp2Settings(
    const VariationParameters& http2_trial_params) {}

int ConfigureSpdySessionMaxQueuedCappedFrames(
    const base::CommandLine& /*command_line*/,
    const VariationParameters& http2_trial_params) {}

void ConfigureHttp2Params(const base::CommandLine& command_line,
                          std::string_view http2_trial_group,
                          const VariationParameters& http2_trial_params,
                          net::HttpNetworkSessionParams* params) {}

bool ShouldDisableQuic(std::string_view quic_trial_group,
                       const VariationParameters& quic_trial_params,
                       bool is_quic_force_disabled) {}

bool ShouldRetryWithoutAltSvcOnQuicErrors(
    const VariationParameters& quic_trial_params) {}

quic::QuicTagVector GetQuicConnectionOptions(
    const VariationParameters& quic_trial_params) {}

quic::QuicTagVector GetQuicClientConnectionOptions(
    const VariationParameters& quic_trial_params) {}

bool ShouldQuicCloseSessionsOnIpChange(
    const VariationParameters& quic_trial_params) {}

bool ShouldQuicGoAwaySessionsOnIpChange(
    const VariationParameters& quic_trial_params) {}

std::optional<bool> GetExponentialBackOffOnInitialDelay(
    const VariationParameters& quic_trial_params) {}

int GetQuicIdleConnectionTimeoutSeconds(
    const VariationParameters& quic_trial_params) {}

int GetQuicReducedPingTimeoutSeconds(
    const VariationParameters& quic_trial_params) {}

int GetQuicMaxTimeBeforeCryptoHandshakeSeconds(
    const VariationParameters& quic_trial_params) {}

int GetQuicMaxIdleTimeBeforeCryptoHandshakeSeconds(
    const VariationParameters& quic_trial_params) {}

bool ShouldQuicEstimateInitialRtt(
    const VariationParameters& quic_trial_params) {}

bool ShouldQuicMigrateSessionsOnNetworkChangeV2(
    const VariationParameters& quic_trial_params) {}

bool ShouldQuicUseNewAlpsCodepoint(
    const VariationParameters& quic_trial_params) {}

bool ShouldQuicReportEcn(
    const VariationParameters& quic_trial_params) {}

bool ShouldQuicMigrateSessionsEarlyV2(
    const VariationParameters& quic_trial_params) {}

bool ShouldQuicAllowPortMigration(
    const VariationParameters& quic_trial_params) {}

int GetMultiPortProbingInterval(const VariationParameters& quic_trial_params) {}

bool ShouldQuicRetryOnAlternateNetworkBeforeHandshake(
    const VariationParameters& quic_trial_params) {}

int GetQuicMaxTimeOnNonDefaultNetworkSeconds(
    const VariationParameters& quic_trial_params) {}

bool ShouldQuicMigrateIdleSessions(
    const VariationParameters& quic_trial_params) {}

bool ShouldQuicDisableTlsZeroRtt(const VariationParameters& quic_trial_params) {}

bool ShouldQuicDisableGQuicZeroRtt(
    const VariationParameters& quic_trial_params) {}

int GetQuicRetransmittableOnWireTimeoutMilliseconds(
    const VariationParameters& quic_trial_params) {}

int GetQuicIdleSessionMigrationPeriodSeconds(
    const VariationParameters& quic_trial_params) {}

int GetQuicMaxNumMigrationsToNonDefaultNetworkOnWriteError(
    const VariationParameters& quic_trial_params) {}

int GetQuicMaxNumMigrationsToNonDefaultNetworkOnPathDegrading(
    const VariationParameters& quic_trial_params) {}

int GetQuicInitialRttForHandshakeMilliseconds(
    const VariationParameters& quic_trial_params) {}

base::flat_set<std::string> GetQuicHostAllowlist(
    const VariationParameters& quic_trial_params) {}

int GetInitialDelayForBrokenAlternativeServiceSeconds(
    const VariationParameters& quic_trial_params) {}

bool DelayMainJobWithAvailableSpdySession(
    const VariationParameters& quic_trial_params) {}

bool IsOriginFrameEnabled(const VariationParameters& quic_trial_params) {}

bool IsDnsSkippedWithOriginFrame(const VariationParameters& quic_trial_params) {}

void SetQuicFlags(const VariationParameters& quic_trial_params) {}

size_t GetQuicMaxPacketLength(const VariationParameters& quic_trial_params) {}

quic::ParsedQuicVersionVector GetQuicVersions(
    const VariationParameters& quic_trial_params) {}

bool AreQuicParamsValid(const base::CommandLine& command_line,
                        std::string_view quic_trial_group,
                        const VariationParameters& quic_trial_params) {}

void ConfigureQuicParams(const base::CommandLine& command_line,
                         std::string_view quic_trial_group,
                         const VariationParameters& quic_trial_params,
                         bool is_quic_force_disabled,
                         net::HttpNetworkSessionParams* params,
                         net::QuicParams* quic_params) {}

}  // anonymous namespace

namespace network_session_configurator {

void ParseCommandLineAndFieldTrials(const base::CommandLine& command_line,
                                    bool is_quic_force_disabled,
                                    net::HttpNetworkSessionParams* params,
                                    net::QuicParams* quic_params) {}

net::URLRequestContextBuilder::HttpCacheParams::Type ChooseCacheType() {}

}  // namespace network_session_configurator