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