| 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 #include "chrome/browser/chromeos/external_metrics.h" | 5 #include "chrome/browser/chromeos/external_metrics.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/metrics/sparse_histogram.h" | 12 #include "base/metrics/sparse_histogram.h" |
| 13 #include "base/metrics/statistics_recorder.h" | 13 #include "base/metrics/statistics_recorder.h" |
| 14 #include "base/timer/elapsed_timer.h" | |
| 15 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/metrics/chromeos_metrics_provider.h" | 15 #include "chrome/browser/metrics/chromeos_metrics_provider.h" |
| 17 #include "components/metrics/metrics_service.h" | 16 #include "components/metrics/metrics_service.h" |
| 18 #include "components/metrics/serialization/metric_sample.h" | 17 #include "components/metrics/serialization/metric_sample.h" |
| 19 #include "components/metrics/serialization/serialization_utils.h" | 18 #include "components/metrics/serialization/serialization_utils.h" |
| 20 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 21 #include "content/public/browser/user_metrics.h" | 20 #include "content/public/browser/user_metrics.h" |
| 22 | 21 |
| 23 using base::UserMetricsAction; | 22 using base::UserMetricsAction; |
| 24 using content::BrowserThread; | 23 using content::BrowserThread; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 case metrics::MetricSample::SPARSE_HISTOGRAM: | 157 case metrics::MetricSample::SPARSE_HISTOGRAM: |
| 159 RecordSparseHistogram(sample); | 158 RecordSparseHistogram(sample); |
| 160 break; | 159 break; |
| 161 } | 160 } |
| 162 } | 161 } |
| 163 | 162 |
| 164 return samples.size(); | 163 return samples.size(); |
| 165 } | 164 } |
| 166 | 165 |
| 167 void ExternalMetrics::CollectEventsAndReschedule() { | 166 void ExternalMetrics::CollectEventsAndReschedule() { |
| 168 base::ElapsedTimer timer; | |
| 169 CollectEvents(); | 167 CollectEvents(); |
| 170 UMA_HISTOGRAM_TIMES("UMA.CollectExternalEventsTime", timer.Elapsed()); | |
| 171 ScheduleCollector(); | 168 ScheduleCollector(); |
| 172 } | 169 } |
| 173 | 170 |
| 174 void ExternalMetrics::ScheduleCollector() { | 171 void ExternalMetrics::ScheduleCollector() { |
| 175 bool result = BrowserThread::GetBlockingPool()->PostDelayedWorkerTask( | 172 bool result = BrowserThread::GetBlockingPool()->PostDelayedWorkerTask( |
| 176 FROM_HERE, | 173 FROM_HERE, |
| 177 base::Bind(&chromeos::ExternalMetrics::CollectEventsAndReschedule, this), | 174 base::Bind(&chromeos::ExternalMetrics::CollectEventsAndReschedule, this), |
| 178 base::TimeDelta::FromSeconds(kExternalMetricsCollectionIntervalSeconds)); | 175 base::TimeDelta::FromSeconds(kExternalMetricsCollectionIntervalSeconds)); |
| 179 DCHECK(result); | 176 DCHECK(result); |
| 180 } | 177 } |
| 181 | 178 |
| 182 } // namespace chromeos | 179 } // namespace chromeos |
| OLD | NEW |