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

Side by Side Diff: components/metrics/metrics_log.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 | « components/metrics/metrics_log.h ('k') | components/metrics/metrics_log_unittest.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 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 #include "components/metrics/metrics_log.h" 5 #include "components/metrics/metrics_log.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory>
11 #include <string> 10 #include <string>
12 #include <vector>
13 11
14 #include "base/base64.h" 12 #include "base/base64.h"
15 #include "base/build_time.h" 13 #include "base/build_time.h"
16 #include "base/cpu.h" 14 #include "base/cpu.h"
17 #include "base/metrics/histogram_macros.h" 15 #include "base/metrics/histogram_macros.h"
18 #include "base/metrics/histogram_samples.h" 16 #include "base/metrics/histogram_samples.h"
19 #include "base/metrics/metrics_hashes.h" 17 #include "base/metrics/metrics_hashes.h"
20 #include "base/sha1.h" 18 #include "base/sha1.h"
21 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
22 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 #endif 196 #endif
199 } 197 }
200 198
201 void MetricsLog::RecordHistogramDelta(const std::string& histogram_name, 199 void MetricsLog::RecordHistogramDelta(const std::string& histogram_name,
202 const base::HistogramSamples& snapshot) { 200 const base::HistogramSamples& snapshot) {
203 DCHECK(!closed_); 201 DCHECK(!closed_);
204 EncodeHistogramDelta(histogram_name, snapshot, &uma_proto_); 202 EncodeHistogramDelta(histogram_name, snapshot, &uma_proto_);
205 } 203 }
206 204
207 void MetricsLog::RecordStabilityMetrics( 205 void MetricsLog::RecordStabilityMetrics(
208 const std::vector<MetricsProvider*>& metrics_providers, 206 const std::vector<std::unique_ptr<MetricsProvider>>& metrics_providers,
209 base::TimeDelta incremental_uptime, 207 base::TimeDelta incremental_uptime,
210 base::TimeDelta uptime) { 208 base::TimeDelta uptime) {
211 DCHECK(!closed_); 209 DCHECK(!closed_);
212 DCHECK(HasEnvironment()); 210 DCHECK(HasEnvironment());
213 DCHECK(!HasStabilityMetrics()); 211 DCHECK(!HasStabilityMetrics());
214 212
215 PrefService* pref = local_state_; 213 PrefService* pref = local_state_;
216 DCHECK(pref); 214 DCHECK(pref);
217 215
218 // Get stability attributes out of Local State, zeroing out stored values. 216 // Get stability attributes out of Local State, zeroing out stored values.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 local_state_->GetInteger(prefs::kStabilityVersionMismatchCount); 292 local_state_->GetInteger(prefs::kStabilityVersionMismatchCount);
295 if (version_mismatch_count) { 293 if (version_mismatch_count) {
296 local_state_->SetInteger(prefs::kStabilityVersionMismatchCount, 0); 294 local_state_->SetInteger(prefs::kStabilityVersionMismatchCount, 0);
297 UMA_STABILITY_HISTOGRAM_COUNTS_100( 295 UMA_STABILITY_HISTOGRAM_COUNTS_100(
298 "Stability.Internals.VersionMismatchCount", 296 "Stability.Internals.VersionMismatchCount",
299 version_mismatch_count); 297 version_mismatch_count);
300 } 298 }
301 } 299 }
302 300
303 void MetricsLog::RecordGeneralMetrics( 301 void MetricsLog::RecordGeneralMetrics(
304 const std::vector<MetricsProvider*>& metrics_providers) { 302 const std::vector<std::unique_ptr<MetricsProvider>>& metrics_providers) {
305 if (local_state_->GetBoolean(prefs::kMetricsResetIds)) 303 if (local_state_->GetBoolean(prefs::kMetricsResetIds))
306 UMA_HISTOGRAM_BOOLEAN("UMA.IsClonedInstall", true); 304 UMA_HISTOGRAM_BOOLEAN("UMA.IsClonedInstall", true);
307 305
308 for (size_t i = 0; i < metrics_providers.size(); ++i) 306 for (size_t i = 0; i < metrics_providers.size(); ++i)
309 metrics_providers[i]->ProvideGeneralMetrics(uma_proto()); 307 metrics_providers[i]->ProvideGeneralMetrics(uma_proto());
310 } 308 }
311 309
312 void MetricsLog::GetFieldTrialIds( 310 void MetricsLog::GetFieldTrialIds(
313 std::vector<ActiveGroupId>* field_trial_ids) const { 311 std::vector<ActiveGroupId>* field_trial_ids) const {
314 variations::GetFieldTrialActiveGroupIds(field_trial_ids); 312 variations::GetFieldTrialActiveGroupIds(field_trial_ids);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 375
378 const uint64_t incremental_uptime_sec = incremental_uptime.InSeconds(); 376 const uint64_t incremental_uptime_sec = incremental_uptime.InSeconds();
379 if (incremental_uptime_sec) 377 if (incremental_uptime_sec)
380 stability->set_incremental_uptime_sec(incremental_uptime_sec); 378 stability->set_incremental_uptime_sec(incremental_uptime_sec);
381 const uint64_t uptime_sec = uptime.InSeconds(); 379 const uint64_t uptime_sec = uptime.InSeconds();
382 if (uptime_sec) 380 if (uptime_sec)
383 stability->set_uptime_sec(uptime_sec); 381 stability->set_uptime_sec(uptime_sec);
384 } 382 }
385 383
386 std::string MetricsLog::RecordEnvironment( 384 std::string MetricsLog::RecordEnvironment(
387 const std::vector<MetricsProvider*>& metrics_providers, 385 const std::vector<std::unique_ptr<MetricsProvider>>& metrics_providers,
388 const std::vector<variations::ActiveGroupId>& synthetic_trials, 386 const std::vector<variations::ActiveGroupId>& synthetic_trials,
389 int64_t install_date, 387 int64_t install_date,
390 int64_t metrics_reporting_enabled_date) { 388 int64_t metrics_reporting_enabled_date) {
391 DCHECK(!HasEnvironment()); 389 DCHECK(!HasEnvironment());
392 390
393 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile(); 391 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile();
394 392
395 WriteMetricsEnableDefault(client_->GetMetricsReportingDefaultState(), 393 WriteMetricsEnableDefault(client_->GetMetricsReportingDefaultState(),
396 system_profile); 394 system_profile);
397 395
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 DCHECK(!closed_); 463 DCHECK(!closed_);
466 closed_ = true; 464 closed_ = true;
467 } 465 }
468 466
469 void MetricsLog::GetEncodedLog(std::string* encoded_log) { 467 void MetricsLog::GetEncodedLog(std::string* encoded_log) {
470 DCHECK(closed_); 468 DCHECK(closed_);
471 uma_proto_.SerializeToString(encoded_log); 469 uma_proto_.SerializeToString(encoded_log);
472 } 470 }
473 471
474 } // namespace metrics 472 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/metrics_log.h ('k') | components/metrics/metrics_log_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698