| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef CHROME_BROWSER_CHROMEOS_NET_NETWORK_THROTTLING_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_NET_NETWORK_THROTTLING_OBSERVER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_NET_NETWORK_THROTTLING_OBSERVER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_NET_NETWORK_THROTTLING_OBSERVER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "components/prefs/pref_change_registrar.h" | 11 #include "components/prefs/pref_change_registrar.h" |
| 12 | 12 |
| 13 class PrefRegistrySimple; | 13 class PrefRegistrySimple; |
| 14 class Profile; | |
| 15 | 14 |
| 16 namespace chromeos { | 15 namespace chromeos { |
| 17 | 16 |
| 18 // NetworkThrottlingObserver is a singleton, owned by | 17 // NetworkThrottlingObserver is a singleton, owned by |
| 19 // ChromeBrowserMainPartsChromeos. | 18 // ChromeBrowserMainPartsChromeos. |
| 20 // This class is responsible for propagating network bandwidth throttling policy | 19 // This class is responsible for propagating network bandwidth throttling policy |
| 21 // changes (prefs::kNetworkThrottlingEnabled) in Chrome down to Shill which | 20 // changes (prefs::kNetworkThrottlingEnabled) in Chrome down to Shill which |
| 22 // implements by calling 'tc' in the kernel. | 21 // implements by calling 'tc' in the kernel. |
| 23 class NetworkThrottlingObserver { | 22 class NetworkThrottlingObserver { |
| 24 public: | 23 public: |
| 25 explicit NetworkThrottlingObserver(PrefService* local_state); | 24 explicit NetworkThrottlingObserver(PrefService* local_state); |
| 26 ~NetworkThrottlingObserver(); | 25 ~NetworkThrottlingObserver(); |
| 27 | 26 |
| 28 static void RegisterPrefs(PrefRegistrySimple* registry); | 27 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 29 | 28 |
| 30 private: | 29 private: |
| 31 // Callback used when prefs::kNetworkThrottlingEnabled changes | 30 // Callback used when prefs::kNetworkThrottlingEnabled changes |
| 32 void OnPreferenceChanged(const std::string& pref_name); | 31 void OnPreferenceChanged(const std::string& pref_name); |
| 33 | 32 |
| 34 PrefService* local_state_; | 33 PrefService* local_state_; |
| 35 PrefChangeRegistrar pref_change_registrar_; | 34 PrefChangeRegistrar pref_change_registrar_; |
| 36 | 35 |
| 37 DISALLOW_COPY_AND_ASSIGN(NetworkThrottlingObserver); | 36 DISALLOW_COPY_AND_ASSIGN(NetworkThrottlingObserver); |
| 38 }; | 37 }; |
| 39 | 38 |
| 40 } // namespace chromeos | 39 } // namespace chromeos |
| 41 | 40 |
| 42 #endif // CHROME_BROWSER_CHROMEOS_NET_NETWORK_THROTTLING_OBSERVER_H_ | 41 #endif // CHROME_BROWSER_CHROMEOS_NET_NETWORK_THROTTLING_OBSERVER_H_ |
| OLD | NEW |