| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/metrics/metrics_log.h" | 5 #include "chrome/browser/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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #include "base/android/build_info.h" | 48 #include "base/android/build_info.h" |
| 49 #endif | 49 #endif |
| 50 | 50 |
| 51 #if defined(OS_WIN) | 51 #if defined(OS_WIN) |
| 52 #include "base/win/metro.h" | 52 #include "base/win/metro.h" |
| 53 | 53 |
| 54 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx | 54 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx |
| 55 extern "C" IMAGE_DOS_HEADER __ImageBase; | 55 extern "C" IMAGE_DOS_HEADER __ImageBase; |
| 56 #endif | 56 #endif |
| 57 | 57 |
| 58 #if defined(OS_CHROMEOS) | |
| 59 #include "chrome/browser/metrics/metrics_log_chromeos.h" | |
| 60 #endif // OS_CHROMEOS | |
| 61 | |
| 62 using content::GpuDataManager; | 58 using content::GpuDataManager; |
| 63 using metrics::MetricsLogBase; | 59 using metrics::MetricsLogBase; |
| 64 using metrics::ProfilerEventProto; | 60 using metrics::ProfilerEventProto; |
| 65 using metrics::SystemProfileProto; | 61 using metrics::SystemProfileProto; |
| 66 using tracked_objects::ProcessDataSnapshot; | 62 using tracked_objects::ProcessDataSnapshot; |
| 67 typedef variations::ActiveGroupId ActiveGroupId; | 63 typedef variations::ActiveGroupId ActiveGroupId; |
| 68 | 64 |
| 69 namespace { | 65 namespace { |
| 70 | 66 |
| 71 // Returns the date at which the current metrics client ID was created as | 67 // Returns the date at which the current metrics client ID was created as |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 | 282 |
| 287 MetricsLog::MetricsLog(const std::string& client_id, | 283 MetricsLog::MetricsLog(const std::string& client_id, |
| 288 int session_id, | 284 int session_id, |
| 289 LogType log_type) | 285 LogType log_type) |
| 290 : MetricsLogBase(client_id, session_id, log_type, | 286 : MetricsLogBase(client_id, session_id, log_type, |
| 291 MetricsLog::GetVersionString()), | 287 MetricsLog::GetVersionString()), |
| 292 creation_time_(base::TimeTicks::Now()), | 288 creation_time_(base::TimeTicks::Now()), |
| 293 extension_metrics_(uma_proto()->client_id()) { | 289 extension_metrics_(uma_proto()->client_id()) { |
| 294 uma_proto()->mutable_system_profile()->set_channel( | 290 uma_proto()->mutable_system_profile()->set_channel( |
| 295 AsProtobufChannel(chrome::VersionInfo::GetChannel())); | 291 AsProtobufChannel(chrome::VersionInfo::GetChannel())); |
| 296 | |
| 297 #if defined(OS_CHROMEOS) | |
| 298 metrics_log_chromeos_.reset(new MetricsLogChromeOS(uma_proto())); | |
| 299 #endif // OS_CHROMEOS | |
| 300 } | 292 } |
| 301 | 293 |
| 302 MetricsLog::~MetricsLog() {} | 294 MetricsLog::~MetricsLog() {} |
| 303 | 295 |
| 304 // static | 296 // static |
| 305 void MetricsLog::RegisterPrefs(PrefRegistrySimple* registry) { | 297 void MetricsLog::RegisterPrefs(PrefRegistrySimple* registry) { |
| 306 registry->RegisterListPref(prefs::kStabilityPluginStats); | 298 registry->RegisterListPref(prefs::kStabilityPluginStats); |
| 307 } | 299 } |
| 308 | 300 |
| 309 // static | 301 // static |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 stability->set_renderer_hang_count(count); | 540 stability->set_renderer_hang_count(count); |
| 549 pref->SetInteger(prefs::kStabilityRendererHangCount, 0); | 541 pref->SetInteger(prefs::kStabilityRendererHangCount, 0); |
| 550 } | 542 } |
| 551 | 543 |
| 552 count = pref->GetInteger(prefs::kStabilityChildProcessCrashCount); | 544 count = pref->GetInteger(prefs::kStabilityChildProcessCrashCount); |
| 553 if (count) { | 545 if (count) { |
| 554 stability->set_child_process_crash_count(count); | 546 stability->set_child_process_crash_count(count); |
| 555 pref->SetInteger(prefs::kStabilityChildProcessCrashCount, 0); | 547 pref->SetInteger(prefs::kStabilityChildProcessCrashCount, 0); |
| 556 } | 548 } |
| 557 | 549 |
| 558 #if defined(OS_CHROMEOS) | |
| 559 metrics_log_chromeos_->WriteRealtimeStabilityAttributes(pref); | |
| 560 #endif // OS_CHROMEOS | |
| 561 | |
| 562 const uint64 incremental_uptime_sec = incremental_uptime.InSeconds(); | 550 const uint64 incremental_uptime_sec = incremental_uptime.InSeconds(); |
| 563 if (incremental_uptime_sec) | 551 if (incremental_uptime_sec) |
| 564 stability->set_incremental_uptime_sec(incremental_uptime_sec); | 552 stability->set_incremental_uptime_sec(incremental_uptime_sec); |
| 565 const uint64 uptime_sec = uptime.InSeconds(); | 553 const uint64 uptime_sec = uptime.InSeconds(); |
| 566 if (uptime_sec) | 554 if (uptime_sec) |
| 567 stability->set_uptime_sec(uptime_sec); | 555 stability->set_uptime_sec(uptime_sec); |
| 568 } | 556 } |
| 569 | 557 |
| 570 void MetricsLog::WritePluginList( | 558 void MetricsLog::WritePluginList( |
| 571 const std::vector<content::WebPluginInfo>& plugin_list) { | 559 const std::vector<content::WebPluginInfo>& plugin_list) { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 #endif | 665 #endif |
| 678 | 666 |
| 679 WritePluginList(plugin_list); | 667 WritePluginList(plugin_list); |
| 680 extension_metrics_.WriteExtensionList(uma_proto()->mutable_system_profile()); | 668 extension_metrics_.WriteExtensionList(uma_proto()->mutable_system_profile()); |
| 681 | 669 |
| 682 std::vector<ActiveGroupId> field_trial_ids; | 670 std::vector<ActiveGroupId> field_trial_ids; |
| 683 GetFieldTrialIds(&field_trial_ids); | 671 GetFieldTrialIds(&field_trial_ids); |
| 684 WriteFieldTrials(field_trial_ids, system_profile); | 672 WriteFieldTrials(field_trial_ids, system_profile); |
| 685 WriteFieldTrials(synthetic_trials, system_profile); | 673 WriteFieldTrials(synthetic_trials, system_profile); |
| 686 | 674 |
| 687 #if defined(OS_CHROMEOS) | |
| 688 metrics_log_chromeos_->LogChromeOSMetrics(); | |
| 689 #endif // OS_CHROMEOS | |
| 690 | |
| 691 for (size_t i = 0; i < metrics_providers.size(); ++i) | 675 for (size_t i = 0; i < metrics_providers.size(); ++i) |
| 692 metrics_providers[i]->ProvideSystemProfileMetrics(system_profile); | 676 metrics_providers[i]->ProvideSystemProfileMetrics(system_profile); |
| 693 | 677 |
| 694 std::string serialied_system_profile; | 678 std::string serialied_system_profile; |
| 695 std::string base64_system_profile; | 679 std::string base64_system_profile; |
| 696 if (system_profile->SerializeToString(&serialied_system_profile)) { | 680 if (system_profile->SerializeToString(&serialied_system_profile)) { |
| 697 base::Base64Encode(serialied_system_profile, &base64_system_profile); | 681 base::Base64Encode(serialied_system_profile, &base64_system_profile); |
| 698 PrefService* local_state = GetPrefService(); | 682 PrefService* local_state = GetPrefService(); |
| 699 local_state->SetString(prefs::kStabilitySavedSystemProfile, | 683 local_state->SetString(prefs::kStabilitySavedSystemProfile, |
| 700 base64_system_profile); | 684 base64_system_profile); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 profile = uma_proto()->add_profiler_event(); | 723 profile = uma_proto()->add_profiler_event(); |
| 740 profile->set_profile_type(ProfilerEventProto::STARTUP_PROFILE); | 724 profile->set_profile_type(ProfilerEventProto::STARTUP_PROFILE); |
| 741 profile->set_time_source(ProfilerEventProto::WALL_CLOCK_TIME); | 725 profile->set_time_source(ProfilerEventProto::WALL_CLOCK_TIME); |
| 742 } else { | 726 } else { |
| 743 // For the remaining calls, re-use the existing field. | 727 // For the remaining calls, re-use the existing field. |
| 744 profile = uma_proto()->mutable_profiler_event(0); | 728 profile = uma_proto()->mutable_profiler_event(0); |
| 745 } | 729 } |
| 746 | 730 |
| 747 WriteProfilerData(process_data, process_type, profile); | 731 WriteProfilerData(process_data, process_type, profile); |
| 748 } | 732 } |
| OLD | NEW |