OLD | NEW |
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/chrome_notification_types.h" |
13 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
14 #include "content/browser/browser_thread.h" | 15 #include "content/browser/browser_thread.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/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( |
(...skipping 12 matching lines...) Expand all Loading... |
38 spdy_disabled_.Init(prefs::kDisableSpdy, prefs, this); | 38 spdy_disabled_.Init(prefs::kDisableSpdy, prefs, this); |
39 http_throttling_enabled_.Init(prefs::kHttpThrottlingEnabled, prefs, this); | 39 http_throttling_enabled_.Init(prefs::kHttpThrottlingEnabled, prefs, this); |
40 | 40 |
41 ApplySettings(NULL); | 41 ApplySettings(NULL); |
42 } | 42 } |
43 | 43 |
44 NetPrefObserver::~NetPrefObserver() { | 44 NetPrefObserver::~NetPrefObserver() { |
45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
46 } | 46 } |
47 | 47 |
48 void NetPrefObserver::Observe(NotificationType type, | 48 void NetPrefObserver::Observe(int type, |
49 const NotificationSource& source, | 49 const NotificationSource& source, |
50 const NotificationDetails& details) { | 50 const NotificationDetails& details) { |
51 DCHECK_EQ(type.value, NotificationType::PREF_CHANGED); | 51 DCHECK_EQ(type, chrome::NOTIFICATION_PREF_CHANGED); |
52 | 52 |
53 std::string* pref_name = Details<std::string>(details).ptr(); | 53 std::string* pref_name = Details<std::string>(details).ptr(); |
54 ApplySettings(pref_name); | 54 ApplySettings(pref_name); |
55 } | 55 } |
56 | 56 |
57 void NetPrefObserver::ApplySettings(const std::string* pref_name) { | 57 void NetPrefObserver::ApplySettings(const std::string* pref_name) { |
58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
59 | 59 |
60 chrome_browser_net::EnablePredictor(*network_prediction_enabled_); | 60 chrome_browser_net::EnablePredictor(*network_prediction_enabled_); |
61 if (prerender_manager_) | 61 if (prerender_manager_) |
(...skipping 20 matching lines...) Expand all Loading... |
82 false, | 82 false, |
83 PrefService::UNSYNCABLE_PREF); | 83 PrefService::UNSYNCABLE_PREF); |
84 prefs->RegisterBooleanPref(prefs::kHttpThrottlingMayExperiment, | 84 prefs->RegisterBooleanPref(prefs::kHttpThrottlingMayExperiment, |
85 true, | 85 true, |
86 PrefService::UNSYNCABLE_PREF); | 86 PrefService::UNSYNCABLE_PREF); |
87 | 87 |
88 // This is the earliest point at which we can set up the trial, as | 88 // This is the earliest point at which we can set up the trial, as |
89 // it relies on prefs for parameterization. | 89 // it relies on prefs for parameterization. |
90 CreateHttpThrottlingTrial(prefs); | 90 CreateHttpThrottlingTrial(prefs); |
91 } | 91 } |
OLD | NEW |