Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Unified Diff: components/metrics/net/network_metrics_provider.h

Issue 2605553002: Add EffectiveConnectionType enum to the system profile proto (Closed)
Patch Set: Add tests Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..c147b2d834212f9c7c2e2b9fb264e36eef6e0e14 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 lives on |task_runner|.
RyanSturm 2016/12/28 21:53:11 nit: s/lives on/can be accessed via/ or "which liv
tbansal1 2017/01/03 17:25:13 Done.
+ void ProvideNetworkQualityEstimator(
+ net::NetworkQualityEstimator* network_quality_estimator,
+ 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 on |network_quality_task_runner_|.
RyanSturm 2016/12/28 21:53:11 same nit here. I'm not sure that taskrunner should
tbansal1 2017/01/03 17:25:13 Done.
+ std::unique_ptr<EffectiveConnectionTypeObserver>
+ effective_connection_type_observer_;
+
+ // Task runner on which |effective_connection_type_observer_| is initialized
RyanSturm 2016/12/28 21:53:11 same nit: s/Task runner/Corresponds to the thread/
tbansal1 2017/01/03 17:25:13 Done.
+ // 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);

Powered by Google App Engine
This is Rietveld 408576698