Chromium Code Reviews| Index: chrome/browser/chromeos/net/network_throttling_observer.h |
| diff --git a/chrome/browser/chromeos/net/network_throttling_observer.h b/chrome/browser/chromeos/net/network_throttling_observer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4ac99f392265872d9f07d89dc1c58a18f113bca5 |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/net/network_throttling_observer.h |
| @@ -0,0 +1,45 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_CHROMEOS_NET_NETWORK_THROTTLING_OBSERVER_H_ |
| +#define CHROME_BROWSER_CHROMEOS_NET_NETWORK_THROTTLING_OBSERVER_H_ |
| + |
| +#include "base/memory/weak_ptr.h" |
| + |
| +class PrefRegistrySimple; |
| +class Profile; |
| + |
| +namespace chromeos { |
| + |
| +namespace network_throttling_observer { |
| + |
| +void RegisterPrefs(PrefRegistrySimple* registry); |
| +} |
| + |
| +// Helper class that listens for changes in network throttling |
| +// policy, and propagates them down to shill (the network manager). |
| +// Call-flow: NetworkThrottlingObserver |
| +// -> NetworkStateHandler |
| +// -> ShillManagerClient |
| +class NetworkThrottlingObserver { |
|
Andrew T Wilson (Slow)
2016/10/21 13:27:30
This is a weird class - it's owned by ChromeBrowse
stevenjb
2016/10/21 19:41:20
+1. We generally use one of two patterns:
1) The
stevenjb
2016/10/21 20:25:54
If we make this a pref observer we shouldn't need
kirtika1
2016/10/23 00:04:49
Done, used (1)
kirtika1
2016/10/23 00:04:49
Thanks for that suggestion!Done.
|
| + public: |
| + NetworkThrottlingObserver(); |
| + ~NetworkThrottlingObserver(); |
| + |
| + static NetworkThrottlingObserver* Get(); |
| + |
| + // Should be called whenever the network throttling policy changes |
| + void OnPreferenceChanged(bool throttling_enabled, |
| + uint32_t upload_rate_kbits, |
| + uint32_t download_rate_kbits); |
| + |
| + private: |
| + base::WeakPtrFactory<NetworkThrottlingObserver> weak_ptr_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(NetworkThrottlingObserver); |
| +}; |
| + |
| +} // namespace chromeos |
| + |
| +#endif // CHROME_BROWSER_CHROMEOS_NET_NETWORK_THROTTLING_OBSERVER_H_ |