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

Side by Side 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: Metrics service is not dependent on net 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 //------------------------------------------------------------------------------ 5 //------------------------------------------------------------------------------
6 // Description of the life cycle of a instance of MetricsService. 6 // Description of the life cycle of a instance of MetricsService.
7 // 7 //
8 // OVERVIEW 8 // OVERVIEW
9 // 9 //
10 // A MetricsService instance is typically created at application startup. It is 10 // A MetricsService instance is typically created at application startup. It is
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 local_state_->SetInt64(prefs::kInstallDate, base::Time::Now().ToTimeT()); 341 local_state_->SetInt64(prefs::kInstallDate, base::Time::Now().ToTimeT());
342 } 342 }
343 343
344 MetricsService::~MetricsService() { 344 MetricsService::~MetricsService() {
345 DisableRecording(); 345 DisableRecording();
346 } 346 }
347 347
348 void MetricsService::InitializeMetricsRecordingState() { 348 void MetricsService::InitializeMetricsRecordingState() {
349 InitializeMetricsState(); 349 InitializeMetricsState();
350 350
351 base::Closure callback = base::Bind(&MetricsService::StartScheduledUpload, 351 base::Closure upload_callback =
352 self_ptr_factory_.GetWeakPtr()); 352 base::Bind(&MetricsService::StartScheduledUpload,
353 scheduler_.reset(new MetricsReportingScheduler(callback)); 353 self_ptr_factory_.GetWeakPtr());
354 scheduler_.reset(
355 new MetricsReportingScheduler(upload_callback, is_cellular_callback_));
354 } 356 }
355 357
356 void MetricsService::Start() { 358 void MetricsService::Start() {
357 HandleIdleSinceLastTransmission(false); 359 HandleIdleSinceLastTransmission(false);
358 EnableRecording(); 360 EnableRecording();
359 EnableReporting(); 361 EnableReporting();
360 } 362 }
361 363
362 bool MetricsService::StartIfMetricsReportingEnabled() { 364 bool MetricsService::StartIfMetricsReportingEnabled() {
363 const bool enabled = state_manager_->IsMetricsReportingEnabled(); 365 const bool enabled = state_manager_->IsMetricsReportingEnabled();
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 DCHECK(IsSingleThreaded()); 1258 DCHECK(IsSingleThreaded());
1257 local_state_->SetBoolean(path, value); 1259 local_state_->SetBoolean(path, value);
1258 RecordCurrentState(local_state_); 1260 RecordCurrentState(local_state_);
1259 } 1261 }
1260 1262
1261 void MetricsService::RecordCurrentState(PrefService* pref) { 1263 void MetricsService::RecordCurrentState(PrefService* pref) {
1262 pref->SetInt64(prefs::kStabilityLastTimestampSec, 1264 pref->SetInt64(prefs::kStabilityLastTimestampSec,
1263 base::Time::Now().ToTimeT()); 1265 base::Time::Now().ToTimeT());
1264 } 1266 }
1265 1267
1268 void MetricsService::SetConnectionTypeCallback(
1269 base::Callback<void(bool*)> is_cellular_callback) {
1270 is_cellular_callback_ = is_cellular_callback;
Alexei Svitkine (slow) 2015/02/23 18:54:06 Can you add DCHECK() that InitializeMetricsRecordi
gayane -on leave until 09-2017 2015/02/23 20:14:08 Done.
1271 }
1272
1266 } // namespace metrics 1273 } // namespace metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698