OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/perftimer.h" | 12 #include "base/perftimer.h" |
13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
15 #include "base/sys_info.h" | 15 #include "base/sys_info.h" |
16 #include "base/third_party/nspr/prtime.h" | 16 #include "base/third_party/nspr/prtime.h" |
17 #include "base/time.h" | 17 #include "base/time.h" |
18 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
19 #include "chrome/browser/autocomplete/autocomplete.h" | 19 #include "chrome/browser/autocomplete/autocomplete.h" |
20 #include "chrome/browser/autocomplete/autocomplete_match.h" | 20 #include "chrome/browser/autocomplete/autocomplete_match.h" |
21 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
22 #include "chrome/browser/gpu_process_host_ui_shim.h" | 22 #include "chrome/browser/gpu_process_host_ui_shim.h" |
23 #include "chrome/browser/prefs/pref_service.h" | 23 #include "chrome/browser/prefs/pref_service.h" |
24 #include "chrome/common/chrome_version_info.h" | 24 #include "chrome/common/chrome_version_info.h" |
25 #include "chrome/common/logging_chrome.h" | 25 #include "chrome/common/logging_chrome.h" |
26 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
27 #include "googleurl/src/gurl.h" | 27 #include "googleurl/src/gurl.h" |
28 #include "webkit/plugins/npapi/webplugininfo.h" | |
29 | 28 |
30 #define OPEN_ELEMENT_FOR_SCOPE(name) ScopedElement scoped_element(this, name) | 29 #define OPEN_ELEMENT_FOR_SCOPE(name) ScopedElement scoped_element(this, name) |
31 | 30 |
32 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx | 31 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx |
33 #if defined(OS_WIN) | 32 #if defined(OS_WIN) |
34 extern "C" IMAGE_DOS_HEADER __ImageBase; | 33 extern "C" IMAGE_DOS_HEADER __ImageBase; |
35 #endif | 34 #endif |
36 | 35 |
37 MetricsLog::MetricsLog(const std::string& client_id, int session_id) | 36 MetricsLog::MetricsLog(const std::string& client_id, int session_id) |
38 : MetricsLogBase(client_id, session_id, MetricsLog::GetVersionString()) {} | 37 : MetricsLogBase(client_id, session_id, MetricsLog::GetVersionString()) {} |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 WriteIntAttribute("childprocesscrashcount", count); | 230 WriteIntAttribute("childprocesscrashcount", count); |
232 pref->SetInteger(prefs::kStabilityChildProcessCrashCount, 0); | 231 pref->SetInteger(prefs::kStabilityChildProcessCrashCount, 0); |
233 } | 232 } |
234 | 233 |
235 int64 recent_duration = GetIncrementalUptime(pref); | 234 int64 recent_duration = GetIncrementalUptime(pref); |
236 if (recent_duration) | 235 if (recent_duration) |
237 WriteInt64Attribute("uptimesec", recent_duration); | 236 WriteInt64Attribute("uptimesec", recent_duration); |
238 } | 237 } |
239 | 238 |
240 void MetricsLog::WritePluginList( | 239 void MetricsLog::WritePluginList( |
241 const std::vector<webkit::npapi::WebPluginInfo>& plugin_list) { | 240 const std::vector<WebPluginInfo>& plugin_list) { |
242 DCHECK(!locked_); | 241 DCHECK(!locked_); |
243 | 242 |
244 OPEN_ELEMENT_FOR_SCOPE("plugins"); | 243 OPEN_ELEMENT_FOR_SCOPE("plugins"); |
245 | 244 |
246 for (std::vector<webkit::npapi::WebPluginInfo>::const_iterator iter = | 245 for (std::vector<WebPluginInfo>::const_iterator iter = plugin_list.begin(); |
247 plugin_list.begin(); | |
248 iter != plugin_list.end(); ++iter) { | 246 iter != plugin_list.end(); ++iter) { |
249 OPEN_ELEMENT_FOR_SCOPE("plugin"); | 247 OPEN_ELEMENT_FOR_SCOPE("plugin"); |
250 | 248 |
251 // Plugin name and filename are hashed for the privacy of those | 249 // Plugin name and filename are hashed for the privacy of those |
252 // testing unreleased new extensions. | 250 // testing unreleased new extensions. |
253 WriteAttribute("name", CreateBase64Hash(UTF16ToUTF8(iter->name))); | 251 WriteAttribute("name", CreateBase64Hash(UTF16ToUTF8(iter->name))); |
254 WriteAttribute("filename", | 252 WriteAttribute("filename", |
255 CreateBase64Hash(WideToUTF8(iter->path.BaseName().ToWStringHack()))); | 253 CreateBase64Hash(WideToUTF8(iter->path.BaseName().ToWStringHack()))); |
256 WriteAttribute("version", UTF16ToUTF8(iter->version)); | 254 WriteAttribute("version", UTF16ToUTF8(iter->version)); |
257 } | 255 } |
258 } | 256 } |
259 | 257 |
260 void MetricsLog::WriteInstallElement() { | 258 void MetricsLog::WriteInstallElement() { |
261 OPEN_ELEMENT_FOR_SCOPE("install"); | 259 OPEN_ELEMENT_FOR_SCOPE("install"); |
262 WriteAttribute("installdate", GetInstallDate()); | 260 WriteAttribute("installdate", GetInstallDate()); |
263 WriteIntAttribute("buildid", 0); // We're using appversion instead. | 261 WriteIntAttribute("buildid", 0); // We're using appversion instead. |
264 } | 262 } |
265 | 263 |
266 void MetricsLog::RecordEnvironment( | 264 void MetricsLog::RecordEnvironment( |
267 const std::vector<webkit::npapi::WebPluginInfo>& plugin_list, | 265 const std::vector<WebPluginInfo>& plugin_list, |
268 const DictionaryValue* profile_metrics) { | 266 const DictionaryValue* profile_metrics) { |
269 DCHECK(!locked_); | 267 DCHECK(!locked_); |
270 | 268 |
271 PrefService* pref = g_browser_process->local_state(); | 269 PrefService* pref = g_browser_process->local_state(); |
272 | 270 |
273 OPEN_ELEMENT_FOR_SCOPE("profile"); | 271 OPEN_ELEMENT_FOR_SCOPE("profile"); |
274 WriteCommonEventAttributes(); | 272 WriteCommonEventAttributes(); |
275 | 273 |
276 WriteInstallElement(); | 274 WriteInstallElement(); |
277 | 275 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 const std::string result_type(AutocompleteMatch::TypeToString(i->type)); | 447 const std::string result_type(AutocompleteMatch::TypeToString(i->type)); |
450 if (!result_type.empty()) | 448 if (!result_type.empty()) |
451 WriteAttribute("resulttype", result_type); | 449 WriteAttribute("resulttype", result_type); |
452 WriteIntAttribute("relevance", i->relevance); | 450 WriteIntAttribute("relevance", i->relevance); |
453 WriteIntAttribute("isstarred", i->starred ? 1 : 0); | 451 WriteIntAttribute("isstarred", i->starred ? 1 : 0); |
454 } | 452 } |
455 } | 453 } |
456 | 454 |
457 ++num_events_; | 455 ++num_events_; |
458 } | 456 } |
OLD | NEW |