Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Side by Side Diff: chrome/browser/net/net_pref_observer.cc

Issue 7283018: Introduce a policy to control the maximal number of connections per proxy server. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/net/net_pref_observer.h" 5 #include "chrome/browser/net/net_pref_observer.h"
6 6
7 #include "base/task.h" 7 #include "base/task.h"
8 #include "chrome/browser/net/predictor_api.h" 8 #include "chrome/browser/net/predictor_api.h"
9 #include "chrome/browser/prefs/pref_service.h" 9 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/browser/prerender/prerender_manager.h" 10 #include "chrome/browser/prerender/prerender_manager.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/trials/http_throttling_trial.h" 12 #include "chrome/browser/trials/http_throttling_trial.h"
13 #include "chrome/common/pref_names.h" 13 #include "chrome/common/pref_names.h"
14 #include "content/browser/browser_thread.h" 14 #include "content/browser/browser_thread.h"
15 #include "content/common/notification_type.h" 15 #include "content/common/notification_type.h"
16 #include "content/common/notification_details.h" 16 #include "content/common/notification_details.h"
17 #include "net/http/http_stream_factory.h" 17 #include "net/http/http_stream_factory.h"
18 #include "net/socket/client_socket_pool_manager.h"
18 #include "net/url_request/url_request_throttler_manager.h" 19 #include "net/url_request/url_request_throttler_manager.h"
19 20
20 namespace { 21 namespace {
21 22
22 // Function (for NewRunnableFunction) to call the set_enforce_throttling 23 // Function (for NewRunnableFunction) to call the set_enforce_throttling
23 // member on the URLRequestThrottlerManager singleton. 24 // member on the URLRequestThrottlerManager singleton.
24 void SetEnforceThrottlingOnThrottlerManager(bool enforce) { 25 void SetEnforceThrottlingOnThrottlerManager(bool enforce) {
25 net::URLRequestThrottlerManager::GetInstance()->set_enforce_throttling( 26 net::URLRequestThrottlerManager::GetInstance()->set_enforce_throttling(
26 enforce); 27 enforce);
27 } 28 }
28 29
29 } 30 }
30 31
31 NetPrefObserver::NetPrefObserver(PrefService* prefs, 32 NetPrefObserver::NetPrefObserver(PrefService* prefs,
32 prerender::PrerenderManager* prerender_manager) 33 prerender::PrerenderManager* prerender_manager)
33 : prerender_manager_(prerender_manager) { 34 : prerender_manager_(prerender_manager) {
34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
35 DCHECK(prefs); 36 DCHECK(prefs);
36 network_prediction_enabled_.Init(prefs::kNetworkPredictionEnabled, prefs, 37 network_prediction_enabled_.Init(prefs::kNetworkPredictionEnabled, prefs,
37 this); 38 this);
38 spdy_disabled_.Init(prefs::kDisableSpdy, prefs, this); 39 spdy_disabled_.Init(prefs::kDisableSpdy, prefs, this);
39 http_throttling_enabled_.Init(prefs::kHttpThrottlingEnabled, prefs, this); 40 http_throttling_enabled_.Init(prefs::kHttpThrottlingEnabled, prefs, this);
41 max_connections_per_proxy_.Init(prefs::kMaxConnectionsPerProxy, prefs, this);
40 42
41 ApplySettings(NULL); 43 ApplySettings(NULL);
42 } 44 }
43 45
44 NetPrefObserver::~NetPrefObserver() { 46 NetPrefObserver::~NetPrefObserver() {
45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 47 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
46 } 48 }
47 49
48 void NetPrefObserver::Observe(NotificationType type, 50 void NetPrefObserver::Observe(NotificationType type,
49 const NotificationSource& source, 51 const NotificationSource& source,
(...skipping 11 matching lines...) Expand all
61 if (prerender_manager_) 63 if (prerender_manager_)
62 prerender_manager_->set_enabled(*network_prediction_enabled_); 64 prerender_manager_->set_enabled(*network_prediction_enabled_);
63 net::HttpStreamFactory::set_spdy_enabled(!*spdy_disabled_); 65 net::HttpStreamFactory::set_spdy_enabled(!*spdy_disabled_);
64 66
65 if (!pref_name || *pref_name == prefs::kHttpThrottlingEnabled) { 67 if (!pref_name || *pref_name == prefs::kHttpThrottlingEnabled) {
66 BrowserThread::PostTask( 68 BrowserThread::PostTask(
67 BrowserThread::IO, FROM_HERE, 69 BrowserThread::IO, FROM_HERE,
68 NewRunnableFunction(SetEnforceThrottlingOnThrottlerManager, 70 NewRunnableFunction(SetEnforceThrottlingOnThrottlerManager,
69 *http_throttling_enabled_)); 71 *http_throttling_enabled_));
70 } 72 }
73
74 if (!pref_name || *pref_name == prefs::kMaxConnectionsPerProxy) {
willchan no longer on Chromium 2011/06/29 22:54:55 There are a few issues here. First, this is only s
pastarmovj 2011/07/01 18:52:44 Ok i removed the dynamic marking from the policy a
75 // Make sure the value is not greater than 100 and nor smaller than the
76 // maximal number of connections allowed per group.
77 net::ClientSocketPoolManager::set_max_sockets_per_proxy_server(
78 std::max(std::min(*max_connections_per_proxy_, 100),
79 net::ClientSocketPoolManager::max_sockets_per_group()));
80 }
71 } 81 }
72 82
73 // static 83 // static
74 void NetPrefObserver::RegisterPrefs(PrefService* prefs) { 84 void NetPrefObserver::RegisterPrefs(PrefService* prefs) {
75 prefs->RegisterBooleanPref(prefs::kNetworkPredictionEnabled, 85 prefs->RegisterBooleanPref(prefs::kNetworkPredictionEnabled,
76 true, 86 true,
77 PrefService::SYNCABLE_PREF); 87 PrefService::SYNCABLE_PREF);
78 prefs->RegisterBooleanPref(prefs::kDisableSpdy, 88 prefs->RegisterBooleanPref(prefs::kDisableSpdy,
79 false, 89 false,
80 PrefService::UNSYNCABLE_PREF); 90 PrefService::UNSYNCABLE_PREF);
81 prefs->RegisterBooleanPref(prefs::kHttpThrottlingEnabled, 91 prefs->RegisterBooleanPref(prefs::kHttpThrottlingEnabled,
82 false, 92 false,
83 PrefService::UNSYNCABLE_PREF); 93 PrefService::UNSYNCABLE_PREF);
84 prefs->RegisterBooleanPref(prefs::kHttpThrottlingMayExperiment, 94 prefs->RegisterBooleanPref(prefs::kHttpThrottlingMayExperiment,
85 true, 95 true,
86 PrefService::UNSYNCABLE_PREF); 96 PrefService::UNSYNCABLE_PREF);
87 97 prefs->RegisterIntegerPref(prefs::kMaxConnectionsPerProxy,
98 32,
willchan no longer on Chromium 2011/06/29 22:54:55 This should probably use a default that is read fr
pastarmovj 2011/07/01 18:52:44 Done.
99 PrefService::UNSYNCABLE_PREF);
88 // This is the earliest point at which we can set up the trial, as 100 // This is the earliest point at which we can set up the trial, as
89 // it relies on prefs for parameterization. 101 // it relies on prefs for parameterization.
90 CreateHttpThrottlingTrial(prefs); 102 CreateHttpThrottlingTrial(prefs);
91 } 103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698