diff options
author | pastarmovj@chromium.org <pastarmovj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-11 09:35:45 +0000 |
---|---|---|
committer | pastarmovj@chromium.org <pastarmovj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-11 09:35:45 +0000 |
commit | 12c84e28a1eee00b8f2bb60c10395e9bf6007241 (patch) | |
tree | 4532fb4d65a980b155873c9ac35488eef53d16be /chrome/browser | |
parent | fbf45bc40900fb2be79e5938831ffd0f5f4c7514 (diff) | |
download | chromium_src-12c84e28a1eee00b8f2bb60c10395e9bf6007241.zip chromium_src-12c84e28a1eee00b8f2bb60c10395e9bf6007241.tar.gz chromium_src-12c84e28a1eee00b8f2bb60c10395e9bf6007241.tar.bz2 |
Introduce a policy to control the maximal number of connections per proxy server.
BUG=63658
TEST=All policy unit_tests should pass.
Review URL: http://codereview.chromium.org/7326017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91998 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
7 files changed, 36 insertions, 7 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index 4b1bd9d..67bd547 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -277,7 +277,9 @@ MetricsService* BrowserMainParts::SetupMetricsAndFieldTrials( // to send metrics. field_trial_list_.reset(new base::FieldTrialList(metrics->GetClientId())); - SetupFieldTrials(metrics->recording_active()); + SetupFieldTrials(metrics->recording_active(), + local_state->IsManagedPreference( + prefs::kMaxConnectionsPerProxy)); // Initialize FieldTrialSynchronizer system. This is a singleton and is used // for posting tasks via NewRunnableMethod. Its deleted when it goes out of @@ -633,7 +635,8 @@ MetricsService* BrowserMainParts::InitializeMetrics( return metrics; } -void BrowserMainParts::SetupFieldTrials(bool metrics_recording_enabled) { +void BrowserMainParts::SetupFieldTrials(bool metrics_recording_enabled, + bool proxy_policy_is_set) { if (metrics_recording_enabled) chrome_browser_net_websocket_experiment::WebSocketExperimentRunner::Start(); @@ -641,7 +644,10 @@ void BrowserMainParts::SetupFieldTrials(bool metrics_recording_enabled) { // ProxyConnectionsFieldTrial(). ConnectionFieldTrial(); SocketTimeoutFieldTrial(); - ProxyConnectionsFieldTrial(); + // If a policy is defining the number of active connections this field test + // shoud not be performed. + if (!proxy_policy_is_set) + ProxyConnectionsFieldTrial(); prerender::ConfigurePrefetchAndPrerender(parsed_command_line()); SpdyFieldTrial(); ConnectBackupJobsFieldTrial(); diff --git a/chrome/browser/browser_main.h b/chrome/browser/browser_main.h index e13a12d..85dce6f 100644 --- a/chrome/browser/browser_main.h +++ b/chrome/browser/browser_main.h @@ -147,7 +147,8 @@ class BrowserMainParts { const PrefService* local_state); // Add an invocation of your field trial init function to this method. - void SetupFieldTrials(bool metrics_recording_enabled); + void SetupFieldTrials(bool metrics_recording_enabled, + bool proxy_policy_is_set); // Members initialized on construction --------------------------------------- diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc index 1b35f11..a68073d 100644 --- a/chrome/browser/browser_process_impl.cc +++ b/chrome/browser/browser_process_impl.cc @@ -78,6 +78,7 @@ #include "content/browser/renderer_host/resource_dispatcher_host.h" #include "content/common/notification_service.h" #include "ipc/ipc_logging.h" +#include "net/socket/client_socket_pool_manager.h" #include "net/url_request/url_request_context_getter.h" #include "ui/base/clipboard/clipboard.h" #include "ui/base/l10n/l10n_util.h" @@ -850,6 +851,15 @@ void BrowserProcessImpl::CreateLocalState() { // able so we need to have it when initializing the profiles. local_state_->RegisterFilePathPref(prefs::kDiskCacheDir, FilePath()); + // Another policy that needs to be defined before the net subsystem is + // initialized is MaxConnectionsPerProxy so we do it here. + local_state_->RegisterIntegerPref(prefs::kMaxConnectionsPerProxy, + net::kDefaultMaxSocketsPerProxyServer); + int max_per_proxy = local_state_->GetInteger(prefs::kMaxConnectionsPerProxy); + net::ClientSocketPoolManager::set_max_sockets_per_proxy_server( + std::max(std::min(max_per_proxy, 99), + net::ClientSocketPoolManager::max_sockets_per_group())); + // This is observed by ChildProcessSecurityPolicy, which lives in content/ // though, so it can't register itself. local_state_->RegisterListPref(prefs::kDisabledSchemes); diff --git a/chrome/browser/policy/configuration_policy_pref_store.cc b/chrome/browser/policy/configuration_policy_pref_store.cc index 3e62c8d..cf44547 100644 --- a/chrome/browser/policy/configuration_policy_pref_store.cc +++ b/chrome/browser/policy/configuration_policy_pref_store.cc @@ -274,6 +274,8 @@ const ConfigurationPolicyPrefKeeper::PolicyToPreferenceMapEntry prefs::kEditBookmarksEnabled }, { Value::TYPE_BOOLEAN, kPolicyAllowFileSelectionDialogs, prefs::kAllowFileSelectionDialogs }, + { Value::TYPE_INTEGER, kPolicyMaxConnectionsPerProxy, + prefs::kMaxConnectionsPerProxy }, #if defined(OS_CHROMEOS) { Value::TYPE_BOOLEAN, kPolicyChromeOsLockOnIdleSuspend, @@ -1065,6 +1067,8 @@ ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList() { key::kAllowFileSelectionDialogs }, { kPolicyDiskCacheDir, Value::TYPE_STRING, key::kDiskCacheDir }, + { kPolicyMaxConnectionsPerProxy, Value::TYPE_INTEGER, + key::kMaxConnectionsPerProxy }, #if defined(OS_CHROMEOS) { kPolicyChromeOsLockOnIdleSuspend, Value::TYPE_BOOLEAN, diff --git a/chrome/browser/policy/configuration_policy_pref_store_unittest.cc b/chrome/browser/policy/configuration_policy_pref_store_unittest.cc index d209228..ca1449f 100644 --- a/chrome/browser/policy/configuration_policy_pref_store_unittest.cc +++ b/chrome/browser/policy/configuration_policy_pref_store_unittest.cc @@ -273,7 +273,9 @@ INSTANTIATE_TEST_CASE_P( TypeAndName(kPolicyRestoreOnStartup, prefs::kRestoreOnStartup), TypeAndName(kPolicyPolicyRefreshRate, - prefs::kUserPolicyRefreshRate))); + prefs::kUserPolicyRefreshRate), + TypeAndName(kPolicyMaxConnectionsPerProxy, + prefs::kMaxConnectionsPerProxy))); // Test cases for the proxy policy settings. class ConfigurationPolicyPrefStoreProxyTest : public testing::Test { diff --git a/chrome/browser/policy/configuration_policy_provider_mac_unittest.cc b/chrome/browser/policy/configuration_policy_provider_mac_unittest.cc index 668492d..3a486cf 100644 --- a/chrome/browser/policy/configuration_policy_provider_mac_unittest.cc +++ b/chrome/browser/policy/configuration_policy_provider_mac_unittest.cc @@ -345,6 +345,9 @@ INSTANTIATE_TEST_CASE_P( key::kDisabledSchemes), PolicyTestParams::ForStringPolicy( kPolicyDiskCacheDir, - key::kDiskCacheDir))); + key::kDiskCacheDir), + PolicyTestParams::ForIntegerPolicy( + kPolicyMaxConnectionsPerProxy, + key::kMaxConnectionsPerProxy))); } // namespace policy diff --git a/chrome/browser/policy/configuration_policy_provider_win_unittest.cc b/chrome/browser/policy/configuration_policy_provider_win_unittest.cc index b14e5b5..b2cc3ce 100644 --- a/chrome/browser/policy/configuration_policy_provider_win_unittest.cc +++ b/chrome/browser/policy/configuration_policy_provider_win_unittest.cc @@ -503,6 +503,9 @@ INSTANTIATE_TEST_CASE_P( key::kDisabledSchemes), PolicyTestParams::ForStringPolicy( kPolicyDiskCacheDir, - key::kDiskCacheDir))); + key::kDiskCacheDir), + PolicyTestParams::ForIntegerPolicy( + kPolicyMaxConnectionsPerProxy, + key::kMaxConnectionsPerProxy))); } // namespace policy |