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

Unified Diff: components/metrics/metrics_service.cc

Issue 922383003: Enable UMA log uploads for cellular networks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed old solution, fixed comments Created 5 years, 10 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
Index: components/metrics/metrics_service.cc
diff --git a/components/metrics/metrics_service.cc b/components/metrics/metrics_service.cc
index 18ec2e55bddae79355348dcc22bbf3e848231092..3ad5a0bc6b29267cf77bc5efc158b5a1c1992497 100644
--- a/components/metrics/metrics_service.cc
+++ b/components/metrics/metrics_service.cc
@@ -348,9 +348,14 @@ MetricsService::~MetricsService() {
void MetricsService::InitializeMetricsRecordingState() {
InitializeMetricsState();
- base::Closure callback = base::Bind(&MetricsService::StartScheduledUpload,
- self_ptr_factory_.GetWeakPtr());
- scheduler_.reset(new MetricsReportingScheduler(callback));
+ base::Closure upload_callback =
+ base::Bind(&MetricsService::StartScheduledUpload,
+ self_ptr_factory_.GetWeakPtr());
+ base::Callback<void(bool*)> cellular_callback =
+ base::Bind(&MetricsService::GetIsCellularConnection,
+ self_ptr_factory_.GetWeakPtr());
+ scheduler_.reset(
+ new MetricsReportingScheduler(upload_callback, cellular_callback));
}
void MetricsService::Start() {
@@ -1263,4 +1268,28 @@ void MetricsService::RecordCurrentState(PrefService* pref) {
base::Time::Now().ToTimeT());
}
+void MetricsService::SetNetworkMetricsProvider(
+ scoped_ptr<NetworkMetricsProvider> network_metrics_provider) {
+ network_metrics_provider_ = network_metrics_provider.get();
+ RegisterMetricsProvider(network_metrics_provider.Pass());
+}
+
+bool MetricsService::IsCellularConnection() {
+ SystemProfileProto::Network::ConnectionType connection_type =
+ network_metrics_provider_->GetConnectionType();
Alexei Svitkine (slow) 2015/02/19 16:29:12 Since it's optional for SetNetworkMetricsProvider(
gayane -on leave until 09-2017 2015/02/19 22:40:13 Done.
+
+ switch (connection_type) {
+ case SystemProfileProto_Network_ConnectionType_CONNECTION_2G:
+ case SystemProfileProto_Network_ConnectionType_CONNECTION_3G:
+ case SystemProfileProto_Network_ConnectionType_CONNECTION_4G:
+ return true;
+ default:
+ return false;
+ }
+}
+
+void MetricsService::GetIsCellularConnection(bool* is_cellular_out) {
+ *is_cellular_out = IsCellularConnection();
+}
+
} // namespace metrics

Powered by Google App Engine
This is Rietveld 408576698