Chromium Code Reviews| 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 <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 #include "chrome/common/pref_names.h" | 38 #include "chrome/common/pref_names.h" |
| 39 #include "chrome/installer/util/google_update_settings.h" | 39 #include "chrome/installer/util/google_update_settings.h" |
| 40 #include "content/public/browser/content_browser_client.h" | 40 #include "content/public/browser/content_browser_client.h" |
| 41 #include "content/public/browser/gpu_data_manager.h" | 41 #include "content/public/browser/gpu_data_manager.h" |
| 42 #include "content/public/common/content_client.h" | 42 #include "content/public/common/content_client.h" |
| 43 #include "content/public/common/gpu_info.h" | 43 #include "content/public/common/gpu_info.h" |
| 44 #include "googleurl/src/gurl.h" | 44 #include "googleurl/src/gurl.h" |
| 45 #include "ui/gfx/screen.h" | 45 #include "ui/gfx/screen.h" |
| 46 #include "webkit/plugins/webplugininfo.h" | 46 #include "webkit/plugins/webplugininfo.h" |
| 47 | 47 |
| 48 #if defined(OS_ANDROID) | |
| 49 #include "base/android/build_info.h" | |
| 50 #endif | |
| 51 | |
| 48 #define OPEN_ELEMENT_FOR_SCOPE(name) ScopedElement scoped_element(this, name) | 52 #define OPEN_ELEMENT_FOR_SCOPE(name) ScopedElement scoped_element(this, name) |
| 49 | 53 |
| 50 #if defined(OS_WIN) | 54 #if defined(OS_WIN) |
| 51 #include "base/win/metro.h" | 55 #include "base/win/metro.h" |
| 52 | 56 |
| 53 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx | 57 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx |
| 54 extern "C" IMAGE_DOS_HEADER __ImageBase; | 58 extern "C" IMAGE_DOS_HEADER __ImageBase; |
| 55 #endif | 59 #endif |
| 56 | 60 |
| 57 using content::GpuDataManager; | 61 using content::GpuDataManager; |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 318 | 322 |
| 319 void MetricsLog::RecordIncrementalStabilityElements( | 323 void MetricsLog::RecordIncrementalStabilityElements( |
| 320 const std::vector<webkit::WebPluginInfo>& plugin_list) { | 324 const std::vector<webkit::WebPluginInfo>& plugin_list) { |
| 321 DCHECK(!locked()); | 325 DCHECK(!locked()); |
| 322 | 326 |
| 323 PrefService* pref = GetPrefService(); | 327 PrefService* pref = GetPrefService(); |
| 324 DCHECK(pref); | 328 DCHECK(pref); |
| 325 | 329 |
| 326 OPEN_ELEMENT_FOR_SCOPE("profile"); | 330 OPEN_ELEMENT_FOR_SCOPE("profile"); |
| 327 WriteCommonEventAttributes(); | 331 WriteCommonEventAttributes(); |
| 328 | |
| 329 WriteInstallElement(); | 332 WriteInstallElement(); |
| 333 #if defined(OS_ANDROID) | |
| 334 WriteOSInfoElement(); | |
| 335 #endif | |
|
Ilya Sherman
2012/10/01 23:01:38
I don't think it's appropriate to add the OS info
gone
2012/10/02 18:24:24
With nilesh's comment as context, does your commen
Ilya Sherman
2012/10/02 21:37:45
TL;DR: You can ignore my previous comment w.r.t. t
gone
2012/10/02 23:10:00
If that's the case then we really shouldn't be for
| |
| 330 | 336 |
| 331 { | 337 { |
| 332 OPEN_ELEMENT_FOR_SCOPE("stability"); // Minimal set of stability elements. | 338 OPEN_ELEMENT_FOR_SCOPE("stability"); // Minimal set of stability elements. |
| 333 WriteRequiredStabilityAttributes(pref); | 339 WriteRequiredStabilityAttributes(pref); |
| 334 WriteRealtimeStabilityAttributes(pref); | 340 WriteRealtimeStabilityAttributes(pref); |
| 335 | 341 |
| 336 WritePluginStabilityElements(plugin_list, pref); | 342 WritePluginStabilityElements(plugin_list, pref); |
| 337 } | 343 } |
| 338 } | 344 } |
| 339 | 345 |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 641 void MetricsLog::RecordEnvironment( | 647 void MetricsLog::RecordEnvironment( |
| 642 const std::vector<webkit::WebPluginInfo>& plugin_list, | 648 const std::vector<webkit::WebPluginInfo>& plugin_list, |
| 643 const GoogleUpdateMetrics& google_update_metrics, | 649 const GoogleUpdateMetrics& google_update_metrics, |
| 644 const DictionaryValue* profile_metrics) { | 650 const DictionaryValue* profile_metrics) { |
| 645 DCHECK(!locked()); | 651 DCHECK(!locked()); |
| 646 | 652 |
| 647 PrefService* pref = GetPrefService(); | 653 PrefService* pref = GetPrefService(); |
| 648 | 654 |
| 649 OPEN_ELEMENT_FOR_SCOPE("profile"); | 655 OPEN_ELEMENT_FOR_SCOPE("profile"); |
| 650 WriteCommonEventAttributes(); | 656 WriteCommonEventAttributes(); |
| 651 | |
| 652 WriteInstallElement(); | 657 WriteInstallElement(); |
| 653 | 658 |
| 654 // Write the XML version. | 659 // Write the XML version. |
| 655 // We'll write the protobuf version in RecordEnvironmentProto(). | 660 // We'll write the protobuf version in RecordEnvironmentProto(). |
| 656 bool write_as_xml = true; | 661 bool write_as_xml = true; |
| 657 WritePluginList(plugin_list, write_as_xml); | 662 WritePluginList(plugin_list, write_as_xml); |
| 658 | 663 |
| 659 WriteStabilityElement(plugin_list, pref); | 664 WriteStabilityElement(plugin_list, pref); |
| 660 | 665 |
| 661 { | 666 { |
| 662 // Write the XML version. | 667 // Write the XML version. |
| 663 // We'll write the protobuf version in RecordEnvironmentProto(). | 668 // We'll write the protobuf version in RecordEnvironmentProto(). |
| 664 OPEN_ELEMENT_FOR_SCOPE("cpu"); | 669 OPEN_ELEMENT_FOR_SCOPE("cpu"); |
| 665 WriteAttribute("arch", base::SysInfo::CPUArchitecture()); | 670 WriteAttribute("arch", base::SysInfo::CPUArchitecture()); |
| 666 } | 671 } |
| 667 | 672 |
| 668 { | 673 { |
| 669 // Write the XML version. | 674 // Write the XML version. |
| 670 // We'll write the protobuf version in RecordEnvironmentProto(). | 675 // We'll write the protobuf version in RecordEnvironmentProto(). |
| 671 OPEN_ELEMENT_FOR_SCOPE("memory"); | 676 OPEN_ELEMENT_FOR_SCOPE("memory"); |
| 672 WriteIntAttribute("mb", base::SysInfo::AmountOfPhysicalMemoryMB()); | 677 WriteIntAttribute("mb", base::SysInfo::AmountOfPhysicalMemoryMB()); |
| 673 #if defined(OS_WIN) | 678 #if defined(OS_WIN) |
| 674 WriteIntAttribute("dllbase", reinterpret_cast<int>(&__ImageBase)); | 679 WriteIntAttribute("dllbase", reinterpret_cast<int>(&__ImageBase)); |
| 675 #endif | 680 #endif |
| 676 } | 681 } |
| 677 | 682 |
| 678 { | 683 WriteOSInfoElement(); |
| 679 // Write the XML version. | |
| 680 // We'll write the protobuf version in RecordEnvironmentProto(). | |
| 681 OPEN_ELEMENT_FOR_SCOPE("os"); | |
| 682 WriteAttribute("name", base::SysInfo::OperatingSystemName()); | |
| 683 WriteAttribute("version", base::SysInfo::OperatingSystemVersion()); | |
| 684 } | |
| 685 | 684 |
| 686 { | 685 { |
| 687 OPEN_ELEMENT_FOR_SCOPE("gpu"); | 686 OPEN_ELEMENT_FOR_SCOPE("gpu"); |
| 688 const content::GPUInfo& gpu_info = | 687 const content::GPUInfo& gpu_info = |
| 689 GpuDataManager::GetInstance()->GetGPUInfo(); | 688 GpuDataManager::GetInstance()->GetGPUInfo(); |
| 690 | 689 |
| 691 // Write the XML version. | 690 // Write the XML version. |
| 692 // We'll write the protobuf version in RecordEnvironmentProto(). | 691 // We'll write the protobuf version in RecordEnvironmentProto(). |
| 693 WriteIntAttribute("vendorid", gpu_info.gpu.vendor_id); | 692 WriteIntAttribute("vendorid", gpu_info.gpu.vendor_id); |
| 694 WriteIntAttribute("deviceid", gpu_info.gpu.device_id); | 693 WriteIntAttribute("deviceid", gpu_info.gpu.device_id); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 769 // TODO(mad): This only checks whether the main process is a Metro process at | 768 // TODO(mad): This only checks whether the main process is a Metro process at |
| 770 // upload time; not whether the collected metrics were all gathered from | 769 // upload time; not whether the collected metrics were all gathered from |
| 771 // Metro. This is ok as an approximation for now, since users will rarely be | 770 // Metro. This is ok as an approximation for now, since users will rarely be |
| 772 // switching from Metro to Desktop mode; but we should re-evaluate whether we | 771 // switching from Metro to Desktop mode; but we should re-evaluate whether we |
| 773 // can distinguish metrics more cleanly in the future: http://crbug.com/140568 | 772 // can distinguish metrics more cleanly in the future: http://crbug.com/140568 |
| 774 if (base::win::IsMetroProcess()) | 773 if (base::win::IsMetroProcess()) |
| 775 os_name += " (Metro)"; | 774 os_name += " (Metro)"; |
| 776 #endif | 775 #endif |
| 777 os->set_name(os_name); | 776 os->set_name(os_name); |
| 778 os->set_version(base::SysInfo::OperatingSystemVersion()); | 777 os->set_version(base::SysInfo::OperatingSystemVersion()); |
| 778 #if defined(OS_ANDROID) | |
| 779 os->set_fingerprint( | |
| 780 base::android::BuildInfo::GetInstance()->android_build_fp()); | |
| 781 #endif | |
| 779 | 782 |
| 780 const content::GPUInfo& gpu_info = | 783 const content::GPUInfo& gpu_info = |
| 781 GpuDataManager::GetInstance()->GetGPUInfo(); | 784 GpuDataManager::GetInstance()->GetGPUInfo(); |
| 782 SystemProfileProto::Hardware::Graphics* gpu = hardware->mutable_gpu(); | 785 SystemProfileProto::Hardware::Graphics* gpu = hardware->mutable_gpu(); |
| 783 gpu->set_vendor_id(gpu_info.gpu.vendor_id); | 786 gpu->set_vendor_id(gpu_info.gpu.vendor_id); |
| 784 gpu->set_device_id(gpu_info.gpu.device_id); | 787 gpu->set_device_id(gpu_info.gpu.device_id); |
| 785 gpu->set_driver_version(gpu_info.driver_version); | 788 gpu->set_driver_version(gpu_info.driver_version); |
| 786 gpu->set_driver_date(gpu_info.driver_date); | 789 gpu->set_driver_date(gpu_info.driver_date); |
| 787 SystemProfileProto::Hardware::Graphics::PerformanceStatistics* | 790 SystemProfileProto::Hardware::Graphics::PerformanceStatistics* |
| 788 gpu_performance = gpu->mutable_performance_statistics(); | 791 gpu_performance = gpu->mutable_performance_statistics(); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 887 } | 890 } |
| 888 | 891 |
| 889 default: | 892 default: |
| 890 NOTREACHED(); | 893 NOTREACHED(); |
| 891 break; | 894 break; |
| 892 } | 895 } |
| 893 } | 896 } |
| 894 } | 897 } |
| 895 } | 898 } |
| 896 | 899 |
| 900 void MetricsLog::WriteOSInfoElement() { | |
| 901 // Write the XML version. | |
|
Ilya Sherman
2012/10/01 23:01:38
As I mentioned above, I don't think you should mov
gone
2012/10/02 23:45:10
Undid the change. We'll go with the protobuf on m
| |
| 902 OPEN_ELEMENT_FOR_SCOPE("os"); | |
| 903 WriteAttribute("name", base::SysInfo::OperatingSystemName()); | |
| 904 WriteAttribute("version", base::SysInfo::OperatingSystemVersion()); | |
| 905 #if defined(OS_ANDROID) | |
| 906 WriteAttribute("fingerprint", | |
| 907 base::android::BuildInfo::GetInstance()->android_build_fp()); | |
|
Ilya Sherman
2012/10/01 23:01:38
I don't recommend trying to add this field to the
gone
2012/10/02 23:45:10
Removed.
| |
| 908 #endif | |
| 909 } | |
| 910 | |
| 897 void MetricsLog::RecordOmniboxOpenedURL(const AutocompleteLog& log) { | 911 void MetricsLog::RecordOmniboxOpenedURL(const AutocompleteLog& log) { |
| 898 DCHECK(!locked()); | 912 DCHECK(!locked()); |
| 899 | 913 |
| 900 // Write the XML version. | 914 // Write the XML version. |
| 901 OPEN_ELEMENT_FOR_SCOPE("uielement"); | 915 OPEN_ELEMENT_FOR_SCOPE("uielement"); |
| 902 WriteAttribute("action", "autocomplete"); | 916 WriteAttribute("action", "autocomplete"); |
| 903 WriteAttribute("targetidhash", ""); | 917 WriteAttribute("targetidhash", ""); |
| 904 // TODO(kochi): Properly track windows. | 918 // TODO(kochi): Properly track windows. |
| 905 WriteIntAttribute("window", 0); | 919 WriteIntAttribute("window", 0); |
| 906 if (log.tab_id != -1) { | 920 if (log.tab_id != -1) { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1007 ProductDataToProto(google_update_metrics.google_update_data, | 1021 ProductDataToProto(google_update_metrics.google_update_data, |
| 1008 google_update->mutable_google_update_status()); | 1022 google_update->mutable_google_update_status()); |
| 1009 } | 1023 } |
| 1010 | 1024 |
| 1011 if (!google_update_metrics.product_data.version.empty()) { | 1025 if (!google_update_metrics.product_data.version.empty()) { |
| 1012 ProductDataToProto(google_update_metrics.product_data, | 1026 ProductDataToProto(google_update_metrics.product_data, |
| 1013 google_update->mutable_client_status()); | 1027 google_update->mutable_client_status()); |
| 1014 } | 1028 } |
| 1015 #endif // defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN) | 1029 #endif // defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN) |
| 1016 } | 1030 } |
| OLD | NEW |