| 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 #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> | 10 #include <memory> |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 #endif | 198 #endif |
| 199 } | 199 } |
| 200 | 200 |
| 201 void MetricsLog::RecordHistogramDelta(const std::string& histogram_name, | 201 void MetricsLog::RecordHistogramDelta(const std::string& histogram_name, |
| 202 const base::HistogramSamples& snapshot) { | 202 const base::HistogramSamples& snapshot) { |
| 203 DCHECK(!closed_); | 203 DCHECK(!closed_); |
| 204 EncodeHistogramDelta(histogram_name, snapshot, &uma_proto_); | 204 EncodeHistogramDelta(histogram_name, snapshot, &uma_proto_); |
| 205 } | 205 } |
| 206 | 206 |
| 207 void MetricsLog::RecordStabilityMetrics( | 207 void MetricsLog::RecordStabilityMetrics( |
| 208 const std::vector<MetricsProvider*>& metrics_providers, | 208 const std::vector<std::unique_ptr<MetricsProvider>>& metrics_providers, |
| 209 base::TimeDelta incremental_uptime, | 209 base::TimeDelta incremental_uptime, |
| 210 base::TimeDelta uptime) { | 210 base::TimeDelta uptime) { |
| 211 DCHECK(!closed_); | 211 DCHECK(!closed_); |
| 212 DCHECK(HasEnvironment()); | 212 DCHECK(HasEnvironment()); |
| 213 DCHECK(!HasStabilityMetrics()); | 213 DCHECK(!HasStabilityMetrics()); |
| 214 | 214 |
| 215 PrefService* pref = local_state_; | 215 PrefService* pref = local_state_; |
| 216 DCHECK(pref); | 216 DCHECK(pref); |
| 217 | 217 |
| 218 // Get stability attributes out of Local State, zeroing out stored values. | 218 // Get stability attributes out of Local State, zeroing out stored values. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 local_state_->GetInteger(prefs::kStabilityVersionMismatchCount); | 294 local_state_->GetInteger(prefs::kStabilityVersionMismatchCount); |
| 295 if (version_mismatch_count) { | 295 if (version_mismatch_count) { |
| 296 local_state_->SetInteger(prefs::kStabilityVersionMismatchCount, 0); | 296 local_state_->SetInteger(prefs::kStabilityVersionMismatchCount, 0); |
| 297 UMA_STABILITY_HISTOGRAM_COUNTS_100( | 297 UMA_STABILITY_HISTOGRAM_COUNTS_100( |
| 298 "Stability.Internals.VersionMismatchCount", | 298 "Stability.Internals.VersionMismatchCount", |
| 299 version_mismatch_count); | 299 version_mismatch_count); |
| 300 } | 300 } |
| 301 } | 301 } |
| 302 | 302 |
| 303 void MetricsLog::RecordGeneralMetrics( | 303 void MetricsLog::RecordGeneralMetrics( |
| 304 const std::vector<MetricsProvider*>& metrics_providers) { | 304 const std::vector<std::unique_ptr<MetricsProvider>>& metrics_providers) { |
| 305 if (local_state_->GetBoolean(prefs::kMetricsResetIds)) | 305 if (local_state_->GetBoolean(prefs::kMetricsResetIds)) |
| 306 UMA_HISTOGRAM_BOOLEAN("UMA.IsClonedInstall", true); | 306 UMA_HISTOGRAM_BOOLEAN("UMA.IsClonedInstall", true); |
| 307 | 307 |
| 308 for (size_t i = 0; i < metrics_providers.size(); ++i) | 308 for (size_t i = 0; i < metrics_providers.size(); ++i) |
| 309 metrics_providers[i]->ProvideGeneralMetrics(uma_proto()); | 309 metrics_providers[i]->ProvideGeneralMetrics(uma_proto()); |
| 310 } | 310 } |
| 311 | 311 |
| 312 void MetricsLog::GetFieldTrialIds( | 312 void MetricsLog::GetFieldTrialIds( |
| 313 std::vector<ActiveGroupId>* field_trial_ids) const { | 313 std::vector<ActiveGroupId>* field_trial_ids) const { |
| 314 variations::GetFieldTrialActiveGroupIds(field_trial_ids); | 314 variations::GetFieldTrialActiveGroupIds(field_trial_ids); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 | 377 |
| 378 const uint64_t incremental_uptime_sec = incremental_uptime.InSeconds(); | 378 const uint64_t incremental_uptime_sec = incremental_uptime.InSeconds(); |
| 379 if (incremental_uptime_sec) | 379 if (incremental_uptime_sec) |
| 380 stability->set_incremental_uptime_sec(incremental_uptime_sec); | 380 stability->set_incremental_uptime_sec(incremental_uptime_sec); |
| 381 const uint64_t uptime_sec = uptime.InSeconds(); | 381 const uint64_t uptime_sec = uptime.InSeconds(); |
| 382 if (uptime_sec) | 382 if (uptime_sec) |
| 383 stability->set_uptime_sec(uptime_sec); | 383 stability->set_uptime_sec(uptime_sec); |
| 384 } | 384 } |
| 385 | 385 |
| 386 std::string MetricsLog::RecordEnvironment( | 386 std::string MetricsLog::RecordEnvironment( |
| 387 const std::vector<MetricsProvider*>& metrics_providers, | 387 const std::vector<std::unique_ptr<MetricsProvider>>& metrics_providers, |
| 388 const std::vector<variations::ActiveGroupId>& synthetic_trials, | 388 const std::vector<variations::ActiveGroupId>& synthetic_trials, |
| 389 int64_t install_date, | 389 int64_t install_date, |
| 390 int64_t metrics_reporting_enabled_date) { | 390 int64_t metrics_reporting_enabled_date) { |
| 391 DCHECK(!HasEnvironment()); | 391 DCHECK(!HasEnvironment()); |
| 392 | 392 |
| 393 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile(); | 393 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile(); |
| 394 | 394 |
| 395 WriteMetricsEnableDefault(client_->GetMetricsReportingDefaultState(), | 395 WriteMetricsEnableDefault(client_->GetMetricsReportingDefaultState(), |
| 396 system_profile); | 396 system_profile); |
| 397 | 397 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 DCHECK(!closed_); | 465 DCHECK(!closed_); |
| 466 closed_ = true; | 466 closed_ = true; |
| 467 } | 467 } |
| 468 | 468 |
| 469 void MetricsLog::GetEncodedLog(std::string* encoded_log) { | 469 void MetricsLog::GetEncodedLog(std::string* encoded_log) { |
| 470 DCHECK(closed_); | 470 DCHECK(closed_); |
| 471 uma_proto_.SerializeToString(encoded_log); | 471 uma_proto_.SerializeToString(encoded_log); |
| 472 } | 472 } |
| 473 | 473 |
| 474 } // namespace metrics | 474 } // namespace metrics |
| OLD | NEW |