| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 126 |
| 127 #include <stddef.h> | 127 #include <stddef.h> |
| 128 #include <algorithm> | 128 #include <algorithm> |
| 129 #include <utility> | 129 #include <utility> |
| 130 | 130 |
| 131 #include "base/bind.h" | 131 #include "base/bind.h" |
| 132 #include "base/callback.h" | 132 #include "base/callback.h" |
| 133 #include "base/location.h" | 133 #include "base/location.h" |
| 134 #include "base/metrics/histogram_base.h" | 134 #include "base/metrics/histogram_base.h" |
| 135 #include "base/metrics/histogram_macros.h" | 135 #include "base/metrics/histogram_macros.h" |
| 136 #include "base/metrics/histogram_persistence.h" | |
| 137 #include "base/metrics/histogram_samples.h" | 136 #include "base/metrics/histogram_samples.h" |
| 137 #include "base/metrics/persistent_histogram_allocator.h" |
| 138 #include "base/metrics/sparse_histogram.h" | 138 #include "base/metrics/sparse_histogram.h" |
| 139 #include "base/metrics/statistics_recorder.h" | 139 #include "base/metrics/statistics_recorder.h" |
| 140 #include "base/rand_util.h" | 140 #include "base/rand_util.h" |
| 141 #include "base/single_thread_task_runner.h" | 141 #include "base/single_thread_task_runner.h" |
| 142 #include "base/strings/string_number_conversions.h" | 142 #include "base/strings/string_number_conversions.h" |
| 143 #include "base/strings/utf_string_conversions.h" | 143 #include "base/strings/utf_string_conversions.h" |
| 144 #include "base/thread_task_runner_handle.h" | 144 #include "base/thread_task_runner_handle.h" |
| 145 #include "base/threading/platform_thread.h" | 145 #include "base/threading/platform_thread.h" |
| 146 #include "base/threading/thread.h" | 146 #include "base/threading/thread.h" |
| 147 #include "base/threading/thread_restrictions.h" | 147 #include "base/threading/thread_restrictions.h" |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 // can stop recording logs that are too big much sooner. | 739 // can stop recording logs that are too big much sooner. |
| 740 if (log_manager_.current_log()->num_events() > kEventLimit) { | 740 if (log_manager_.current_log()->num_events() > kEventLimit) { |
| 741 UMA_HISTOGRAM_COUNTS("UMA.Discarded Log Events", | 741 UMA_HISTOGRAM_COUNTS("UMA.Discarded Log Events", |
| 742 log_manager_.current_log()->num_events()); | 742 log_manager_.current_log()->num_events()); |
| 743 log_manager_.DiscardCurrentLog(); | 743 log_manager_.DiscardCurrentLog(); |
| 744 OpenNewLog(); // Start trivial log to hold our histograms. | 744 OpenNewLog(); // Start trivial log to hold our histograms. |
| 745 } | 745 } |
| 746 | 746 |
| 747 // If a persistent allocator is in use, update its internal histograms (such | 747 // If a persistent allocator is in use, update its internal histograms (such |
| 748 // as how much memory is being used) before reporting. | 748 // as how much memory is being used) before reporting. |
| 749 base::PersistentMemoryAllocator* allocator = | 749 base::PersistentHistogramAllocator* allocator = |
| 750 base::GetPersistentHistogramMemoryAllocator(); | 750 base::PersistentHistogramAllocator::GetGlobalAllocator(); |
| 751 if (allocator) | 751 if (allocator) |
| 752 allocator->UpdateTrackingHistograms(); | 752 allocator->UpdateTrackingHistograms(); |
| 753 | 753 |
| 754 // Put incremental data (histogram deltas, and realtime stats deltas) at the | 754 // Put incremental data (histogram deltas, and realtime stats deltas) at the |
| 755 // end of all log transmissions (initial log handles this separately). | 755 // end of all log transmissions (initial log handles this separately). |
| 756 // RecordIncrementalStabilityElements only exists on the derived | 756 // RecordIncrementalStabilityElements only exists on the derived |
| 757 // MetricsLog class. | 757 // MetricsLog class. |
| 758 MetricsLog* current_log = log_manager_.current_log(); | 758 MetricsLog* current_log = log_manager_.current_log(); |
| 759 DCHECK(current_log); | 759 DCHECK(current_log); |
| 760 RecordCurrentEnvironment(current_log); | 760 RecordCurrentEnvironment(current_log); |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1161 base::Time::Now().ToTimeT()); | 1161 base::Time::Now().ToTimeT()); |
| 1162 } | 1162 } |
| 1163 | 1163 |
| 1164 void MetricsService::SkipAndDiscardUpload() { | 1164 void MetricsService::SkipAndDiscardUpload() { |
| 1165 log_manager_.DiscardStagedLog(); | 1165 log_manager_.DiscardStagedLog(); |
| 1166 scheduler_->UploadCancelled(); | 1166 scheduler_->UploadCancelled(); |
| 1167 log_upload_in_progress_ = false; | 1167 log_upload_in_progress_ = false; |
| 1168 } | 1168 } |
| 1169 | 1169 |
| 1170 } // namespace metrics | 1170 } // namespace metrics |
| OLD | NEW |