123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- 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 ++++
- .../spoof_checks/top_domains/BUILD.gn | 1 +
- net/socket/client_socket_pool_manager.cc | 17 +++++++++++++++++
- 8 files changed, 44 insertions(+)
- diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
- --- a/chrome/browser/about_flags.cc
- +++ b/chrome/browser/about_flags.cc
- @@ -849,6 +849,11 @@ const FeatureEntry::Choice kForceEffectiveConnectionTypeChoices[] = {
- 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 ==
- @@ -3918,6 +3923,9 @@ const FeatureEntry kFeatureEntries[] = {
- flag_descriptions::kAndroidPictureInPictureAPIName,
- flag_descriptions::kAndroidPictureInPictureAPIDescription, kOsAndroid,
- FEATURE_VALUE_TYPE(media::kPictureInPictureAPI)},
- + {"max-connections-per-host", flag_descriptions::kMaxConnectionsPerHostName,
- + flag_descriptions::kMaxConnectionsPerHostDescription, kOsAll,
- + MULTI_VALUE_TYPE(kMaxConnectionsPerHostChoices)},
- {"reengagement-notification",
- flag_descriptions::kReengagementNotificationName,
- flag_descriptions::kReengagementNotificationDescription, kOsAndroid,
- diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc
- --- a/chrome/browser/flag_descriptions.cc
- +++ b/chrome/browser/flag_descriptions.cc
- @@ -1626,6 +1626,10 @@ const char kMediaHistoryDescription[] =
- "Enables Media History which records data around media playbacks on "
- "websites.";
-
- +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[] =
- diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h
- --- a/chrome/browser/flag_descriptions.h
- +++ b/chrome/browser/flag_descriptions.h
- @@ -933,6 +933,9 @@ extern const char kLogJsConsoleMessagesDescription[];
- extern const char kMediaHistoryName[];
- extern const char kMediaHistoryDescription[];
-
- +extern const char kMaxConnectionsPerHostName[];
- +extern const char kMaxConnectionsPerHostDescription[];
- +
- extern const char kMediaRouterCastAllowAllIPsName[];
- extern const char kMediaRouterCastAllowAllIPsDescription[];
-
- diff --git a/components/network_session_configurator/common/network_features.cc b/components/network_session_configurator/common/network_features.cc
- --- a/components/network_session_configurator/common/network_features.cc
- +++ b/components/network_session_configurator/common/network_features.cc
- @@ -8,4 +8,7 @@
-
- namespace features {
-
- +const char kMaxConnectionsPerHostChoiceDefault[] = "6",
- + kMaxConnectionsPerHostChoice15[] = "15";
- +
- } // namespace features
- diff --git a/components/network_session_configurator/common/network_features.h b/components/network_session_configurator/common/network_features.h
- --- 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[];
- +
- } // namespace features
-
- #endif // COMPONENTS_NETWORK_SESSION_CONFIGURATOR_COMMON_NETWORK_FEATURES_H_
- diff --git a/components/network_session_configurator/common/network_switch_list.h b/components/network_session_configurator/common/network_switch_list.h
- --- a/components/network_session_configurator/common/network_switch_list.h
- +++ b/components/network_session_configurator/common/network_switch_list.h
- @@ -19,6 +19,10 @@ NETWORK_SWITCH(kEnableUserAlternateProtocolPorts,
- // 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")
-
- diff --git a/components/url_formatter/spoof_checks/top_domains/BUILD.gn b/components/url_formatter/spoof_checks/top_domains/BUILD.gn
- --- a/components/url_formatter/spoof_checks/top_domains/BUILD.gn
- +++ b/components/url_formatter/spoof_checks/top_domains/BUILD.gn
- @@ -73,6 +73,7 @@ executable("make_top_domain_list_variables") {
- "//base:i18n",
- "//components/url_formatter/spoof_checks/common_words:common",
- "//third_party/icu",
- + "//components/network_session_configurator/common"
- ]
- if (is_ios) {
- frameworks = [ "UIKit.framework" ]
- diff --git a/net/socket/client_socket_pool_manager.cc b/net/socket/client_socket_pool_manager.cc
- --- a/net/socket/client_socket_pool_manager.cc
- +++ b/net/socket/client_socket_pool_manager.cc
- @@ -20,6 +20,10 @@
- #include "net/socket/client_socket_handle.h"
- #include "net/socket/client_socket_pool.h"
- #include "net/socket/connect_job.h"
- +#include "components/network_session_configurator/common/network_switches.h"
- +
- +#include "base/command_line.h"
- +#include "base/strings/string_number_conversions.h"
- #include "net/ssl/ssl_config.h"
- #include "third_party/abseil-cpp/absl/types/optional.h"
- #include "url/gurl.h"
- @@ -173,6 +177,19 @@ void ClientSocketPoolManager::set_max_sockets_per_pool(
- int ClientSocketPoolManager::max_sockets_per_group(
- HttpNetworkSession::SocketPoolType pool_type) {
- DCHECK_LT(pool_type, HttpNetworkSession::NUM_SOCKET_POOL_TYPES);
- +
- + if (pool_type == HttpNetworkSession::NORMAL_SOCKET_POOL) {
- + int maxConnectionsPerHost = 0;
- + auto value = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switches::kMaxConnectionsPerHost);
- + if (!value.empty() && !base::StringToInt(value, &maxConnectionsPerHost)) {
- + LOG(DFATAL) << "--" << switches::kMaxConnectionsPerHost << " only accepts integers as arguments (\"" << value << "\" is invalid)";
- + }
- + if (maxConnectionsPerHost != 0) {
- + return maxConnectionsPerHost;
- + }
- + // fallthrough for default value
- + }
- +
- return g_max_sockets_per_group[pool_type];
- }
-
- --
- 2.20.1
|