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

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

Issue 2691803002: Remove ScopedVector in //component/metrics (Closed)
Patch Set: Remove ScopedVector in //component/metrics 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
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 <string> 10 #include <string>
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 125
126 void ExternalMetrics::RecordSparseHistogram( 126 void ExternalMetrics::RecordSparseHistogram(
127 const metrics::MetricSample& sample) { 127 const metrics::MetricSample& sample) {
128 CHECK_EQ(metrics::MetricSample::SPARSE_HISTOGRAM, sample.type()); 128 CHECK_EQ(metrics::MetricSample::SPARSE_HISTOGRAM, sample.type());
129 base::HistogramBase* counter = base::SparseHistogram::FactoryGet( 129 base::HistogramBase* counter = base::SparseHistogram::FactoryGet(
130 sample.name(), base::HistogramBase::kUmaTargetedHistogramFlag); 130 sample.name(), base::HistogramBase::kUmaTargetedHistogramFlag);
131 counter->Add(sample.sample()); 131 counter->Add(sample.sample());
132 } 132 }
133 133
134 int ExternalMetrics::CollectEvents() { 134 int ExternalMetrics::CollectEvents() {
135 ScopedVector<metrics::MetricSample> samples; 135 std::vector<std::unique_ptr<metrics::MetricSample>> samples;
Ilya Sherman 2017/02/13 19:21:30 Please #include <vector> and <memory> at the top o
ke.he 2017/02/14 04:24:14 Done.
136 metrics::SerializationUtils::ReadAndTruncateMetricsFromFile(uma_events_file_, 136 metrics::SerializationUtils::ReadAndTruncateMetricsFromFile(uma_events_file_,
137 &samples); 137 &samples);
138 138
139 for (ScopedVector<metrics::MetricSample>::iterator it = samples.begin(); 139 for (auto it = samples.begin(); it != samples.end(); ++it) {
140 it != samples.end();
141 ++it) {
142 const metrics::MetricSample& sample = **it; 140 const metrics::MetricSample& sample = **it;
143 141
144 // Do not use the UMA_HISTOGRAM_... macros here. They cache the Histogram 142 // Do not use the UMA_HISTOGRAM_... macros here. They cache the Histogram
145 // instance and thus only work if |sample.name()| is constant. 143 // instance and thus only work if |sample.name()| is constant.
146 switch (sample.type()) { 144 switch (sample.type()) {
147 case metrics::MetricSample::CRASH: 145 case metrics::MetricSample::CRASH:
148 RecordCrash(sample.name()); 146 RecordCrash(sample.name());
149 break; 147 break;
150 case metrics::MetricSample::USER_ACTION: 148 case metrics::MetricSample::USER_ACTION:
151 RecordAction(sample.name()); 149 RecordAction(sample.name());
(...skipping 20 matching lines...) Expand all
172 170
173 void ExternalMetrics::ScheduleCollector() { 171 void ExternalMetrics::ScheduleCollector() {
174 bool result = BrowserThread::GetBlockingPool()->PostDelayedWorkerTask( 172 bool result = BrowserThread::GetBlockingPool()->PostDelayedWorkerTask(
175 FROM_HERE, 173 FROM_HERE,
176 base::Bind(&chromeos::ExternalMetrics::CollectEventsAndReschedule, this), 174 base::Bind(&chromeos::ExternalMetrics::CollectEventsAndReschedule, this),
177 base::TimeDelta::FromSeconds(kExternalMetricsCollectionIntervalSeconds)); 175 base::TimeDelta::FromSeconds(kExternalMetricsCollectionIntervalSeconds));
178 DCHECK(result); 176 DCHECK(result);
179 } 177 }
180 178
181 } // namespace chromeos 179 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chromecast/browser/metrics/external_metrics.cc » ('j') | components/metrics/metrics_log.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698