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

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

Issue 2605553002: Add EffectiveConnectionType enum to the system profile proto (Closed)
Patch Set: Rebased Created 3 years, 11 months 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
« no previous file with comments | « components/metrics/net/DEPS ('k') | components/metrics/net/network_metrics_provider.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..2eccee0460c78b7026430abdfac08a9070b2a309 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 {
@@ -24,12 +30,44 @@ class NetworkMetricsProvider
: public MetricsProvider,
public net::NetworkChangeNotifier::ConnectionTypeObserver {
public:
+ // Class that provides |this| with the network quality estimator.
+ class NetworkQualityEstimatorProvider {
+ public:
+ virtual ~NetworkQualityEstimatorProvider() {}
+
+ // Returns the network quality estimator. May be nullptr.
+ virtual net::NetworkQualityEstimator* GetNetworkQualityEstimator() = 0;
+
+ // Returns the task runner on which |this| should be used and destroyed.
+ virtual scoped_refptr<base::SequencedTaskRunner> GetTaskRunner() = 0;
+
+ protected:
+ NetworkQualityEstimatorProvider() {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimatorProvider);
+ };
+
// Creates a NetworkMetricsProvider, where |io_task_runner| is used to post
// network info collection tasks.
explicit NetworkMetricsProvider(base::TaskRunner* io_task_runner);
+
+ // Creates a NetworkMetricsProvider, where |io_task_runner| is used to post
+ // network info collection tasks. |network_quality_estimator_provider|
+ // should be set if it is useful to attach the quality of the network to the
+ // metrics report.
+ NetworkMetricsProvider(std::unique_ptr<NetworkQualityEstimatorProvider>
+ network_quality_estimator_provider,
+ base::TaskRunner* io_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 +79,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 +97,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 +123,28 @@ class NetworkMetricsProvider
base::HistogramBase::Count total_aborts_;
base::HistogramBase::Count total_codes_;
+ // Provides the network quality estimator. May be null.
+ std::unique_ptr<NetworkQualityEstimatorProvider>
+ network_quality_estimator_provider_;
+
+ // Listens to the changes in the effective connection type. Initialized and
+ // destroyed using |network_quality_task_runner_|. May be null.
+ std::unique_ptr<EffectiveConnectionTypeObserver>
+ effective_connection_type_observer_;
+
+ // Task runner using which |effective_connection_type_observer_| is
+ // initialized and destroyed. May be null.
+ 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);
« no previous file with comments | « components/metrics/net/DEPS ('k') | components/metrics/net/network_metrics_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698