Chromium Code Reviews| Index: components/metrics/net/network_metrics_provider.h |
| diff --git a/components/metrics/net/network_metrics_provider.h b/components/metrics/net/network_metrics_provider.h |
| index da47689d2746187f5e7ba4e874a07c867327139b..08845bd882ced1bc609f4beb850f4c0b1d387947 100644 |
| --- a/components/metrics/net/network_metrics_provider.h |
| +++ b/components/metrics/net/network_metrics_provider.h |
| @@ -10,11 +10,17 @@ |
| #include "base/macros.h" |
| #include "base/memory/weak_ptr.h" |
| #include "base/metrics/histogram_base.h" |
| +#include "base/threading/thread_checker.h" |
| #include "components/metrics/metrics_provider.h" |
| #include "components/metrics/net/wifi_access_point_info_provider.h" |
| #include "components/metrics/proto/system_profile.pb.h" |
| #include "net/base/network_change_notifier.h" |
| #include "net/base/network_interfaces.h" |
| +#include "net/nqe/effective_connection_type.h" |
| + |
| +namespace net { |
| +class NetworkQualityEstimator; |
| +} |
| namespace metrics { |
| @@ -27,9 +33,20 @@ class NetworkMetricsProvider |
| // Creates a NetworkMetricsProvider, where |io_task_runner| is used to post |
| // network info collection tasks. |
| explicit NetworkMetricsProvider(base::TaskRunner* io_task_runner); |
| + |
| + // Sets the network quality estimator which can be accessed via |task_runner|. |
| + void ProvideNetworkQualityEstimator( |
| + net::NetworkQualityEstimator* network_quality_estimator, |
|
Alexei Svitkine (slow)
2017/01/03 17:48:48
Non-const params should be last.
tbansal1
2017/01/03 18:55:43
Done.
|
| + const scoped_refptr<base::SequencedTaskRunner>& task_runner); |
| + |
| ~NetworkMetricsProvider() override; |
| private: |
| + FRIEND_TEST_ALL_PREFIXES(NetworkMetricsProviderTest, EffectiveConnectionType); |
| + |
| + // Listens to the changes in the effective conection type. |
| + class EffectiveConnectionTypeObserver; |
| + |
| // MetricsProvider: |
| void ProvideGeneralMetrics(ChromeUserMetricsExtension* uma_proto) override; |
| void ProvideSystemProfileMetrics(SystemProfileProto* system_profile) override; |
| @@ -41,6 +58,8 @@ class NetworkMetricsProvider |
| SystemProfileProto::Network::ConnectionType GetConnectionType() const; |
| SystemProfileProto::Network::WifiPHYLayerProtocol GetWifiPHYLayerProtocol() |
| const; |
| + SystemProfileProto::Network::EffectiveConnectionType |
| + GetEffectiveConnectionType() const; |
| // Posts a call to net::GetWifiPHYLayerProtocol on the blocking pool. |
| void ProbeWifiPHYLayerProtocol(); |
| @@ -57,6 +76,10 @@ class NetworkMetricsProvider |
| // Logs metrics that are functions of other metrics being uploaded. |
| void LogAggregatedMetrics(); |
| + // Notifies |this| that the effective connection type of the current network |
| + // has changed to |type|. |
| + void OnEffectiveConnectionTypeChanged(net::EffectiveConnectionType type); |
| + |
| // Task runner used for blocking file I/O. |
| base::TaskRunner* io_task_runner_; |
| @@ -79,6 +102,24 @@ class NetworkMetricsProvider |
| base::HistogramBase::Count total_aborts_; |
| base::HistogramBase::Count total_codes_; |
| + // Listens to the changes in the effective connection type. Initialized and |
| + // destroyed using |network_quality_task_runner_|. |
| + std::unique_ptr<EffectiveConnectionTypeObserver> |
| + effective_connection_type_observer_; |
| + |
| + // Task runner using which |effective_connection_type_observer_| is |
| + // initialized and destroyed. |
| + scoped_refptr<base::SequencedTaskRunner> network_quality_task_runner_; |
| + |
| + // Last known effective connection type. |
| + net::EffectiveConnectionType effective_connection_type_; |
| + |
| + // True if |effective_connection_type_| changed during the lifetime of the |
| + // log. |
| + bool effective_connection_type_is_ambiguous_; |
| + |
| + base::ThreadChecker thread_checker_; |
| + |
| base::WeakPtrFactory<NetworkMetricsProvider> weak_ptr_factory_; |
| DISALLOW_COPY_AND_ASSIGN(NetworkMetricsProvider); |