OLD | NEW |
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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 callback = base::Bind(&MetricsService::StartScheduledUpload, |
352 self_ptr_factory_.GetWeakPtr()); | 352 self_ptr_factory_.GetWeakPtr()); |
353 scheduler_.reset(new MetricsReportingScheduler(callback)); | 353 scheduler_.reset(new MetricsReportingScheduler(callback)); |
| 354 scheduler_->SetNetworkMetricsProvider(network_metrics_provider_); |
354 } | 355 } |
355 | 356 |
356 void MetricsService::Start() { | 357 void MetricsService::Start() { |
357 HandleIdleSinceLastTransmission(false); | 358 HandleIdleSinceLastTransmission(false); |
358 EnableRecording(); | 359 EnableRecording(); |
359 EnableReporting(); | 360 EnableReporting(); |
360 } | 361 } |
361 | 362 |
362 bool MetricsService::StartIfMetricsReportingEnabled() { | 363 bool MetricsService::StartIfMetricsReportingEnabled() { |
363 const bool enabled = state_manager_->IsMetricsReportingEnabled(); | 364 const bool enabled = state_manager_->IsMetricsReportingEnabled(); |
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1256 DCHECK(IsSingleThreaded()); | 1257 DCHECK(IsSingleThreaded()); |
1257 local_state_->SetBoolean(path, value); | 1258 local_state_->SetBoolean(path, value); |
1258 RecordCurrentState(local_state_); | 1259 RecordCurrentState(local_state_); |
1259 } | 1260 } |
1260 | 1261 |
1261 void MetricsService::RecordCurrentState(PrefService* pref) { | 1262 void MetricsService::RecordCurrentState(PrefService* pref) { |
1262 pref->SetInt64(prefs::kStabilityLastTimestampSec, | 1263 pref->SetInt64(prefs::kStabilityLastTimestampSec, |
1263 base::Time::Now().ToTimeT()); | 1264 base::Time::Now().ToTimeT()); |
1264 } | 1265 } |
1265 | 1266 |
| 1267 void MetricsService::SetNetworkMetricsProvider() { |
| 1268 network_metrics_provider_ = |
| 1269 (metrics::NetworkMetricsProvider*)metrics_providers_.get().back(); |
| 1270 } |
| 1271 |
1266 } // namespace metrics | 1272 } // namespace metrics |
OLD | NEW |