123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- From: csagan5 <32685696+csagan5@users.noreply.github.com>
- Date: Sun, 8 Jul 2018 22:42:04 +0200
- Subject: Add flag to configure maximum connections per host
- With the introduction of this flag it is possible to increase the maximum
- allowed connections per host; this can however be detrimental to devices
- with limited CPU/memory resources and it is disabled by default.
- ---
- chrome/browser/about_flags.cc | 8 ++++++++
- chrome/browser/flag_descriptions.cc | 4 ++++
- chrome/browser/flag_descriptions.h | 3 +++
- .../common/network_features.cc | 3 +++
- .../common/network_features.h | 4 ++++
- .../common/network_switch_list.h | 4 ++++
- net/socket/client_socket_pool_manager.cc | 16 ++++++++++++++++
- 7 files changed, 42 insertions(+)
- --- a/chrome/browser/about_flags.cc
- +++ b/chrome/browser/about_flags.cc
- @@ -619,6 +619,11 @@ const FeatureEntry::Choice kForceEffecti
- net::kEffectiveConnectionType4G},
- };
-
- +const FeatureEntry::Choice kMaxConnectionsPerHostChoices[] = {
- + {features::kMaxConnectionsPerHostChoiceDefault, "", ""},
- + {features::kMaxConnectionsPerHostChoice15, switches::kMaxConnectionsPerHost, "15"},
- +};
- +
- // Ensure that all effective connection types returned by Network Quality
- // Estimator (NQE) are also exposed via flags.
- static_assert(net::EFFECTIVE_CONNECTION_TYPE_LAST + 2 ==
- @@ -2217,6 +2222,9 @@ const FeatureEntry kFeatureEntries[] = {
- flag_descriptions::kAutofillCreditCardUploadDescription, kOsAll,
- FEATURE_VALUE_TYPE(autofill::features::kAutofillUpstream)},
- #endif // TOOLKIT_VIEWS || OS_ANDROID
- + {"max-connections-per-host", flag_descriptions::kMaxConnectionsPerHostName,
- + flag_descriptions::kMaxConnectionsPerHostDescription, kOsAll,
- + MULTI_VALUE_TYPE(kMaxConnectionsPerHostChoices)},
- {"force-ui-direction", flag_descriptions::kForceUiDirectionName,
- flag_descriptions::kForceUiDirectionDescription, kOsAll,
- MULTI_VALUE_TYPE(kForceUIDirectionChoices)},
- --- a/chrome/browser/flag_descriptions.cc
- +++ b/chrome/browser/flag_descriptions.cc
- @@ -1206,6 +1206,10 @@ const char kLookalikeUrlNavigationSugges
- const char kMarkHttpAsName[] = "Mark non-secure origins as non-secure";
- const char kMarkHttpAsDescription[] = "Change the UI treatment for HTTP pages";
-
- +const char kMaxConnectionsPerHostName[] = "Maximum connections per host";
- +const char kMaxConnectionsPerHostDescription[] =
- + "Customize maximum allowed connections per host.";
- +
- const char kMediaRouterCastAllowAllIPsName[] =
- "Connect to Cast devices on all IP addresses";
- const char kMediaRouterCastAllowAllIPsDescription[] =
- --- a/chrome/browser/flag_descriptions.h
- +++ b/chrome/browser/flag_descriptions.h
- @@ -733,6 +733,9 @@ extern const char kMarkHttpAsWarning[];
- extern const char kMarkHttpAsWarningAndDangerousOnFormEdits[];
- extern const char kMarkHttpAsWarningAndDangerousOnPasswordsAndCreditCards[];
-
- +extern const char kMaxConnectionsPerHostName[];
- +extern const char kMaxConnectionsPerHostDescription[];
- +
- extern const char kMediaRouterCastAllowAllIPsName[];
- extern const char kMediaRouterCastAllowAllIPsDescription[];
-
- --- a/components/network_session_configurator/common/network_features.cc
- +++ b/components/network_session_configurator/common/network_features.cc
- @@ -8,6 +8,9 @@
-
- namespace features {
-
- +const char kMaxConnectionsPerHostChoiceDefault[] = "6",
- + kMaxConnectionsPerHostChoice15[] = "15";
- +
- const base::Feature kDnsOverHttps{"dns-over-https",
- base::FEATURE_DISABLED_BY_DEFAULT};
-
- --- a/components/network_session_configurator/common/network_features.h
- +++ b/components/network_session_configurator/common/network_features.h
- @@ -10,6 +10,10 @@
-
- namespace features {
-
- +NETWORK_SESSION_CONFIGURATOR_EXPORT extern const char kMaxConnectionsPerHostChoiceDefault[],
- + kMaxConnectionsPerHostChoice6[],
- + kMaxConnectionsPerHostChoice15[];
- +
- // Enabled DNS over HTTPS
- // (https://tools.ietf.org/id/draft-ietf-doh-dns-over-https-12.txt).
- NETWORK_SESSION_CONFIGURATOR_EXPORT extern const base::Feature kDnsOverHttps;
- --- a/components/network_session_configurator/common/network_switch_list.h
- +++ b/components/network_session_configurator/common/network_switch_list.h
- @@ -22,6 +22,10 @@ NETWORK_SWITCH(kEnableUserAlternateProto
- // Enables the QUIC protocol. This is a temporary testing flag.
- NETWORK_SWITCH(kEnableQuic, "enable-quic")
-
- +// Allows specifying a higher number of maximum connections per host
- +// (15 instead of 6, mirroring the value Mozilla uses).
- +NETWORK_SWITCH(kMaxConnectionsPerHost, "max-connections-per-host")
- +
- // Ignores certificate-related errors.
- NETWORK_SWITCH(kIgnoreCertificateErrors, "ignore-certificate-errors")
-
- --- a/chrome/browser/browser_process_impl.cc
- +++ b/chrome/browser/browser_process_impl.cc
- @@ -18,12 +18,14 @@
- #include "base/debug/leak_annotations.h"
- #include "base/files/file_path.h"
- #include "base/location.h"
- +#include "base/logging.h"
- #include "base/macros.h"
- #include "base/memory/ptr_util.h"
- #include "base/metrics/histogram_macros.h"
- #include "base/path_service.h"
- #include "base/run_loop.h"
- #include "base/single_thread_task_runner.h"
- +#include "base/strings/string_number_conversions.h"
- #include "base/synchronization/waitable_event.h"
- #include "base/task/post_task.h"
- #include "base/task/task_traits.h"
- @@ -95,6 +97,7 @@
- #include "components/metrics/metrics_service.h"
- #include "components/metrics_services_manager/metrics_services_manager.h"
- #include "components/metrics_services_manager/metrics_services_manager_client.h"
- +#include "components/network_session_configurator/common/network_switches.h"
- #include "components/network_time/network_time_tracker.h"
- #include "components/optimization_guide/optimization_guide_features.h"
- #include "components/optimization_guide/optimization_guide_service.h"
- @@ -130,6 +133,7 @@
- #include "extensions/buildflags/buildflags.h"
- #include "extensions/common/constants.h"
- #include "media/media_buildflags.h"
- +#include "net/socket/client_socket_pool_manager.h"
- #include "ppapi/buildflags/buildflags.h"
- #include "printing/buildflags/buildflags.h"
- #include "services/network/public/cpp/features.h"
- @@ -315,6 +319,18 @@ void BrowserProcessImpl::Init() {
- base::Bind(&ApplyMetricsReportingPolicy));
- #endif
-
- + int max_connections_per_host = 0;
- + auto switch_value = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
- + switches::kMaxConnectionsPerHost);
- + if (!switch_value.empty() && !base::StringToInt(switch_value, &max_connections_per_host)) {
- + LOG(DFATAL) << "--" << switches::kMaxConnectionsPerHost
- + << " expected integer; got (\"" << switch_value << "\" instead)";
- + }
- + if (max_connections_per_host != 0) {
- + net::ClientSocketPoolManager::set_max_sockets_per_group(
- + net::HttpNetworkSession::NORMAL_SOCKET_POOL, max_connections_per_host);
- + }
- +
- DCHECK(!webrtc_event_log_manager_);
- webrtc_event_log_manager_ = WebRtcEventLogManager::CreateSingletonInstance();
-
- --- a/chrome/browser/BUILD.gn
- +++ b/chrome/browser/BUILD.gn
- @@ -1991,6 +1991,7 @@ jumbo_split_static_library("browser") {
- "//components/net_log",
- "//components/network_hints/common",
- "//components/network_session_configurator/browser",
- + "//components/network_session_configurator/common",
- "//components/network_time",
- "//components/ntp_tiles",
- "//components/offline_items_collection/core",
|