| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 const uint64 incremental_uptime_sec = incremental_uptime.InSeconds(); | 323 const uint64 incremental_uptime_sec = incremental_uptime.InSeconds(); |
| 324 if (incremental_uptime_sec) | 324 if (incremental_uptime_sec) |
| 325 stability->set_incremental_uptime_sec(incremental_uptime_sec); | 325 stability->set_incremental_uptime_sec(incremental_uptime_sec); |
| 326 const uint64 uptime_sec = uptime.InSeconds(); | 326 const uint64 uptime_sec = uptime.InSeconds(); |
| 327 if (uptime_sec) | 327 if (uptime_sec) |
| 328 stability->set_uptime_sec(uptime_sec); | 328 stability->set_uptime_sec(uptime_sec); |
| 329 } | 329 } |
| 330 | 330 |
| 331 void MetricsLog::RecordEnvironment( | 331 void MetricsLog::RecordEnvironment( |
| 332 const std::vector<metrics::MetricsProvider*>& metrics_providers, | 332 const std::vector<metrics::MetricsProvider*>& metrics_providers, |
| 333 const std::vector<variations::ActiveGroupId>& synthetic_trials) { | 333 const std::vector<variations::ActiveGroupId>& synthetic_trials, |
| 334 int64 install_date) { |
| 334 DCHECK(!HasEnvironment()); | 335 DCHECK(!HasEnvironment()); |
| 335 | 336 |
| 336 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile(); | 337 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile(); |
| 337 | 338 |
| 338 std::string brand_code; | 339 std::string brand_code; |
| 339 if (client_->GetBrand(&brand_code)) | 340 if (client_->GetBrand(&brand_code)) |
| 340 system_profile->set_brand_code(brand_code); | 341 system_profile->set_brand_code(brand_code); |
| 341 | 342 |
| 342 int enabled_date; | 343 int enabled_date; |
| 343 bool success = | 344 bool success = |
| 344 base::StringToInt(GetMetricsEnabledDate(local_state_), &enabled_date); | 345 base::StringToInt(GetMetricsEnabledDate(local_state_), &enabled_date); |
| 345 DCHECK(success); | 346 DCHECK(success); |
| 346 | 347 |
| 347 // Reduce granularity of the enabled_date field to nearest hour. | 348 // Reduce granularity of the enabled_date field to nearest hour. |
| 348 system_profile->set_uma_enabled_date(RoundSecondsToHour(enabled_date)); | 349 system_profile->set_uma_enabled_date(RoundSecondsToHour(enabled_date)); |
| 349 | 350 |
| 350 int64 install_date = client_->GetInstallDate(); | |
| 351 | |
| 352 // Reduce granularity of the install_date field to nearest hour. | 351 // Reduce granularity of the install_date field to nearest hour. |
| 353 system_profile->set_install_date(RoundSecondsToHour(install_date)); | 352 system_profile->set_install_date(RoundSecondsToHour(install_date)); |
| 354 | 353 |
| 355 system_profile->set_application_locale(client_->GetApplicationLocale()); | 354 system_profile->set_application_locale(client_->GetApplicationLocale()); |
| 356 | 355 |
| 357 SystemProfileProto::Hardware* hardware = system_profile->mutable_hardware(); | 356 SystemProfileProto::Hardware* hardware = system_profile->mutable_hardware(); |
| 358 | 357 |
| 359 // By default, the hardware class is empty (i.e., unknown). | 358 // By default, the hardware class is empty (i.e., unknown). |
| 360 hardware->set_hardware_class(std::string()); | 359 hardware->set_hardware_class(std::string()); |
| 361 | 360 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 | 428 |
| 430 void MetricsLog::CloseLog() { | 429 void MetricsLog::CloseLog() { |
| 431 DCHECK(!closed_); | 430 DCHECK(!closed_); |
| 432 closed_ = true; | 431 closed_ = true; |
| 433 } | 432 } |
| 434 | 433 |
| 435 void MetricsLog::GetEncodedLog(std::string* encoded_log) { | 434 void MetricsLog::GetEncodedLog(std::string* encoded_log) { |
| 436 DCHECK(closed_); | 435 DCHECK(closed_); |
| 437 uma_proto_.SerializeToString(encoded_log); | 436 uma_proto_.SerializeToString(encoded_log); |
| 438 } | 437 } |
| OLD | NEW |