OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_NET_NQE_UI_NETWORK_QUALITY_ESTIMATOR_SERVICE_H_ |
| 6 #define CHROME_BROWSER_NET_NQE_UI_NETWORK_QUALITY_ESTIMATOR_SERVICE_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/threading/thread_checker.h" |
| 11 #include "components/keyed_service/core/keyed_service.h" |
| 12 #include "net/nqe/network_quality_estimator.h" |
| 13 |
| 14 class Profile; |
| 15 |
| 16 // UI service to determine the current EffectiveConnectionType. |
| 17 class UINetworkQualityEstimatorService : public KeyedService { |
| 18 public: |
| 19 explicit UINetworkQualityEstimatorService(Profile* profile); |
| 20 ~UINetworkQualityEstimatorService() override; |
| 21 |
| 22 // The current EffectiveConnectionType. |
| 23 net::NetworkQualityEstimator::EffectiveConnectionType |
| 24 GetEffectiveConnectionType() const; |
| 25 |
| 26 private: |
| 27 class IONetworkQualityObserver; |
| 28 |
| 29 // KeyedService implementation: |
| 30 void Shutdown() override; |
| 31 |
| 32 // Called when the EffectiveConnectionType has updated to |type|. |
| 33 // NetworkQualityEstimator::EffectiveConnectionType is an estimate of the |
| 34 // quality of the network that may differ from the actual network type |
| 35 // reported by NetworkchangeNotifier::GetConnectionType. |
| 36 void EffectiveConnectionTypeChanged( |
| 37 net::NetworkQualityEstimator::EffectiveConnectionType type); |
| 38 |
| 39 // The current EffectiveConnectionType. |
| 40 net::NetworkQualityEstimator::EffectiveConnectionType type_; |
| 41 |
| 42 // IO thread based observer that is owned by this service. Created on the UI |
| 43 // thread, but used and deleted on the IO thread. |
| 44 IONetworkQualityObserver* io_observer_; |
| 45 |
| 46 base::WeakPtrFactory<UINetworkQualityEstimatorService> weak_factory_; |
| 47 |
| 48 DISALLOW_COPY_AND_ASSIGN(UINetworkQualityEstimatorService); |
| 49 }; |
| 50 |
| 51 #endif // CHROME_BROWSER_NET_NQE_UI_NETWORK_QUALITY_ESTIMATOR_SERVICE_H_ |
OLD | NEW |