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 20 matching lines...) Expand all Loading... |
31 #include "chrome/browser/autocomplete/autocomplete_result.h" | 31 #include "chrome/browser/autocomplete/autocomplete_result.h" |
32 #include "chrome/browser/browser_process.h" | 32 #include "chrome/browser/browser_process.h" |
33 #include "chrome/browser/google/google_util.h" | 33 #include "chrome/browser/google/google_util.h" |
34 #include "chrome/browser/metrics/extension_metrics.h" | 34 #include "chrome/browser/metrics/extension_metrics.h" |
35 #include "chrome/browser/omnibox/omnibox_log.h" | 35 #include "chrome/browser/omnibox/omnibox_log.h" |
36 #include "chrome/browser/plugins/plugin_prefs.h" | 36 #include "chrome/browser/plugins/plugin_prefs.h" |
37 #include "chrome/browser/profiles/profile_manager.h" | 37 #include "chrome/browser/profiles/profile_manager.h" |
38 #include "chrome/common/chrome_version_info.h" | 38 #include "chrome/common/chrome_version_info.h" |
39 #include "chrome/common/pref_names.h" | 39 #include "chrome/common/pref_names.h" |
40 #include "chrome/installer/util/google_update_settings.h" | 40 #include "chrome/installer/util/google_update_settings.h" |
| 41 #include "components/metrics/metrics_provider.h" |
41 #include "components/metrics/proto/omnibox_event.pb.h" | 42 #include "components/metrics/proto/omnibox_event.pb.h" |
42 #include "components/metrics/proto/profiler_event.pb.h" | 43 #include "components/metrics/proto/profiler_event.pb.h" |
43 #include "components/metrics/proto/system_profile.pb.h" | 44 #include "components/metrics/proto/system_profile.pb.h" |
44 #include "components/nacl/common/nacl_process_type.h" | 45 #include "components/nacl/common/nacl_process_type.h" |
45 #include "components/variations/active_field_trials.h" | 46 #include "components/variations/active_field_trials.h" |
46 #include "content/public/browser/gpu_data_manager.h" | 47 #include "content/public/browser/gpu_data_manager.h" |
47 #include "content/public/common/content_client.h" | 48 #include "content/public/common/content_client.h" |
48 #include "content/public/common/webplugininfo.h" | 49 #include "content/public/common/webplugininfo.h" |
49 #include "gpu/config/gpu_info.h" | 50 #include "gpu/config/gpu_info.h" |
50 #include "ui/gfx/screen.h" | 51 #include "ui/gfx/screen.h" |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 // static | 442 // static |
442 void MetricsLog::set_version_extension(const std::string& extension) { | 443 void MetricsLog::set_version_extension(const std::string& extension) { |
443 g_version_extension.Get() = extension; | 444 g_version_extension.Get() = extension; |
444 } | 445 } |
445 | 446 |
446 // static | 447 // static |
447 const std::string& MetricsLog::version_extension() { | 448 const std::string& MetricsLog::version_extension() { |
448 return g_version_extension.Get(); | 449 return g_version_extension.Get(); |
449 } | 450 } |
450 | 451 |
451 void MetricsLog::RecordStabilityMetrics(base::TimeDelta incremental_uptime, | 452 void MetricsLog::RecordStabilityMetrics( |
452 base::TimeDelta uptime) { | 453 const std::vector<metrics::MetricsProvider*>& metrics_providers, |
| 454 base::TimeDelta incremental_uptime, |
| 455 base::TimeDelta uptime) { |
453 DCHECK(!locked()); | 456 DCHECK(!locked()); |
454 DCHECK(HasEnvironment()); | 457 DCHECK(HasEnvironment()); |
455 DCHECK(!HasStabilityMetrics()); | 458 DCHECK(!HasStabilityMetrics()); |
456 | 459 |
457 PrefService* pref = GetPrefService(); | 460 PrefService* pref = GetPrefService(); |
458 DCHECK(pref); | 461 DCHECK(pref); |
459 | 462 |
460 // Get stability attributes out of Local State, zeroing out stored values. | 463 // Get stability attributes out of Local State, zeroing out stored values. |
461 // NOTE: This could lead to some data loss if this report isn't successfully | 464 // NOTE: This could lead to some data loss if this report isn't successfully |
462 // sent, but that's true for all the metrics. | 465 // sent, but that's true for all the metrics. |
463 | 466 |
464 WriteRequiredStabilityAttributes(pref); | 467 WriteRequiredStabilityAttributes(pref); |
465 WritePluginStabilityElements(pref); | 468 WritePluginStabilityElements(pref); |
466 | 469 |
467 // Record recent delta for critical stability metrics. We can't wait for a | 470 // Record recent delta for critical stability metrics. We can't wait for a |
468 // restart to gather these, as that delay biases our observation away from | 471 // restart to gather these, as that delay biases our observation away from |
469 // users that run happily for a looooong time. We send increments with each | 472 // users that run happily for a looooong time. We send increments with each |
470 // uma log upload, just as we send histogram data. | 473 // uma log upload, just as we send histogram data. |
471 WriteRealtimeStabilityAttributes(pref, incremental_uptime, uptime); | 474 WriteRealtimeStabilityAttributes(pref, incremental_uptime, uptime); |
472 | 475 |
| 476 SystemProfileProto::Stability* stability = |
| 477 uma_proto()->mutable_system_profile()->mutable_stability(); |
| 478 for (size_t i = 0; i < metrics_providers.size(); ++i) |
| 479 metrics_providers[i]->ProvideStabilityMetrics(stability); |
| 480 |
473 // Omit some stats unless this is the initial stability log. | 481 // Omit some stats unless this is the initial stability log. |
474 if (log_type() != INITIAL_STABILITY_LOG) | 482 if (log_type() != INITIAL_STABILITY_LOG) |
475 return; | 483 return; |
476 | 484 |
477 int incomplete_shutdown_count = | 485 int incomplete_shutdown_count = |
478 pref->GetInteger(prefs::kStabilityIncompleteSessionEndCount); | 486 pref->GetInteger(prefs::kStabilityIncompleteSessionEndCount); |
479 pref->SetInteger(prefs::kStabilityIncompleteSessionEndCount, 0); | 487 pref->SetInteger(prefs::kStabilityIncompleteSessionEndCount, 0); |
480 int breakpad_registration_success_count = | 488 int breakpad_registration_success_count = |
481 pref->GetInteger(prefs::kStabilityBreakpadRegistrationSuccess); | 489 pref->GetInteger(prefs::kStabilityBreakpadRegistrationSuccess); |
482 pref->SetInteger(prefs::kStabilityBreakpadRegistrationSuccess, 0); | 490 pref->SetInteger(prefs::kStabilityBreakpadRegistrationSuccess, 0); |
483 int breakpad_registration_failure_count = | 491 int breakpad_registration_failure_count = |
484 pref->GetInteger(prefs::kStabilityBreakpadRegistrationFail); | 492 pref->GetInteger(prefs::kStabilityBreakpadRegistrationFail); |
485 pref->SetInteger(prefs::kStabilityBreakpadRegistrationFail, 0); | 493 pref->SetInteger(prefs::kStabilityBreakpadRegistrationFail, 0); |
486 int debugger_present_count = | 494 int debugger_present_count = |
487 pref->GetInteger(prefs::kStabilityDebuggerPresent); | 495 pref->GetInteger(prefs::kStabilityDebuggerPresent); |
488 pref->SetInteger(prefs::kStabilityDebuggerPresent, 0); | 496 pref->SetInteger(prefs::kStabilityDebuggerPresent, 0); |
489 int debugger_not_present_count = | 497 int debugger_not_present_count = |
490 pref->GetInteger(prefs::kStabilityDebuggerNotPresent); | 498 pref->GetInteger(prefs::kStabilityDebuggerNotPresent); |
491 pref->SetInteger(prefs::kStabilityDebuggerNotPresent, 0); | 499 pref->SetInteger(prefs::kStabilityDebuggerNotPresent, 0); |
492 | 500 |
493 // TODO(jar): The following are all optional, so we *could* optimize them for | 501 // TODO(jar): The following are all optional, so we *could* optimize them for |
494 // values of zero (and not include them). | 502 // values of zero (and not include them). |
495 SystemProfileProto::Stability* stability = | |
496 uma_proto()->mutable_system_profile()->mutable_stability(); | |
497 stability->set_incomplete_shutdown_count(incomplete_shutdown_count); | 503 stability->set_incomplete_shutdown_count(incomplete_shutdown_count); |
498 stability->set_breakpad_registration_success_count( | 504 stability->set_breakpad_registration_success_count( |
499 breakpad_registration_success_count); | 505 breakpad_registration_success_count); |
500 stability->set_breakpad_registration_failure_count( | 506 stability->set_breakpad_registration_failure_count( |
501 breakpad_registration_failure_count); | 507 breakpad_registration_failure_count); |
502 stability->set_debugger_present_count(debugger_present_count); | 508 stability->set_debugger_present_count(debugger_present_count); |
503 stability->set_debugger_not_present_count(debugger_not_present_count); | 509 stability->set_debugger_not_present_count(debugger_not_present_count); |
504 } | 510 } |
505 | 511 |
| 512 void MetricsLog::RecordGeneralMetrics( |
| 513 const std::vector<metrics::MetricsProvider*>& metrics_providers) { |
| 514 for (size_t i = 0; i < metrics_providers.size(); ++i) |
| 515 metrics_providers[i]->ProvideGeneralMetrics(uma_proto()); |
| 516 } |
| 517 |
506 PrefService* MetricsLog::GetPrefService() { | 518 PrefService* MetricsLog::GetPrefService() { |
507 return g_browser_process->local_state(); | 519 return g_browser_process->local_state(); |
508 } | 520 } |
509 | 521 |
510 gfx::Size MetricsLog::GetScreenSize() const { | 522 gfx::Size MetricsLog::GetScreenSize() const { |
511 return gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().GetSizeInPixel(); | 523 return gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().GetSizeInPixel(); |
512 } | 524 } |
513 | 525 |
514 float MetricsLog::GetScreenDeviceScaleFactor() const { | 526 float MetricsLog::GetScreenDeviceScaleFactor() const { |
515 return gfx::Screen::GetNativeScreen()-> | 527 return gfx::Screen::GetNativeScreen()-> |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 for (std::vector<content::WebPluginInfo>::const_iterator iter = | 694 for (std::vector<content::WebPluginInfo>::const_iterator iter = |
683 plugin_list.begin(); | 695 plugin_list.begin(); |
684 iter != plugin_list.end(); ++iter) { | 696 iter != plugin_list.end(); ++iter) { |
685 SystemProfileProto::Plugin* plugin = system_profile->add_plugin(); | 697 SystemProfileProto::Plugin* plugin = system_profile->add_plugin(); |
686 SetPluginInfo(*iter, plugin_prefs, plugin); | 698 SetPluginInfo(*iter, plugin_prefs, plugin); |
687 } | 699 } |
688 #endif // defined(ENABLE_PLUGINS) | 700 #endif // defined(ENABLE_PLUGINS) |
689 } | 701 } |
690 | 702 |
691 void MetricsLog::RecordEnvironment( | 703 void MetricsLog::RecordEnvironment( |
| 704 const std::vector<metrics::MetricsProvider*>& metrics_providers, |
692 const std::vector<content::WebPluginInfo>& plugin_list, | 705 const std::vector<content::WebPluginInfo>& plugin_list, |
693 const GoogleUpdateMetrics& google_update_metrics, | 706 const GoogleUpdateMetrics& google_update_metrics, |
694 const std::vector<variations::ActiveGroupId>& synthetic_trials) { | 707 const std::vector<variations::ActiveGroupId>& synthetic_trials) { |
695 DCHECK(!HasEnvironment()); | 708 DCHECK(!HasEnvironment()); |
696 | 709 |
697 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile(); | 710 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile(); |
698 | 711 |
699 std::string brand_code; | 712 std::string brand_code; |
700 if (google_util::GetBrand(&brand_code)) | 713 if (google_util::GetBrand(&brand_code)) |
701 system_profile->set_brand_code(brand_code); | 714 system_profile->set_brand_code(brand_code); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 | 801 |
789 std::vector<ActiveGroupId> field_trial_ids; | 802 std::vector<ActiveGroupId> field_trial_ids; |
790 GetFieldTrialIds(&field_trial_ids); | 803 GetFieldTrialIds(&field_trial_ids); |
791 WriteFieldTrials(field_trial_ids, system_profile); | 804 WriteFieldTrials(field_trial_ids, system_profile); |
792 WriteFieldTrials(synthetic_trials, system_profile); | 805 WriteFieldTrials(synthetic_trials, system_profile); |
793 | 806 |
794 #if defined(OS_CHROMEOS) | 807 #if defined(OS_CHROMEOS) |
795 metrics_log_chromeos_->LogChromeOSMetrics(); | 808 metrics_log_chromeos_->LogChromeOSMetrics(); |
796 #endif // OS_CHROMEOS | 809 #endif // OS_CHROMEOS |
797 | 810 |
| 811 for (size_t i = 0; i < metrics_providers.size(); ++i) |
| 812 metrics_providers[i]->ProvideSystemProfileMetrics(system_profile); |
| 813 |
798 std::string serialied_system_profile; | 814 std::string serialied_system_profile; |
799 std::string base64_system_profile; | 815 std::string base64_system_profile; |
800 if (system_profile->SerializeToString(&serialied_system_profile)) { | 816 if (system_profile->SerializeToString(&serialied_system_profile)) { |
801 base::Base64Encode(serialied_system_profile, &base64_system_profile); | 817 base::Base64Encode(serialied_system_profile, &base64_system_profile); |
802 PrefService* local_state = GetPrefService(); | 818 PrefService* local_state = GetPrefService(); |
803 local_state->SetString(prefs::kStabilitySavedSystemProfile, | 819 local_state->SetString(prefs::kStabilitySavedSystemProfile, |
804 base64_system_profile); | 820 base64_system_profile); |
805 local_state->SetString(prefs::kStabilitySavedSystemProfileHash, | 821 local_state->SetString(prefs::kStabilitySavedSystemProfileHash, |
806 ComputeSHA1(serialied_system_profile)); | 822 ComputeSHA1(serialied_system_profile)); |
807 } | 823 } |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 ProductDataToProto(google_update_metrics.google_update_data, | 956 ProductDataToProto(google_update_metrics.google_update_data, |
941 google_update->mutable_google_update_status()); | 957 google_update->mutable_google_update_status()); |
942 } | 958 } |
943 | 959 |
944 if (!google_update_metrics.product_data.version.empty()) { | 960 if (!google_update_metrics.product_data.version.empty()) { |
945 ProductDataToProto(google_update_metrics.product_data, | 961 ProductDataToProto(google_update_metrics.product_data, |
946 google_update->mutable_client_status()); | 962 google_update->mutable_client_status()); |
947 } | 963 } |
948 #endif // defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN) | 964 #endif // defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN) |
949 } | 965 } |
OLD | NEW |