OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/lazy_instance.h" |
12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
13 #include "base/perftimer.h" | 14 #include "base/perftimer.h" |
14 #include "base/string_util.h" | 15 #include "base/string_util.h" |
15 #include "base/sys_info.h" | 16 #include "base/sys_info.h" |
16 #include "base/third_party/nspr/prtime.h" | 17 #include "base/third_party/nspr/prtime.h" |
17 #include "base/time.h" | 18 #include "base/time.h" |
18 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
19 #include "chrome/browser/autocomplete/autocomplete.h" | 20 #include "chrome/browser/autocomplete/autocomplete.h" |
20 #include "chrome/browser/autocomplete/autocomplete_match.h" | 21 #include "chrome/browser/autocomplete/autocomplete_match.h" |
21 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
22 #include "chrome/browser/plugin_prefs.h" | 23 #include "chrome/browser/plugin_prefs.h" |
23 #include "chrome/browser/prefs/pref_service.h" | 24 #include "chrome/browser/prefs/pref_service.h" |
24 #include "chrome/browser/profiles/profile_manager.h" | 25 #include "chrome/browser/profiles/profile_manager.h" |
25 #include "chrome/common/chrome_version_info.h" | 26 #include "chrome/common/chrome_version_info.h" |
26 #include "chrome/common/logging_chrome.h" | 27 #include "chrome/common/logging_chrome.h" |
27 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
28 #include "content/browser/gpu/gpu_data_manager.h" | 29 #include "content/browser/gpu/gpu_data_manager.h" |
29 #include "googleurl/src/gurl.h" | 30 #include "googleurl/src/gurl.h" |
30 #include "ui/gfx/screen.h" | 31 #include "ui/gfx/screen.h" |
31 #include "webkit/plugins/webplugininfo.h" | 32 #include "webkit/plugins/webplugininfo.h" |
32 | 33 |
33 #define OPEN_ELEMENT_FOR_SCOPE(name) ScopedElement scoped_element(this, name) | 34 #define OPEN_ELEMENT_FOR_SCOPE(name) ScopedElement scoped_element(this, name) |
34 | 35 |
35 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx | 36 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx |
36 #if defined(OS_WIN) | 37 #if defined(OS_WIN) |
37 extern "C" IMAGE_DOS_HEADER __ImageBase; | 38 extern "C" IMAGE_DOS_HEADER __ImageBase; |
38 #endif | 39 #endif |
39 | 40 |
| 41 static base::LazyInstance<std::string, |
| 42 base::LeakyLazyInstanceTraits<std::string > > |
| 43 g_version_extension = LAZY_INSTANCE_INITIALIZER; |
| 44 |
40 MetricsLog::MetricsLog(const std::string& client_id, int session_id) | 45 MetricsLog::MetricsLog(const std::string& client_id, int session_id) |
41 : MetricsLogBase(client_id, session_id, MetricsLog::GetVersionString()) {} | 46 : MetricsLogBase(client_id, session_id, MetricsLog::GetVersionString()) {} |
42 | 47 |
43 MetricsLog::~MetricsLog() {} | 48 MetricsLog::~MetricsLog() {} |
44 | 49 |
45 // static | 50 // static |
46 void MetricsLog::RegisterPrefs(PrefService* local_state) { | 51 void MetricsLog::RegisterPrefs(PrefService* local_state) { |
47 local_state->RegisterListPref(prefs::kStabilityPluginStats); | 52 local_state->RegisterListPref(prefs::kStabilityPluginStats); |
48 } | 53 } |
49 | 54 |
(...skipping 24 matching lines...) Expand all Loading... |
74 | 79 |
75 // static | 80 // static |
76 std::string MetricsLog::GetVersionString() { | 81 std::string MetricsLog::GetVersionString() { |
77 chrome::VersionInfo version_info; | 82 chrome::VersionInfo version_info; |
78 if (!version_info.is_valid()) { | 83 if (!version_info.is_valid()) { |
79 NOTREACHED() << "Unable to retrieve version info."; | 84 NOTREACHED() << "Unable to retrieve version info."; |
80 return std::string(); | 85 return std::string(); |
81 } | 86 } |
82 | 87 |
83 std::string version = version_info.Version(); | 88 std::string version = version_info.Version(); |
84 if (!version_extension_.empty()) | 89 if (!version_extension().empty()) |
85 version += version_extension_; | 90 version += version_extension(); |
86 if (!version_info.IsOfficialBuild()) | 91 if (!version_info.IsOfficialBuild()) |
87 version.append("-devel"); | 92 version.append("-devel"); |
88 return version; | 93 return version; |
89 } | 94 } |
90 | 95 |
91 MetricsLog* MetricsLog::AsMetricsLog() { | 96 MetricsLog* MetricsLog::AsMetricsLog() { |
92 return this; | 97 return this; |
93 } | 98 } |
94 | 99 |
| 100 // static |
| 101 void MetricsLog::set_version_extension(const std::string& extension) { |
| 102 g_version_extension.Get() = extension; |
| 103 } |
| 104 |
| 105 // static |
| 106 const std::string& MetricsLog::version_extension() { |
| 107 return g_version_extension.Get(); |
| 108 } |
| 109 |
95 void MetricsLog::RecordIncrementalStabilityElements() { | 110 void MetricsLog::RecordIncrementalStabilityElements() { |
96 DCHECK(!locked_); | 111 DCHECK(!locked_); |
97 | 112 |
98 PrefService* pref = g_browser_process->local_state(); | 113 PrefService* pref = g_browser_process->local_state(); |
99 DCHECK(pref); | 114 DCHECK(pref); |
100 | 115 |
101 OPEN_ELEMENT_FOR_SCOPE("profile"); | 116 OPEN_ELEMENT_FOR_SCOPE("profile"); |
102 WriteCommonEventAttributes(); | 117 WriteCommonEventAttributes(); |
103 | 118 |
104 WriteInstallElement(); | 119 WriteInstallElement(); |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 const std::string result_type(AutocompleteMatch::TypeToString(i->type)); | 508 const std::string result_type(AutocompleteMatch::TypeToString(i->type)); |
494 if (!result_type.empty()) | 509 if (!result_type.empty()) |
495 WriteAttribute("resulttype", result_type); | 510 WriteAttribute("resulttype", result_type); |
496 WriteIntAttribute("relevance", i->relevance); | 511 WriteIntAttribute("relevance", i->relevance); |
497 WriteIntAttribute("isstarred", i->starred ? 1 : 0); | 512 WriteIntAttribute("isstarred", i->starred ? 1 : 0); |
498 } | 513 } |
499 } | 514 } |
500 | 515 |
501 ++num_events_; | 516 ++num_events_; |
502 } | 517 } |
OLD | NEW |