Commit 4f763482 authored by Paul Jensen's avatar Paul Jensen Committed by Commit Bot

Convert NetworkMetricsProvider from deprecated ConnectionTypeObserver

Convert it to "new" (2012) NeworkChangeObserver.

Bug: 754695
Change-Id: Ifc63ddff076da40fd1a18d052b73f03e778cbd56
Reviewed-on: https://chromium-review.googlesource.com/1161966Reviewed-by: default avatarSteven Holte <holte@chromium.org>
Commit-Queue: Paul Jensen <pauljensen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580647}
parent d35e08b7
......@@ -126,7 +126,7 @@ NetworkMetricsProvider::NetworkMetricsProvider(
min_effective_connection_type_(net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN),
max_effective_connection_type_(net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN),
weak_ptr_factory_(this) {
net::NetworkChangeNotifier::AddConnectionTypeObserver(this);
net::NetworkChangeNotifier::AddNetworkChangeObserver(this);
connection_type_ = net::NetworkChangeNotifier::GetConnectionType();
if (connection_type_ != net::NetworkChangeNotifier::CONNECTION_UNKNOWN)
network_change_notifier_initialized_ = true;
......@@ -157,7 +157,7 @@ NetworkMetricsProvider::NetworkMetricsProvider(
NetworkMetricsProvider::~NetworkMetricsProvider() {
DCHECK(thread_checker_.CalledOnValidThread());
net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this);
net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
if (network_quality_estimator_provider_) {
scoped_refptr<base::SequencedTaskRunner> network_quality_task_runner =
......@@ -232,7 +232,7 @@ void NetworkMetricsProvider::ProvideSystemProfileMetrics(
WriteWifiAccessPointProto(info, network);
}
void NetworkMetricsProvider::OnConnectionTypeChanged(
void NetworkMetricsProvider::OnNetworkChanged(
net::NetworkChangeNotifier::ConnectionType type) {
DCHECK(thread_checker_.CalledOnValidThread());
// To avoid reporting an ambiguous connection type for users on flaky
......
......@@ -33,7 +33,7 @@ ConvertEffectiveConnectionType(
// the network environment.
class NetworkMetricsProvider
: public MetricsProvider,
public net::NetworkChangeNotifier::ConnectionTypeObserver {
public net::NetworkChangeNotifier::NetworkChangeObserver {
public:
// Class that provides |this| with the network quality estimator.
class NetworkQualityEstimatorProvider {
......@@ -82,8 +82,8 @@ class NetworkMetricsProvider
ChromeUserMetricsExtension* uma_proto) override;
void ProvideSystemProfileMetrics(SystemProfileProto* system_profile) override;
// ConnectionTypeObserver:
void OnConnectionTypeChanged(
// NetworkChangeObserver:
void OnNetworkChanged(
net::NetworkChangeNotifier::ConnectionType type) override;
SystemProfileProto::Network::ConnectionType GetConnectionType() const;
......
......@@ -182,7 +182,7 @@ TEST_F(NetworkMetricsProviderTest, ECTAmbiguousOnConnectionTypeChange) {
// Even with change in the connection type, effective connection types
// should be reported as 2G.
network_metrics_provider.OnConnectionTypeChanged(
network_metrics_provider.OnNetworkChanged(
net::NetworkChangeNotifier::CONNECTION_2G);
network_metrics_provider.ProvideSystemProfileMetrics(&system_profile);
EXPECT_EQ(SystemProfileProto::Network::EFFECTIVE_CONNECTION_TYPE_2G,
......@@ -252,7 +252,7 @@ TEST_F(NetworkMetricsProviderTest, ConnectionTypeIsAmbiguous) {
// When a connection type change callback is received, network change notifier
// should be marked as initialized.
network_metrics_provider.OnConnectionTypeChanged(
network_metrics_provider.OnNetworkChanged(
net::NetworkChangeNotifier::CONNECTION_2G);
EXPECT_EQ(net::NetworkChangeNotifier::CONNECTION_2G,
network_metrics_provider.connection_type_);
......@@ -271,7 +271,7 @@ TEST_F(NetworkMetricsProviderTest, ConnectionTypeIsAmbiguous) {
EXPECT_EQ(SystemProfileProto::Network::CONNECTION_2G,
system_profile.network().connection_type());
network_metrics_provider.OnConnectionTypeChanged(
network_metrics_provider.OnNetworkChanged(
net::NetworkChangeNotifier::CONNECTION_3G);
EXPECT_TRUE(network_metrics_provider.connection_type_is_ambiguous_);
EXPECT_TRUE(network_metrics_provider.network_change_notifier_initialized_);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment