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 19 matching lines...) Expand all Loading... | |
30 #include "chrome/browser/autocomplete/autocomplete_provider.h" | 30 #include "chrome/browser/autocomplete/autocomplete_provider.h" |
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/logging_chrome.h" | 39 #include "chrome/common/logging_chrome.h" |
40 #include "chrome/common/metrics/proto/omnibox_event.pb.h" | |
41 #include "chrome/common/metrics/proto/profiler_event.pb.h" | |
42 #include "chrome/common/metrics/proto/system_profile.pb.h" | |
43 #include "chrome/common/metrics/variations/variations_util.h" | 40 #include "chrome/common/metrics/variations/variations_util.h" |
44 #include "chrome/common/pref_names.h" | 41 #include "chrome/common/pref_names.h" |
45 #include "chrome/installer/util/google_update_settings.h" | 42 #include "chrome/installer/util/google_update_settings.h" |
43 #include "components/metrics/proto/omnibox_event.pb.h" | |
44 #include "components/metrics/proto/profiler_event.pb.h" | |
45 #include "components/metrics/proto/system_profile.pb.h" | |
46 #include "components/nacl/common/nacl_process_type.h" | 46 #include "components/nacl/common/nacl_process_type.h" |
47 #include "content/public/browser/gpu_data_manager.h" | 47 #include "content/public/browser/gpu_data_manager.h" |
48 #include "content/public/common/content_client.h" | 48 #include "content/public/common/content_client.h" |
49 #include "content/public/common/webplugininfo.h" | 49 #include "content/public/common/webplugininfo.h" |
50 #include "gpu/config/gpu_info.h" | 50 #include "gpu/config/gpu_info.h" |
51 #include "ui/gfx/screen.h" | 51 #include "ui/gfx/screen.h" |
52 #include "url/gurl.h" | 52 #include "url/gurl.h" |
53 | 53 |
54 #if defined(OS_ANDROID) | 54 #if defined(OS_ANDROID) |
55 #include "base/android/build_info.h" | 55 #include "base/android/build_info.h" |
56 #endif | 56 #endif |
57 | 57 |
58 #if defined(OS_WIN) | 58 #if defined(OS_WIN) |
59 #include "base/win/metro.h" | 59 #include "base/win/metro.h" |
60 | 60 |
61 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx | 61 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx |
62 extern "C" IMAGE_DOS_HEADER __ImageBase; | 62 extern "C" IMAGE_DOS_HEADER __ImageBase; |
63 #endif | 63 #endif |
64 | 64 |
65 #if defined(OS_CHROMEOS) | 65 #if defined(OS_CHROMEOS) |
66 #include "chrome/browser/metrics/metrics_log_chromeos.h" | 66 #include "chrome/browser/metrics/metrics_log_chromeos.h" |
67 #endif // OS_CHROMEOS | 67 #endif // OS_CHROMEOS |
68 | 68 |
69 using content::GpuDataManager; | 69 using content::GpuDataManager; |
70 using metrics::OmniboxEventProto; | 70 using metrics::OmniboxEventProto; |
71 using metrics::ProfilerEventProto; | 71 using metrics::ProfilerEventProto; |
72 using metrics::SystemProfileProto; | 72 using metrics::SystemProfileProto; |
73 using metrics::MetricsLogBase; | |
Ilya Sherman
2014/04/15 23:00:40
nit: Alphabetize, please.
| |
73 using tracked_objects::ProcessDataSnapshot; | 74 using tracked_objects::ProcessDataSnapshot; |
74 typedef chrome_variations::ActiveGroupId ActiveGroupId; | 75 typedef chrome_variations::ActiveGroupId ActiveGroupId; |
75 typedef SystemProfileProto::GoogleUpdate::ProductInfo ProductInfo; | 76 typedef SystemProfileProto::GoogleUpdate::ProductInfo ProductInfo; |
76 | 77 |
77 namespace { | 78 namespace { |
78 | 79 |
79 // Returns the date at which the current metrics client ID was created as | 80 // Returns the date at which the current metrics client ID was created as |
80 // a string containing seconds since the epoch, or "0" if none was found. | 81 // a string containing seconds since the epoch, or "0" if none was found. |
81 std::string GetMetricsEnabledDate(PrefService* pref) { | 82 std::string GetMetricsEnabledDate(PrefService* pref) { |
82 if (!pref) { | 83 if (!pref) { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 case PROCESS_TYPE_NACL_LOADER: | 201 case PROCESS_TYPE_NACL_LOADER: |
201 return ProfilerEventProto::TrackedObject::NACL_LOADER; | 202 return ProfilerEventProto::TrackedObject::NACL_LOADER; |
202 case PROCESS_TYPE_NACL_BROKER: | 203 case PROCESS_TYPE_NACL_BROKER: |
203 return ProfilerEventProto::TrackedObject::NACL_BROKER; | 204 return ProfilerEventProto::TrackedObject::NACL_BROKER; |
204 default: | 205 default: |
205 NOTREACHED(); | 206 NOTREACHED(); |
206 return ProfilerEventProto::TrackedObject::UNKNOWN; | 207 return ProfilerEventProto::TrackedObject::UNKNOWN; |
207 } | 208 } |
208 } | 209 } |
209 | 210 |
211 SystemProfileProto::Channel AsProtobufChannel( | |
212 chrome::VersionInfo::Channel channel) { | |
213 switch (channel) { | |
214 case chrome::VersionInfo::CHANNEL_UNKNOWN: | |
215 return SystemProfileProto::CHANNEL_UNKNOWN; | |
216 case chrome::VersionInfo::CHANNEL_CANARY: | |
217 return SystemProfileProto::CHANNEL_CANARY; | |
218 case chrome::VersionInfo::CHANNEL_DEV: | |
219 return SystemProfileProto::CHANNEL_DEV; | |
220 case chrome::VersionInfo::CHANNEL_BETA: | |
221 return SystemProfileProto::CHANNEL_BETA; | |
222 case chrome::VersionInfo::CHANNEL_STABLE: | |
223 return SystemProfileProto::CHANNEL_STABLE; | |
224 default: | |
225 NOTREACHED(); | |
226 return SystemProfileProto::CHANNEL_UNKNOWN; | |
227 } | |
228 } | |
229 | |
210 // Computes a SHA-1 hash of |data| and returns it as a hex string. | 230 // Computes a SHA-1 hash of |data| and returns it as a hex string. |
211 std::string ComputeSHA1(const std::string& data) { | 231 std::string ComputeSHA1(const std::string& data) { |
212 const std::string sha1 = base::SHA1HashString(data); | 232 const std::string sha1 = base::SHA1HashString(data); |
213 return base::HexEncode(sha1.data(), sha1.size()); | 233 return base::HexEncode(sha1.data(), sha1.size()); |
214 } | 234 } |
215 | 235 |
216 #if defined(ENABLE_PLUGINS) | 236 #if defined(ENABLE_PLUGINS) |
217 // Returns the plugin preferences corresponding for this user, if available. | 237 // Returns the plugin preferences corresponding for this user, if available. |
218 // If multiple user profiles are loaded, returns the preferences corresponding | 238 // If multiple user profiles are loaded, returns the preferences corresponding |
219 // to an arbitrary one of the profiles. | 239 // to an arbitrary one of the profiles. |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
379 static base::LazyInstance<std::string>::Leaky | 399 static base::LazyInstance<std::string>::Leaky |
380 g_version_extension = LAZY_INSTANCE_INITIALIZER; | 400 g_version_extension = LAZY_INSTANCE_INITIALIZER; |
381 | 401 |
382 MetricsLog::MetricsLog(const std::string& client_id, | 402 MetricsLog::MetricsLog(const std::string& client_id, |
383 int session_id, | 403 int session_id, |
384 LogType log_type) | 404 LogType log_type) |
385 : MetricsLogBase(client_id, session_id, log_type, | 405 : MetricsLogBase(client_id, session_id, log_type, |
386 MetricsLog::GetVersionString()), | 406 MetricsLog::GetVersionString()), |
387 creation_time_(base::TimeTicks::Now()), | 407 creation_time_(base::TimeTicks::Now()), |
388 extension_metrics_(uma_proto()->client_id()) { | 408 extension_metrics_(uma_proto()->client_id()) { |
409 uma_proto()->mutable_system_profile()->set_channel( | |
410 AsProtobufChannel(chrome::VersionInfo::CHANNEL_STABLE)); | |
411 | |
389 #if defined(OS_CHROMEOS) | 412 #if defined(OS_CHROMEOS) |
390 metrics_log_chromeos_.reset(new MetricsLogChromeOS(uma_proto())); | 413 metrics_log_chromeos_.reset(new MetricsLogChromeOS(uma_proto())); |
391 #endif // OS_CHROMEOS | 414 #endif // OS_CHROMEOS |
392 } | 415 } |
393 | 416 |
394 MetricsLog::~MetricsLog() {} | 417 MetricsLog::~MetricsLog() {} |
395 | 418 |
396 // static | 419 // static |
397 void MetricsLog::RegisterPrefs(PrefRegistrySimple* registry) { | 420 void MetricsLog::RegisterPrefs(PrefRegistrySimple* registry) { |
398 registry->RegisterListPref(prefs::kStabilityPluginStats); | 421 registry->RegisterListPref(prefs::kStabilityPluginStats); |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
902 ProductDataToProto(google_update_metrics.google_update_data, | 925 ProductDataToProto(google_update_metrics.google_update_data, |
903 google_update->mutable_google_update_status()); | 926 google_update->mutable_google_update_status()); |
904 } | 927 } |
905 | 928 |
906 if (!google_update_metrics.product_data.version.empty()) { | 929 if (!google_update_metrics.product_data.version.empty()) { |
907 ProductDataToProto(google_update_metrics.product_data, | 930 ProductDataToProto(google_update_metrics.product_data, |
908 google_update->mutable_client_status()); | 931 google_update->mutable_client_status()); |
909 } | 932 } |
910 #endif // defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN) | 933 #endif // defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN) |
911 } | 934 } |
OLD | NEW |