Commit e35022a3 authored by Pavol Marko's avatar Pavol Marko Committed by Commit Bot

Expose disable_idle_sockets_close_on_memory_pressure as feature

Adds a chrome Feature to disable closing idle sockets on memory
pressure. This only applies to Profile NetworkContexts.

Bug: 1150526
Test: new browser test
Change-Id: I0e4f18d8faa4f365bdd7dc404003e147ca47aa8c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2547723Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Commit-Queue: Pavol Marko <pmarko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#829161}
parent a8866d20
......@@ -70,6 +70,7 @@
#include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chromeos/constants/chromeos_features.h"
#include "chromeos/constants/chromeos_switches.h"
#include "components/user_manager/user.h"
#include "components/user_manager/user_manager.h"
......@@ -828,6 +829,13 @@ void ProfileNetworkContextService::ConfigureNetworkContextParamsInternal(
GetAdditionalCertificates(policy_cert_service,
GetPartitionPath(relative_partition_path));
}
// Disable idle sockets close on memory pressure if configured by finch or
// about://flags.
if (base::FeatureList::IsEnabled(
chromeos::features::kDisableIdleSocketsCloseOnMemoryPressure)) {
network_context_params->disable_idle_sockets_close_on_memory_pressure =
true;
}
#endif
// Should be initialized with existing per-profile CORS access lists.
......
......@@ -68,6 +68,10 @@
#include "services/network/public/mojom/url_loader_factory.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_CHROMEOS)
#include "chromeos/constants/chromeos_features.h"
#endif
// Most tests for this class are in NetworkContextConfigurationBrowserTest.
class ProfileNetworkContextServiceBrowsertest : public InProcessBrowserTest {
public:
......@@ -651,3 +655,58 @@ INSTANTIATE_TEST_SUITE_P(
ProfileNetworkContextServiceCertVerifierBuiltinFeaturePolicyTestWithService,
::testing::Bool());
#endif // BUILDFLAG(BUILTIN_CERT_VERIFIER_FEATURE_SUPPORTED)
#if defined(OS_CHROMEOS)
class ProfileNetworkContextServiceMemoryPressureFeatureBrowsertest
: public ProfileNetworkContextServiceBrowsertest,
public ::testing::WithParamInterface<base::Optional<bool>> {
public:
ProfileNetworkContextServiceMemoryPressureFeatureBrowsertest() = default;
~ProfileNetworkContextServiceMemoryPressureFeatureBrowsertest() override =
default;
void SetUp() override {
if (GetParam().has_value()) {
if (GetParam().value()) {
scoped_feature_list_.InitWithFeatures(
{chromeos::features::kDisableIdleSocketsCloseOnMemoryPressure}, {});
} else {
scoped_feature_list_.InitWithFeatures(
{}, {chromeos::features::kDisableIdleSocketsCloseOnMemoryPressure});
}
}
ProfileNetworkContextServiceBrowsertest::SetUp();
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
};
// If the feature is enabled (GetParam()==true),
// NetworkContextParams.disable_idle_sockets_close_on_memory_pressure is
// expected to be true.
// If the feature is not set or disabled (GetParam()==false or nullopt),
// NetworkContextParams.disable_idle_sockets_close_on_memory_pressure is
// expected to be false
IN_PROC_BROWSER_TEST_P(
ProfileNetworkContextServiceMemoryPressureFeatureBrowsertest,
FeaturePropagates) {
ProfileNetworkContextService* profile_network_context_service =
ProfileNetworkContextServiceFactory::GetForContext(browser()->profile());
base::FilePath empty_relative_partition_path;
network::mojom::NetworkContextParams network_context_params;
network::mojom::CertVerifierCreationParams cert_verifier_creation_params;
profile_network_context_service->ConfigureNetworkContextParams(
/*in_memory=*/false, empty_relative_partition_path,
&network_context_params, &cert_verifier_creation_params);
EXPECT_EQ(
GetParam().value_or(false),
network_context_params.disable_idle_sockets_close_on_memory_pressure);
}
INSTANTIATE_TEST_SUITE_P(
All,
ProfileNetworkContextServiceMemoryPressureFeatureBrowsertest,
/*disable_idle_sockets_close_on_memory_pressure=*/
::testing::Values(base::nullopt, true, false));
#endif // defined(OS_CHROMEOS)
......@@ -207,6 +207,15 @@ const base::Feature kCrostiniEnableDlc{"CrostiniEnableDlc",
const base::Feature kCryptAuthV2DeviceActivityStatus{
"CryptAuthV2DeviceActivityStatus", base::FEATURE_DISABLED_BY_DEFAULT};
// Disable idle sockets closing on memory pressure for NetworkContexts that
// belong to Profiles. It only applies to Profiles because the goal is to
// improve perceived performance of web browsing within the Chrome OS user
// session by avoiding re-estabshing TLS connections that require client
// certificates.
const base::Feature kDisableIdleSocketsCloseOnMemoryPressure{
"disable_idle_sockets_close_on_memory_pressure",
base::FEATURE_DISABLED_BY_DEFAULT};
// Enables or disables the CryptAuth v2 DeviceSync flow. Regardless of this
// flag, v1 DeviceSync will continue to operate until it is disabled via the
// feature flag kDisableCryptAuthV1DeviceSync.
......
......@@ -108,6 +108,8 @@ extern const base::Feature kDisableCryptAuthV1DeviceSync;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kCryptAuthV2DeviceActivityStatus;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kDisableIdleSocketsCloseOnMemoryPressure;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kCrostiniWebUIUpgrader;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kCryptAuthV2DeviceSync;
......
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