blob: 4b0db68515d0003af981b1040265b436c0fe61c5 [file] [log] [blame]
[email protected]85ed9d42010-06-08 22:37:441// Copyright (c) 2010 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
[email protected]cd1adc22009-01-16 01:29:225#include "chrome/browser/metrics/metrics_log.h"
initial.commit09911bf2008-07-26 23:55:296
[email protected]1eeb5e02010-07-20 23:02:117#include <string>
8#include <vector>
9
[email protected]d1be67b2008-11-19 20:28:3810#include "base/basictypes.h"
initial.commit09911bf2008-07-26 23:55:2911#include "base/file_util.h"
12#include "base/file_version_info.h"
[email protected]85ed9d42010-06-08 22:37:4413#include "base/perftimer.h"
initial.commit09911bf2008-07-26 23:55:2914#include "base/scoped_ptr.h"
15#include "base/string_util.h"
[email protected]fadf97f2008-09-18 12:18:1416#include "base/sys_info.h"
[email protected]37f39e42010-01-06 17:35:1717#include "base/third_party/nspr/prtime.h"
[email protected]1eeb5e02010-07-20 23:02:1118#include "base/time.h"
19#include "base/utf_string_conversions.h"
initial.commit09911bf2008-07-26 23:55:2920#include "chrome/browser/autocomplete/autocomplete.h"
21#include "chrome/browser/browser_process.h"
[email protected]e8c287c872010-07-20 00:49:4222#include "chrome/browser/gpu_process_host.h"
[email protected]052313b2010-02-19 09:43:0823#include "chrome/browser/pref_service.h"
[email protected]1eeb5e02010-07-20 23:02:1124#include "chrome/common/chrome_version_info.h"
initial.commit09911bf2008-07-26 23:55:2925#include "chrome/common/logging_chrome.h"
26#include "chrome/common/pref_names.h"
[email protected]46072d42008-07-28 14:49:3527#include "googleurl/src/gurl.h"
initial.commit09911bf2008-07-26 23:55:2928
29#define OPEN_ELEMENT_FOR_SCOPE(name) ScopedElement scoped_element(this, name)
30
[email protected]d1be67b2008-11-19 20:28:3831// http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx
32#if defined(OS_WIN)
33extern "C" IMAGE_DOS_HEADER __ImageBase;
34#endif
35
[email protected]1226abb2010-06-10 18:01:2836MetricsLog::MetricsLog(const std::string& client_id, int session_id)
37 : MetricsLogBase(client_id, session_id, MetricsLog::GetVersionString()) {}
[email protected]5ed7d4572009-12-23 17:42:4138
[email protected]1226abb2010-06-10 18:01:2839MetricsLog::~MetricsLog() {}
initial.commit09911bf2008-07-26 23:55:2940
41// static
42void MetricsLog::RegisterPrefs(PrefService* local_state) {
43 local_state->RegisterListPref(prefs::kStabilityPluginStats);
initial.commit09911bf2008-07-26 23:55:2944}
45
[email protected]9165f742010-03-10 22:55:0146int64 MetricsLog::GetIncrementalUptime(PrefService* pref) {
47 base::TimeTicks now = base::TimeTicks::Now();
48 static base::TimeTicks last_updated_time(now);
49 int64 incremental_time = (now - last_updated_time).InSeconds();
50 last_updated_time = now;
51
52 if (incremental_time > 0) {
53 int64 metrics_uptime = pref->GetInt64(prefs::kUninstallMetricsUptimeSec);
54 metrics_uptime += incremental_time;
55 pref->SetInt64(prefs::kUninstallMetricsUptimeSec, metrics_uptime);
56 }
57
58 return incremental_time;
59}
60
initial.commit09911bf2008-07-26 23:55:2961std::string MetricsLog::GetInstallDate() const {
62 PrefService* pref = g_browser_process->local_state();
63 if (pref) {
[email protected]ddd231e2010-06-29 20:35:1964 return pref->GetString(prefs::kMetricsClientIDTimestamp);
initial.commit09911bf2008-07-26 23:55:2965 } else {
66 NOTREACHED();
67 return "0";
68 }
69}
70
[email protected]1226abb2010-06-10 18:01:2871// static
72std::string MetricsLog::GetVersionString() {
73 scoped_ptr<FileVersionInfo> version_info(
[email protected]1eeb5e02010-07-20 23:02:1174 chrome::GetChromeVersionInfo());
[email protected]1226abb2010-06-10 18:01:2875 if (version_info.get()) {
76 std::string version = WideToUTF8(version_info->product_version());
77 if (!version_extension_.empty())
78 version += version_extension_;
79 if (!version_info->is_official_build())
80 version.append("-devel");
81 return version;
82 } else {
83 NOTREACHED() << "Unable to retrieve version string.";
84 }
85
86 return std::string();
87}
88
[email protected]0b33f80b2008-12-17 21:34:3689void MetricsLog::RecordIncrementalStabilityElements() {
90 DCHECK(!locked_);
91
92 PrefService* pref = g_browser_process->local_state();
93 DCHECK(pref);
94
[email protected]147bbc0b2009-01-06 19:37:4095 OPEN_ELEMENT_FOR_SCOPE("profile");
96 WriteCommonEventAttributes();
97
98 WriteInstallElement(); // Supply appversion.
99
100 {
101 OPEN_ELEMENT_FOR_SCOPE("stability"); // Minimal set of stability elements.
102 WriteRequiredStabilityAttributes(pref);
103 WriteRealtimeStabilityAttributes(pref);
104
105 WritePluginStabilityElements(pref);
106 }
[email protected]0b33f80b2008-12-17 21:34:36107}
108
initial.commit09911bf2008-07-26 23:55:29109void MetricsLog::WriteStabilityElement() {
110 DCHECK(!locked_);
111
112 PrefService* pref = g_browser_process->local_state();
113 DCHECK(pref);
114
115 // Get stability attributes out of Local State, zeroing out stored values.
116 // NOTE: This could lead to some data loss if this report isn't successfully
117 // sent, but that's true for all the metrics.
118
[email protected]ffaf78a2008-11-12 17:38:33119 OPEN_ELEMENT_FOR_SCOPE("stability");
[email protected]147bbc0b2009-01-06 19:37:40120 WriteRequiredStabilityAttributes(pref);
121 WriteRealtimeStabilityAttributes(pref);
initial.commit09911bf2008-07-26 23:55:29122
[email protected]0b33f80b2008-12-17 21:34:36123 // TODO(jar): The following are all optional, so we *could* optimize them for
124 // values of zero (and not include them).
[email protected]8e674e42008-07-30 16:05:48125 WriteIntAttribute("incompleteshutdowncount",
126 pref->GetInteger(
127 prefs::kStabilityIncompleteSessionEndCount));
128 pref->SetInteger(prefs::kStabilityIncompleteSessionEndCount, 0);
[email protected]0b33f80b2008-12-17 21:34:36129
130
[email protected]e73c01972008-08-13 00:18:24131 WriteIntAttribute("breakpadregistrationok",
132 pref->GetInteger(prefs::kStabilityBreakpadRegistrationSuccess));
133 pref->SetInteger(prefs::kStabilityBreakpadRegistrationSuccess, 0);
134 WriteIntAttribute("breakpadregistrationfail",
135 pref->GetInteger(prefs::kStabilityBreakpadRegistrationFail));
136 pref->SetInteger(prefs::kStabilityBreakpadRegistrationFail, 0);
137 WriteIntAttribute("debuggerpresent",
138 pref->GetInteger(prefs::kStabilityDebuggerPresent));
139 pref->SetInteger(prefs::kStabilityDebuggerPresent, 0);
140 WriteIntAttribute("debuggernotpresent",
141 pref->GetInteger(prefs::kStabilityDebuggerNotPresent));
142 pref->SetInteger(prefs::kStabilityDebuggerNotPresent, 0);
initial.commit09911bf2008-07-26 23:55:29143
[email protected]147bbc0b2009-01-06 19:37:40144 WritePluginStabilityElements(pref);
145}
146
147void MetricsLog::WritePluginStabilityElements(PrefService* pref) {
148 // Now log plugin stability info.
initial.commit09911bf2008-07-26 23:55:29149 const ListValue* plugin_stats_list = pref->GetList(
150 prefs::kStabilityPluginStats);
151 if (plugin_stats_list) {
[email protected]ffaf78a2008-11-12 17:38:33152 OPEN_ELEMENT_FOR_SCOPE("plugins");
initial.commit09911bf2008-07-26 23:55:29153 for (ListValue::const_iterator iter = plugin_stats_list->begin();
154 iter != plugin_stats_list->end(); ++iter) {
155 if (!(*iter)->IsType(Value::TYPE_DICTIONARY)) {
156 NOTREACHED();
157 continue;
158 }
159 DictionaryValue* plugin_dict = static_cast<DictionaryValue*>(*iter);
160
[email protected]57ecc4b2010-08-11 03:02:51161 std::string plugin_name;
[email protected]8e50b602009-03-03 22:59:43162 plugin_dict->GetString(prefs::kStabilityPluginName, &plugin_name);
initial.commit09911bf2008-07-26 23:55:29163
[email protected]ffaf78a2008-11-12 17:38:33164 OPEN_ELEMENT_FOR_SCOPE("pluginstability");
[email protected]a27a9382009-02-11 23:55:10165 // Use "filename" instead of "name", otherwise we need to update the
166 // UMA servers.
[email protected]57ecc4b2010-08-11 03:02:51167 WriteAttribute("filename", CreateBase64Hash(plugin_name));
initial.commit09911bf2008-07-26 23:55:29168
169 int launches = 0;
[email protected]8e50b602009-03-03 22:59:43170 plugin_dict->GetInteger(prefs::kStabilityPluginLaunches, &launches);
initial.commit09911bf2008-07-26 23:55:29171 WriteIntAttribute("launchcount", launches);
172
173 int instances = 0;
[email protected]8e50b602009-03-03 22:59:43174 plugin_dict->GetInteger(prefs::kStabilityPluginInstances, &instances);
initial.commit09911bf2008-07-26 23:55:29175 WriteIntAttribute("instancecount", instances);
176
177 int crashes = 0;
[email protected]8e50b602009-03-03 22:59:43178 plugin_dict->GetInteger(prefs::kStabilityPluginCrashes, &crashes);
initial.commit09911bf2008-07-26 23:55:29179 WriteIntAttribute("crashcount", crashes);
initial.commit09911bf2008-07-26 23:55:29180 }
181
182 pref->ClearPref(prefs::kStabilityPluginStats);
initial.commit09911bf2008-07-26 23:55:29183 }
initial.commit09911bf2008-07-26 23:55:29184}
185
[email protected]147bbc0b2009-01-06 19:37:40186void MetricsLog::WriteRequiredStabilityAttributes(PrefService* pref) {
[email protected]0b33f80b2008-12-17 21:34:36187 // The server refuses data that doesn't have certain values. crashcount and
188 // launchcount are currently "required" in the "stability" group.
189 WriteIntAttribute("launchcount",
190 pref->GetInteger(prefs::kStabilityLaunchCount));
191 pref->SetInteger(prefs::kStabilityLaunchCount, 0);
192 WriteIntAttribute("crashcount",
193 pref->GetInteger(prefs::kStabilityCrashCount));
194 pref->SetInteger(prefs::kStabilityCrashCount, 0);
195}
196
[email protected]147bbc0b2009-01-06 19:37:40197void MetricsLog::WriteRealtimeStabilityAttributes(PrefService* pref) {
[email protected]0b33f80b2008-12-17 21:34:36198 // Update the stats which are critical for real-time stability monitoring.
199 // Since these are "optional," only list ones that are non-zero, as the counts
200 // are aggergated (summed) server side.
201
202 int count = pref->GetInteger(prefs::kStabilityPageLoadCount);
203 if (count) {
204 WriteIntAttribute("pageloadcount", count);
205 pref->SetInteger(prefs::kStabilityPageLoadCount, 0);
206 }
207
208 count = pref->GetInteger(prefs::kStabilityRendererCrashCount);
209 if (count) {
210 WriteIntAttribute("renderercrashcount", count);
211 pref->SetInteger(prefs::kStabilityRendererCrashCount, 0);
212 }
213
[email protected]1f085622009-12-04 05:33:45214 count = pref->GetInteger(prefs::kStabilityExtensionRendererCrashCount);
215 if (count) {
216 WriteIntAttribute("extensionrenderercrashcount", count);
217 pref->SetInteger(prefs::kStabilityExtensionRendererCrashCount, 0);
218 }
219
[email protected]0b33f80b2008-12-17 21:34:36220 count = pref->GetInteger(prefs::kStabilityRendererHangCount);
221 if (count) {
222 WriteIntAttribute("rendererhangcount", count);
223 pref->SetInteger(prefs::kStabilityRendererHangCount, 0);
224 }
[email protected]1f085622009-12-04 05:33:45225
226 count = pref->GetInteger(prefs::kStabilityChildProcessCrashCount);
227 if (count) {
228 WriteIntAttribute("childprocesscrashcount", count);
229 pref->SetInteger(prefs::kStabilityChildProcessCrashCount, 0);
230 }
[email protected]9165f742010-03-10 22:55:01231
232 int64 recent_duration = GetIncrementalUptime(pref);
233 if (recent_duration)
234 WriteInt64Attribute("uptimesec", recent_duration);
[email protected]0b33f80b2008-12-17 21:34:36235}
236
initial.commit09911bf2008-07-26 23:55:29237void MetricsLog::WritePluginList(
238 const std::vector<WebPluginInfo>& plugin_list) {
239 DCHECK(!locked_);
240
[email protected]ffaf78a2008-11-12 17:38:33241 OPEN_ELEMENT_FOR_SCOPE("plugins");
initial.commit09911bf2008-07-26 23:55:29242
243 for (std::vector<WebPluginInfo>::const_iterator iter = plugin_list.begin();
244 iter != plugin_list.end(); ++iter) {
[email protected]ffaf78a2008-11-12 17:38:33245 OPEN_ELEMENT_FOR_SCOPE("plugin");
initial.commit09911bf2008-07-26 23:55:29246
247 // Plugin name and filename are hashed for the privacy of those
248 // testing unreleased new extensions.
[email protected]c9d811372010-06-23 21:44:57249 WriteAttribute("name", CreateBase64Hash(UTF16ToUTF8(iter->name)));
[email protected]046344c2009-01-13 00:54:21250 WriteAttribute("filename",
251 CreateBase64Hash(WideToUTF8(iter->path.BaseName().ToWStringHack())));
[email protected]c9d811372010-06-23 21:44:57252 WriteAttribute("version", UTF16ToUTF8(iter->version));
initial.commit09911bf2008-07-26 23:55:29253 }
initial.commit09911bf2008-07-26 23:55:29254}
255
[email protected]147bbc0b2009-01-06 19:37:40256void MetricsLog::WriteInstallElement() {
257 OPEN_ELEMENT_FOR_SCOPE("install");
258 WriteAttribute("installdate", GetInstallDate());
259 WriteIntAttribute("buildid", 0); // We're using appversion instead.
[email protected]147bbc0b2009-01-06 19:37:40260}
261
initial.commit09911bf2008-07-26 23:55:29262void MetricsLog::RecordEnvironment(
263 const std::vector<WebPluginInfo>& plugin_list,
264 const DictionaryValue* profile_metrics) {
265 DCHECK(!locked_);
266
267 PrefService* pref = g_browser_process->local_state();
268
[email protected]ffaf78a2008-11-12 17:38:33269 OPEN_ELEMENT_FOR_SCOPE("profile");
initial.commit09911bf2008-07-26 23:55:29270 WriteCommonEventAttributes();
271
[email protected]147bbc0b2009-01-06 19:37:40272 WriteInstallElement();
initial.commit09911bf2008-07-26 23:55:29273
274 WritePluginList(plugin_list);
275
276 WriteStabilityElement();
277
278 {
279 OPEN_ELEMENT_FOR_SCOPE("cpu");
[email protected]05f9b682008-09-29 22:18:01280 WriteAttribute("arch", base::SysInfo::CPUArchitecture());
initial.commit09911bf2008-07-26 23:55:29281 }
282
283 {
initial.commit09911bf2008-07-26 23:55:29284 OPEN_ELEMENT_FOR_SCOPE("memory");
[email protected]ed6fc352008-09-18 12:44:40285 WriteIntAttribute("mb", base::SysInfo::AmountOfPhysicalMemoryMB());
[email protected]d1be67b2008-11-19 20:28:38286#if defined(OS_WIN)
287 WriteIntAttribute("dllbase", reinterpret_cast<int>(&__ImageBase));
288#endif
initial.commit09911bf2008-07-26 23:55:29289 }
290
291 {
292 OPEN_ELEMENT_FOR_SCOPE("os");
293 WriteAttribute("name",
[email protected]05f9b682008-09-29 22:18:01294 base::SysInfo::OperatingSystemName());
initial.commit09911bf2008-07-26 23:55:29295 WriteAttribute("version",
[email protected]05f9b682008-09-29 22:18:01296 base::SysInfo::OperatingSystemVersion());
initial.commit09911bf2008-07-26 23:55:29297 }
298
299 {
[email protected]e8c287c872010-07-20 00:49:42300 OPEN_ELEMENT_FOR_SCOPE("gpu");
301 WriteIntAttribute("vendorid",
302 GpuProcessHost::Get()->gpu_info().vendor_id());
303 WriteIntAttribute("deviceid",
304 GpuProcessHost::Get()->gpu_info().device_id());
305 }
306
307 {
initial.commit09911bf2008-07-26 23:55:29308 OPEN_ELEMENT_FOR_SCOPE("display");
309 int width = 0;
310 int height = 0;
[email protected]05f9b682008-09-29 22:18:01311 base::SysInfo::GetPrimaryDisplayDimensions(&width, &height);
initial.commit09911bf2008-07-26 23:55:29312 WriteIntAttribute("xsize", width);
313 WriteIntAttribute("ysize", height);
[email protected]05f9b682008-09-29 22:18:01314 WriteIntAttribute("screens", base::SysInfo::DisplayCount());
initial.commit09911bf2008-07-26 23:55:29315 }
316
317 {
318 OPEN_ELEMENT_FOR_SCOPE("bookmarks");
319 int num_bookmarks_on_bookmark_bar =
320 pref->GetInteger(prefs::kNumBookmarksOnBookmarkBar);
321 int num_folders_on_bookmark_bar =
322 pref->GetInteger(prefs::kNumFoldersOnBookmarkBar);
323 int num_bookmarks_in_other_bookmarks_folder =
324 pref->GetInteger(prefs::kNumBookmarksInOtherBookmarkFolder);
325 int num_folders_in_other_bookmarks_folder =
326 pref->GetInteger(prefs::kNumFoldersInOtherBookmarkFolder);
327 {
328 OPEN_ELEMENT_FOR_SCOPE("bookmarklocation");
329 WriteAttribute("name", "full-tree");
330 WriteIntAttribute("foldercount",
331 num_folders_on_bookmark_bar + num_folders_in_other_bookmarks_folder);
332 WriteIntAttribute("itemcount",
333 num_bookmarks_on_bookmark_bar +
334 num_bookmarks_in_other_bookmarks_folder);
335 }
336 {
337 OPEN_ELEMENT_FOR_SCOPE("bookmarklocation");
338 WriteAttribute("name", "toolbar");
339 WriteIntAttribute("foldercount", num_folders_on_bookmark_bar);
340 WriteIntAttribute("itemcount", num_bookmarks_on_bookmark_bar);
341 }
342 }
343
344 {
345 OPEN_ELEMENT_FOR_SCOPE("keywords");
346 WriteIntAttribute("count", pref->GetInteger(prefs::kNumKeywords));
347 }
348
349 if (profile_metrics)
350 WriteAllProfilesMetrics(*profile_metrics);
initial.commit09911bf2008-07-26 23:55:29351}
352
353void MetricsLog::WriteAllProfilesMetrics(
354 const DictionaryValue& all_profiles_metrics) {
[email protected]57ecc4b2010-08-11 03:02:51355 const std::string profile_prefix(prefs::kProfilePrefix);
initial.commit09911bf2008-07-26 23:55:29356 for (DictionaryValue::key_iterator i = all_profiles_metrics.begin_keys();
357 i != all_profiles_metrics.end_keys(); ++i) {
[email protected]e7b418b2010-07-30 19:47:47358 const std::string& key_name = *i;
initial.commit09911bf2008-07-26 23:55:29359 if (key_name.compare(0, profile_prefix.size(), profile_prefix) == 0) {
360 DictionaryValue* profile;
[email protected]4dad9ad82009-11-25 20:47:52361 if (all_profiles_metrics.GetDictionaryWithoutPathExpansion(key_name,
362 &profile))
initial.commit09911bf2008-07-26 23:55:29363 WriteProfileMetrics(key_name.substr(profile_prefix.size()), *profile);
364 }
365 }
366}
367
[email protected]e7b418b2010-07-30 19:47:47368void MetricsLog::WriteProfileMetrics(const std::string& profileidhash,
initial.commit09911bf2008-07-26 23:55:29369 const DictionaryValue& profile_metrics) {
370 OPEN_ELEMENT_FOR_SCOPE("userprofile");
[email protected]e7b418b2010-07-30 19:47:47371 WriteAttribute("profileidhash", profileidhash);
initial.commit09911bf2008-07-26 23:55:29372 for (DictionaryValue::key_iterator i = profile_metrics.begin_keys();
373 i != profile_metrics.end_keys(); ++i) {
374 Value* value;
[email protected]4dad9ad82009-11-25 20:47:52375 if (profile_metrics.GetWithoutPathExpansion(*i, &value)) {
[email protected]e7b418b2010-07-30 19:47:47376 DCHECK(*i != "id");
initial.commit09911bf2008-07-26 23:55:29377 switch (value->GetType()) {
378 case Value::TYPE_STRING: {
[email protected]5e324b72008-12-18 00:07:59379 std::string string_value;
initial.commit09911bf2008-07-26 23:55:29380 if (value->GetAsString(&string_value)) {
381 OPEN_ELEMENT_FOR_SCOPE("profileparam");
[email protected]e7b418b2010-07-30 19:47:47382 WriteAttribute("name", *i);
[email protected]5e324b72008-12-18 00:07:59383 WriteAttribute("value", string_value);
initial.commit09911bf2008-07-26 23:55:29384 }
385 break;
386 }
387
388 case Value::TYPE_BOOLEAN: {
389 bool bool_value;
390 if (value->GetAsBoolean(&bool_value)) {
391 OPEN_ELEMENT_FOR_SCOPE("profileparam");
[email protected]e7b418b2010-07-30 19:47:47392 WriteAttribute("name", *i);
initial.commit09911bf2008-07-26 23:55:29393 WriteIntAttribute("value", bool_value ? 1 : 0);
394 }
395 break;
396 }
397
398 case Value::TYPE_INTEGER: {
399 int int_value;
400 if (value->GetAsInteger(&int_value)) {
401 OPEN_ELEMENT_FOR_SCOPE("profileparam");
[email protected]e7b418b2010-07-30 19:47:47402 WriteAttribute("name", *i);
initial.commit09911bf2008-07-26 23:55:29403 WriteIntAttribute("value", int_value);
404 }
405 break;
406 }
407
408 default:
409 NOTREACHED();
410 break;
411 }
412 }
413 }
414}
415
416void MetricsLog::RecordOmniboxOpenedURL(const AutocompleteLog& log) {
417 DCHECK(!locked_);
418
[email protected]ffaf78a2008-11-12 17:38:33419 OPEN_ELEMENT_FOR_SCOPE("uielement");
initial.commit09911bf2008-07-26 23:55:29420 WriteAttribute("action", "autocomplete");
421 WriteAttribute("targetidhash", "");
422 // TODO(kochi): Properly track windows.
423 WriteIntAttribute("window", 0);
424 WriteCommonEventAttributes();
425
[email protected]ffaf78a2008-11-12 17:38:33426 {
427 OPEN_ELEMENT_FOR_SCOPE("autocomplete");
initial.commit09911bf2008-07-26 23:55:29428
[email protected]ffaf78a2008-11-12 17:38:33429 WriteIntAttribute("typedlength", static_cast<int>(log.text.length()));
430 WriteIntAttribute("selectedindex", static_cast<int>(log.selected_index));
431 WriteIntAttribute("completedlength",
432 static_cast<int>(log.inline_autocompleted_length));
[email protected]381e2992008-12-16 01:41:00433 const std::string input_type(
434 AutocompleteInput::TypeToString(log.input_type));
435 if (!input_type.empty())
436 WriteAttribute("inputtype", input_type);
initial.commit09911bf2008-07-26 23:55:29437
[email protected]ffaf78a2008-11-12 17:38:33438 for (AutocompleteResult::const_iterator i(log.result.begin());
439 i != log.result.end(); ++i) {
440 OPEN_ELEMENT_FOR_SCOPE("autocompleteitem");
441 if (i->provider)
442 WriteAttribute("provider", i->provider->name());
[email protected]381e2992008-12-16 01:41:00443 const std::string result_type(AutocompleteMatch::TypeToString(i->type));
444 if (!result_type.empty())
445 WriteAttribute("resulttype", result_type);
[email protected]ffaf78a2008-11-12 17:38:33446 WriteIntAttribute("relevance", i->relevance);
447 WriteIntAttribute("isstarred", i->starred ? 1 : 0);
448 }
initial.commit09911bf2008-07-26 23:55:29449 }
initial.commit09911bf2008-07-26 23:55:29450
451 ++num_events_;
452}