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

Side by Side Diff: chrome/browser/chromeos/external_metrics.cc

Issue 2691803002: Remove ScopedVector in //component/metrics (Closed)
Patch Set: code rebase Created 3 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
« no previous file with comments | « no previous file | chromecast/browser/metrics/external_metrics.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <memory>
10 #include <string> 11 #include <string>
12 #include <vector>
11 13
12 #include "base/bind.h" 14 #include "base/bind.h"
13 #include "base/metrics/histogram_macros.h" 15 #include "base/metrics/histogram_macros.h"
14 #include "base/metrics/sparse_histogram.h" 16 #include "base/metrics/sparse_histogram.h"
15 #include "base/metrics/statistics_recorder.h" 17 #include "base/metrics/statistics_recorder.h"
16 #include "base/threading/sequenced_worker_pool.h" 18 #include "base/threading/sequenced_worker_pool.h"
17 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/metrics/chromeos_metrics_provider.h" 20 #include "chrome/browser/metrics/chromeos_metrics_provider.h"
19 #include "components/metrics/metrics_service.h" 21 #include "components/metrics/metrics_service.h"
20 #include "components/metrics/serialization/metric_sample.h" 22 #include "components/metrics/serialization/metric_sample.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 128
127 void ExternalMetrics::RecordSparseHistogram( 129 void ExternalMetrics::RecordSparseHistogram(
128 const metrics::MetricSample& sample) { 130 const metrics::MetricSample& sample) {
129 CHECK_EQ(metrics::MetricSample::SPARSE_HISTOGRAM, sample.type()); 131 CHECK_EQ(metrics::MetricSample::SPARSE_HISTOGRAM, sample.type());
130 base::HistogramBase* counter = base::SparseHistogram::FactoryGet( 132 base::HistogramBase* counter = base::SparseHistogram::FactoryGet(
131 sample.name(), base::HistogramBase::kUmaTargetedHistogramFlag); 133 sample.name(), base::HistogramBase::kUmaTargetedHistogramFlag);
132 counter->Add(sample.sample()); 134 counter->Add(sample.sample());
133 } 135 }
134 136
135 int ExternalMetrics::CollectEvents() { 137 int ExternalMetrics::CollectEvents() {
136 ScopedVector<metrics::MetricSample> samples; 138 std::vector<std::unique_ptr<metrics::MetricSample>> samples;
137 metrics::SerializationUtils::ReadAndTruncateMetricsFromFile(uma_events_file_, 139 metrics::SerializationUtils::ReadAndTruncateMetricsFromFile(uma_events_file_,
138 &samples); 140 &samples);
139 141
140 for (ScopedVector<metrics::MetricSample>::iterator it = samples.begin(); 142 for (auto it = samples.begin(); it != samples.end(); ++it) {
141 it != samples.end();
142 ++it) {
143 const metrics::MetricSample& sample = **it; 143 const metrics::MetricSample& sample = **it;
144 144
145 // Do not use the UMA_HISTOGRAM_... macros here. They cache the Histogram 145 // Do not use the UMA_HISTOGRAM_... macros here. They cache the Histogram
146 // instance and thus only work if |sample.name()| is constant. 146 // instance and thus only work if |sample.name()| is constant.
147 switch (sample.type()) { 147 switch (sample.type()) {
148 case metrics::MetricSample::CRASH: 148 case metrics::MetricSample::CRASH:
149 RecordCrash(sample.name()); 149 RecordCrash(sample.name());
150 break; 150 break;
151 case metrics::MetricSample::USER_ACTION: 151 case metrics::MetricSample::USER_ACTION:
152 RecordAction(sample.name()); 152 RecordAction(sample.name());
(...skipping 20 matching lines...) Expand all
173 173
174 void ExternalMetrics::ScheduleCollector() { 174 void ExternalMetrics::ScheduleCollector() {
175 bool result = BrowserThread::GetBlockingPool()->PostDelayedWorkerTask( 175 bool result = BrowserThread::GetBlockingPool()->PostDelayedWorkerTask(
176 FROM_HERE, 176 FROM_HERE,
177 base::Bind(&chromeos::ExternalMetrics::CollectEventsAndReschedule, this), 177 base::Bind(&chromeos::ExternalMetrics::CollectEventsAndReschedule, this),
178 base::TimeDelta::FromSeconds(kExternalMetricsCollectionIntervalSeconds)); 178 base::TimeDelta::FromSeconds(kExternalMetricsCollectionIntervalSeconds));
179 DCHECK(result); 179 DCHECK(result);
180 } 180 }
181 181
182 } // namespace chromeos 182 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chromecast/browser/metrics/external_metrics.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698