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

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

Issue 7688006: Revert 97465 - Revert 97446 - Modifying prefetch to account for multi-profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 4 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
« no previous file with comments | « chrome/browser/net/net_pref_observer.h ('k') | chrome/browser/net/predictor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.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/chrome_notification_types.h" 13 #include "chrome/common/chrome_notification_types.h"
14 #include "chrome/common/pref_names.h" 14 #include "chrome/common/pref_names.h"
15 #include "content/browser/browser_thread.h" 15 #include "content/browser/browser_thread.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/url_request/url_request_throttler_manager.h" 18 #include "net/url_request/url_request_throttler_manager.h"
19 19
20 namespace { 20 namespace {
21 21
22 // Function (for NewRunnableFunction) to call the set_enforce_throttling 22 // Function (for NewRunnableFunction) to call the set_enforce_throttling
23 // member on the URLRequestThrottlerManager singleton. 23 // member on the URLRequestThrottlerManager singleton.
24 void SetEnforceThrottlingOnThrottlerManager(bool enforce) { 24 void SetEnforceThrottlingOnThrottlerManager(bool enforce) {
25 net::URLRequestThrottlerManager::GetInstance()->set_enforce_throttling( 25 net::URLRequestThrottlerManager::GetInstance()->set_enforce_throttling(
26 enforce); 26 enforce);
27 } 27 }
28 28
29 } 29 }
30 30
31 NetPrefObserver::NetPrefObserver(PrefService* prefs, 31 NetPrefObserver::NetPrefObserver(PrefService* prefs,
32 prerender::PrerenderManager* prerender_manager) 32 prerender::PrerenderManager* prerender_manager,
33 : prerender_manager_(prerender_manager) { 33 chrome_browser_net::Predictor* predictor)
34 : prerender_manager_(prerender_manager),
35 predictor_(predictor) {
34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
35 DCHECK(prefs); 37 DCHECK(prefs);
38 DCHECK(predictor);
39
36 network_prediction_enabled_.Init(prefs::kNetworkPredictionEnabled, prefs, 40 network_prediction_enabled_.Init(prefs::kNetworkPredictionEnabled, prefs,
37 this); 41 this);
38 spdy_disabled_.Init(prefs::kDisableSpdy, prefs, this); 42 spdy_disabled_.Init(prefs::kDisableSpdy, prefs, this);
39 http_throttling_enabled_.Init(prefs::kHttpThrottlingEnabled, prefs, this); 43 http_throttling_enabled_.Init(prefs::kHttpThrottlingEnabled, prefs, this);
40 44
41 ApplySettings(NULL); 45 ApplySettings(NULL);
42 } 46 }
43 47
44 NetPrefObserver::~NetPrefObserver() { 48 NetPrefObserver::~NetPrefObserver() {
45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 49 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
46 } 50 }
47 51
48 void NetPrefObserver::Observe(int type, 52 void NetPrefObserver::Observe(int type,
49 const NotificationSource& source, 53 const NotificationSource& source,
50 const NotificationDetails& details) { 54 const NotificationDetails& details) {
51 DCHECK_EQ(type, chrome::NOTIFICATION_PREF_CHANGED); 55 DCHECK_EQ(type, chrome::NOTIFICATION_PREF_CHANGED);
52 56
53 std::string* pref_name = Details<std::string>(details).ptr(); 57 std::string* pref_name = Details<std::string>(details).ptr();
54 ApplySettings(pref_name); 58 ApplySettings(pref_name);
55 } 59 }
56 60
57 void NetPrefObserver::ApplySettings(const std::string* pref_name) { 61 void NetPrefObserver::ApplySettings(const std::string* pref_name) {
58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
59 63
60 chrome_browser_net::EnablePredictor(*network_prediction_enabled_); 64 predictor_->EnablePredictor(*network_prediction_enabled_);
61 if (prerender_manager_) 65 if (prerender_manager_)
62 prerender_manager_->set_enabled(*network_prediction_enabled_); 66 prerender_manager_->set_enabled(*network_prediction_enabled_);
63 net::HttpStreamFactory::set_spdy_enabled(!*spdy_disabled_); 67 net::HttpStreamFactory::set_spdy_enabled(!*spdy_disabled_);
64 68
65 if (!pref_name || *pref_name == prefs::kHttpThrottlingEnabled) { 69 if (!pref_name || *pref_name == prefs::kHttpThrottlingEnabled) {
66 BrowserThread::PostTask( 70 BrowserThread::PostTask(
67 BrowserThread::IO, FROM_HERE, 71 BrowserThread::IO, FROM_HERE,
68 NewRunnableFunction(SetEnforceThrottlingOnThrottlerManager, 72 NewRunnableFunction(SetEnforceThrottlingOnThrottlerManager,
69 *http_throttling_enabled_)); 73 *http_throttling_enabled_));
70 } 74 }
(...skipping 11 matching lines...) Expand all
82 false, 86 false,
83 PrefService::UNSYNCABLE_PREF); 87 PrefService::UNSYNCABLE_PREF);
84 prefs->RegisterBooleanPref(prefs::kHttpThrottlingMayExperiment, 88 prefs->RegisterBooleanPref(prefs::kHttpThrottlingMayExperiment,
85 true, 89 true,
86 PrefService::UNSYNCABLE_PREF); 90 PrefService::UNSYNCABLE_PREF);
87 91
88 // This is the earliest point at which we can set up the trial, as 92 // This is the earliest point at which we can set up the trial, as
89 // it relies on prefs for parameterization. 93 // it relies on prefs for parameterization.
90 CreateHttpThrottlingTrial(prefs); 94 CreateHttpThrottlingTrial(prefs);
91 } 95 }
OLDNEW
« no previous file with comments | « chrome/browser/net/net_pref_observer.h ('k') | chrome/browser/net/predictor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698