| 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 // Tests can manually set EffectiveConnectionType, but browser tests should | 22 // Tests can manually set EffectiveConnectionType, but browser tests should |
| 24 // expect that the EffectiveConnectionType could change. | 23 // expect that the EffectiveConnectionType could change. |
| 25 void SetEffectiveConnectionTypeForTesting( | 24 void SetEffectiveConnectionTypeForTesting(net::EffectiveConnectionType type); |
| 26 net::NetworkQualityEstimator::EffectiveConnectionType type); | |
| 27 | 25 |
| 28 private: | 26 private: |
| 29 class IONetworkQualityObserver; | 27 class IONetworkQualityObserver; |
| 30 | 28 |
| 31 // KeyedService implementation: | 29 // KeyedService implementation: |
| 32 void Shutdown() override; | 30 void Shutdown() override; |
| 33 | 31 |
| 34 // Called when the EffectiveConnectionType has updated to |type|. | 32 // Called when the EffectiveConnectionType has updated to |type|. |
| 35 // NetworkQualityEstimator::EffectiveConnectionType is an estimate of the | 33 // NetworkQualityEstimator::EffectiveConnectionType is an estimate of the |
| 36 // quality of the network that may differ from the actual network type | 34 // quality of the network that may differ from the actual network type |
| 37 // reported by NetworkchangeNotifier::GetConnectionType. | 35 // reported by NetworkchangeNotifier::GetConnectionType. |
| 38 void EffectiveConnectionTypeChanged( | 36 void EffectiveConnectionTypeChanged(net::EffectiveConnectionType type); |
| 39 net::NetworkQualityEstimator::EffectiveConnectionType type); | |
| 40 | 37 |
| 41 // The current EffectiveConnectionType. | 38 // The current EffectiveConnectionType. |
| 42 net::NetworkQualityEstimator::EffectiveConnectionType type_; | 39 net::EffectiveConnectionType type_; |
| 43 | 40 |
| 44 // IO thread based observer that is owned by this service. Created on the UI | 41 // IO thread based observer that is owned by this service. Created on the UI |
| 45 // thread, but used and deleted on the IO thread. | 42 // thread, but used and deleted on the IO thread. |
| 46 IONetworkQualityObserver* io_observer_; | 43 IONetworkQualityObserver* io_observer_; |
| 47 | 44 |
| 48 base::WeakPtrFactory<UINetworkQualityEstimatorService> weak_factory_; | 45 base::WeakPtrFactory<UINetworkQualityEstimatorService> weak_factory_; |
| 49 | 46 |
| 50 DISALLOW_COPY_AND_ASSIGN(UINetworkQualityEstimatorService); | 47 DISALLOW_COPY_AND_ASSIGN(UINetworkQualityEstimatorService); |
| 51 }; | 48 }; |
| 52 | 49 |
| 53 #endif // CHROME_BROWSER_NET_NQE_UI_NETWORK_QUALITY_ESTIMATOR_SERVICE_H_ | 50 #endif // CHROME_BROWSER_NET_NQE_UI_NETWORK_QUALITY_ESTIMATOR_SERVICE_H_ |
| OLD | NEW |