OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 10 // A MetricsService instance is typically created at application startup. It |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 DCHECK(IsSingleThreaded()); | 395 DCHECK(IsSingleThreaded()); |
396 InitializeMetricsState(); | 396 InitializeMetricsState(); |
397 | 397 |
398 base::Closure callback = base::Bind(&MetricsService::StartScheduledUpload, | 398 base::Closure callback = base::Bind(&MetricsService::StartScheduledUpload, |
399 self_ptr_factory_.GetWeakPtr()); | 399 self_ptr_factory_.GetWeakPtr()); |
400 scheduler_.reset(new MetricsReportingScheduler(callback)); | 400 scheduler_.reset(new MetricsReportingScheduler(callback)); |
401 log_manager_.set_log_serializer(new MetricsLogSerializer()); | 401 log_manager_.set_log_serializer(new MetricsLogSerializer()); |
402 log_manager_.set_max_ongoing_log_store_size(kUploadLogAvoidRetransmitSize); | 402 log_manager_.set_max_ongoing_log_store_size(kUploadLogAvoidRetransmitSize); |
403 } | 403 } |
404 | 404 |
| 405 // Constrcutor for tests. Will not initialize the object for realz. |
| 406 MetricsService::MetricsService(bool active) |
| 407 : recording_active_(active), |
| 408 reporting_active_(active), |
| 409 state_(INITIALIZED), |
| 410 io_thread_(NULL), |
| 411 idle_since_last_transmission_(false), |
| 412 next_window_id_(0), |
| 413 ALLOW_THIS_IN_INITIALIZER_LIST(self_ptr_factory_(this)), |
| 414 ALLOW_THIS_IN_INITIALIZER_LIST(state_saver_factory_(this)), |
| 415 waiting_for_asynchronus_reporting_step_(false) { |
| 416 DCHECK(IsSingleThreaded()); |
| 417 } |
| 418 |
405 MetricsService::~MetricsService() { | 419 MetricsService::~MetricsService() { |
406 SetRecording(false); | 420 SetRecording(false); |
407 } | 421 } |
408 | 422 |
409 void MetricsService::Start() { | 423 void MetricsService::Start() { |
410 HandleIdleSinceLastTransmission(false); | 424 HandleIdleSinceLastTransmission(false); |
411 SetRecording(true); | 425 SetRecording(true); |
412 SetReporting(true); | 426 SetReporting(true); |
413 } | 427 } |
414 | 428 |
(...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1666 if (local_state) { | 1680 if (local_state) { |
1667 const PrefService::Preference* uma_pref = | 1681 const PrefService::Preference* uma_pref = |
1668 local_state->FindPreference(prefs::kMetricsReportingEnabled); | 1682 local_state->FindPreference(prefs::kMetricsReportingEnabled); |
1669 if (uma_pref) { | 1683 if (uma_pref) { |
1670 bool success = uma_pref->GetValue()->GetAsBoolean(&result); | 1684 bool success = uma_pref->GetValue()->GetAsBoolean(&result); |
1671 DCHECK(success); | 1685 DCHECK(success); |
1672 } | 1686 } |
1673 } | 1687 } |
1674 return result; | 1688 return result; |
1675 } | 1689 } |
OLD | NEW |