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