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> |
11 | 11 |
12 #include "base/build_time.h" | 12 #include "base/build_time.h" |
13 #include "base/cpu.h" | 13 #include "base/cpu.h" |
14 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
15 #include "base/metrics/histogram_samples.h" | 15 #include "base/metrics/histogram_samples.h" |
16 #include "base/metrics/metrics_hashes.h" | 16 #include "base/metrics/metrics_hashes.h" |
17 #include "base/sys_info.h" | 17 #include "base/sys_info.h" |
18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
20 #include "components/metrics/environment_recorder.h" | 20 #include "components/metrics/environment_recorder.h" |
21 #include "components/metrics/histogram_encoder.h" | 21 #include "components/metrics/histogram_encoder.h" |
22 #include "components/metrics/metrics_pref_names.h" | 22 #include "components/metrics/metrics_pref_names.h" |
23 #include "components/metrics/metrics_provider.h" | 23 #include "components/metrics/metrics_provider.h" |
24 #include "components/metrics/metrics_service_client.h" | 24 #include "components/metrics/metrics_service_client.h" |
25 #include "components/metrics/persistent_system_profile.h" | |
25 #include "components/metrics/proto/histogram_event.pb.h" | 26 #include "components/metrics/proto/histogram_event.pb.h" |
26 #include "components/metrics/proto/system_profile.pb.h" | 27 #include "components/metrics/proto/system_profile.pb.h" |
27 #include "components/metrics/proto/user_action_event.pb.h" | 28 #include "components/metrics/proto/user_action_event.pb.h" |
28 #include "components/prefs/pref_registry_simple.h" | 29 #include "components/prefs/pref_registry_simple.h" |
29 #include "components/prefs/pref_service.h" | 30 #include "components/prefs/pref_service.h" |
30 #include "components/variations/active_field_trials.h" | 31 #include "components/variations/active_field_trials.h" |
31 | 32 |
32 #if defined(OS_ANDROID) | 33 #if defined(OS_ANDROID) |
33 #include "base/android/build_info.h" | 34 #include "base/android/build_info.h" |
34 #endif | 35 #endif |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
295 cpu->set_num_cores(base::SysInfo::NumberOfProcessors()); | 296 cpu->set_num_cores(base::SysInfo::NumberOfProcessors()); |
296 | 297 |
297 std::vector<ActiveGroupId> field_trial_ids; | 298 std::vector<ActiveGroupId> field_trial_ids; |
298 GetFieldTrialIds(&field_trial_ids); | 299 GetFieldTrialIds(&field_trial_ids); |
299 WriteFieldTrials(field_trial_ids, system_profile); | 300 WriteFieldTrials(field_trial_ids, system_profile); |
300 WriteFieldTrials(synthetic_trials, system_profile); | 301 WriteFieldTrials(synthetic_trials, system_profile); |
301 | 302 |
302 for (size_t i = 0; i < metrics_providers.size(); ++i) | 303 for (size_t i = 0; i < metrics_providers.size(); ++i) |
303 metrics_providers[i]->ProvideSystemProfileMetrics(system_profile); | 304 metrics_providers[i]->ProvideSystemProfileMetrics(system_profile); |
304 | 305 |
306 GlobalPersistentSystemProfile::GetInstance()->SetSystemProfile( | |
307 *system_profile); | |
Alexei Svitkine (slow)
2017/05/29 19:48:32
This causes the system profile to be converted fro
bcwhite
2017/05/29 20:56:35
Turns out that SerializeAndRecordEnvironment retur
| |
308 | |
305 EnvironmentRecorder recorder(local_state_); | 309 EnvironmentRecorder recorder(local_state_); |
306 return recorder.SerializeAndRecordEnvironmentToPrefs(*system_profile); | 310 return recorder.SerializeAndRecordEnvironmentToPrefs(*system_profile); |
307 } | 311 } |
308 | 312 |
309 bool MetricsLog::LoadSavedEnvironmentFromPrefs(std::string* app_version) { | 313 bool MetricsLog::LoadSavedEnvironmentFromPrefs(std::string* app_version) { |
310 DCHECK(app_version); | 314 DCHECK(app_version); |
311 app_version->clear(); | 315 app_version->clear(); |
312 | 316 |
313 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile(); | 317 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile(); |
314 EnvironmentRecorder recorder(local_state_); | 318 EnvironmentRecorder recorder(local_state_); |
315 bool success = recorder.LoadEnvironmentFromPrefs(system_profile); | 319 bool success = recorder.LoadEnvironmentFromPrefs(system_profile); |
316 if (success) | 320 if (success) |
317 *app_version = system_profile->app_version(); | 321 *app_version = system_profile->app_version(); |
318 return success; | 322 return success; |
319 } | 323 } |
320 | 324 |
321 void MetricsLog::CloseLog() { | 325 void MetricsLog::CloseLog() { |
322 DCHECK(!closed_); | 326 DCHECK(!closed_); |
323 closed_ = true; | 327 closed_ = true; |
324 } | 328 } |
325 | 329 |
326 void MetricsLog::GetEncodedLog(std::string* encoded_log) { | 330 void MetricsLog::GetEncodedLog(std::string* encoded_log) { |
327 DCHECK(closed_); | 331 DCHECK(closed_); |
328 uma_proto_.SerializeToString(encoded_log); | 332 uma_proto_.SerializeToString(encoded_log); |
329 } | 333 } |
330 | 334 |
331 } // namespace metrics | 335 } // namespace metrics |
OLD | NEW |