| 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 <string> | 10 #include <string> |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 EnvironmentRecorder recorder(local_state_); | 306 EnvironmentRecorder recorder(local_state_); |
| 307 std::string serialized_proto = | 307 std::string serialized_proto = |
| 308 recorder.SerializeAndRecordEnvironmentToPrefs(*system_profile); | 308 recorder.SerializeAndRecordEnvironmentToPrefs(*system_profile); |
| 309 | 309 |
| 310 GlobalPersistentSystemProfile::GetInstance()->SetSystemProfile( | 310 GlobalPersistentSystemProfile::GetInstance()->SetSystemProfile( |
| 311 serialized_proto); | 311 serialized_proto); |
| 312 | 312 |
| 313 return serialized_proto; | 313 return serialized_proto; |
| 314 } | 314 } |
| 315 | 315 |
| 316 bool MetricsLog::LoadSavedEnvironmentFromProvider( |
| 317 MetricsProvider* metrics_provider, |
| 318 std::string* app_version) { |
| 319 DCHECK(app_version); |
| 320 app_version->clear(); |
| 321 |
| 322 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile(); |
| 323 if (!metrics_provider->ProvideStabilitySystemProfile(system_profile)) |
| 324 return false; |
| 325 *app_version = system_profile->app_version(); |
| 326 return true; |
| 327 } |
| 328 |
| 316 bool MetricsLog::LoadSavedEnvironmentFromPrefs(std::string* app_version) { | 329 bool MetricsLog::LoadSavedEnvironmentFromPrefs(std::string* app_version) { |
| 317 DCHECK(app_version); | 330 DCHECK(app_version); |
| 318 app_version->clear(); | 331 app_version->clear(); |
| 319 | 332 |
| 320 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile(); | 333 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile(); |
| 321 EnvironmentRecorder recorder(local_state_); | 334 EnvironmentRecorder recorder(local_state_); |
| 322 bool success = recorder.LoadEnvironmentFromPrefs(system_profile); | 335 bool success = recorder.LoadEnvironmentFromPrefs(system_profile); |
| 323 if (success) | 336 if (success) |
| 324 *app_version = system_profile->app_version(); | 337 *app_version = system_profile->app_version(); |
| 325 return success; | 338 return success; |
| 326 } | 339 } |
| 327 | 340 |
| 328 void MetricsLog::CloseLog() { | 341 void MetricsLog::CloseLog() { |
| 329 DCHECK(!closed_); | 342 DCHECK(!closed_); |
| 330 closed_ = true; | 343 closed_ = true; |
| 331 } | 344 } |
| 332 | 345 |
| 333 void MetricsLog::GetEncodedLog(std::string* encoded_log) { | 346 void MetricsLog::GetEncodedLog(std::string* encoded_log) { |
| 334 DCHECK(closed_); | 347 DCHECK(closed_); |
| 335 uma_proto_.SerializeToString(encoded_log); | 348 uma_proto_.SerializeToString(encoded_log); |
| 336 } | 349 } |
| 337 | 350 |
| 338 } // namespace metrics | 351 } // namespace metrics |
| OLD | NEW |