blob: 9b51cfad3eec92061d8454a8675914fa26764102 [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]978df342009-11-24 06:21:5310#include "base/base64.h"
[email protected]d1be67b2008-11-19 20:28:3811#include "base/basictypes.h"
initial.commit09911bf2008-07-26 23:55:2912#include "base/file_util.h"
13#include "base/file_version_info.h"
14#include "base/md5.h"
[email protected]85ed9d42010-06-08 22:37:4415#include "base/perftimer.h"
initial.commit09911bf2008-07-26 23:55:2916#include "base/scoped_ptr.h"
17#include "base/string_util.h"
[email protected]fadf97f2008-09-18 12:18:1418#include "base/sys_info.h"
[email protected]37f39e42010-01-06 17:35:1719#include "base/third_party/nspr/prtime.h"
[email protected]1eeb5e02010-07-20 23:02:1120#include "base/time.h"
21#include "base/utf_string_conversions.h"
initial.commit09911bf2008-07-26 23:55:2922#include "chrome/browser/autocomplete/autocomplete.h"
23#include "chrome/browser/browser_process.h"
[email protected]e8c287c872010-07-20 00:49:4224#include "chrome/browser/gpu_process_host.h"
[email protected]052313b2010-02-19 09:43:0825#include "chrome/browser/pref_service.h"
[email protected]1eeb5e02010-07-20 23:02:1126#include "chrome/common/chrome_version_info.h"
initial.commit09911bf2008-07-26 23:55:2927#include "chrome/common/logging_chrome.h"
28#include "chrome/common/pref_names.h"
[email protected]46072d42008-07-28 14:49:3529#include "googleurl/src/gurl.h"
initial.commit09911bf2008-07-26 23:55:2930
31#define OPEN_ELEMENT_FOR_SCOPE(name) ScopedElement scoped_element(this, name)
32
[email protected]d1be67b2008-11-19 20:28:3833// http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx
34#if defined(OS_WIN)
35extern "C" IMAGE_DOS_HEADER __ImageBase;
36#endif
37
[email protected]1226abb2010-06-10 18:01:2838MetricsLog::MetricsLog(const std::string& client_id, int session_id)
39 : MetricsLogBase(client_id, session_id, MetricsLog::GetVersionString()) {}
[email protected]5ed7d4572009-12-23 17:42:4140
[email protected]1226abb2010-06-10 18:01:2841MetricsLog::~MetricsLog() {}
initial.commit09911bf2008-07-26 23:55:2942
43// static
44void MetricsLog::RegisterPrefs(PrefService* local_state) {
45 local_state->RegisterListPref(prefs::kStabilityPluginStats);
initial.commit09911bf2008-07-26 23:55:2946}
47
[email protected]9165f742010-03-10 22:55:0148int64 MetricsLog::GetIncrementalUptime(PrefService* pref) {
49 base::TimeTicks now = base::TimeTicks::Now();
50 static base::TimeTicks last_updated_time(now);
51 int64 incremental_time = (now - last_updated_time).InSeconds();
52 last_updated_time = now;
53
54 if (incremental_time > 0) {
55 int64 metrics_uptime = pref->GetInt64(prefs::kUninstallMetricsUptimeSec);
56 metrics_uptime += incremental_time;
57 pref->SetInt64(prefs::kUninstallMetricsUptimeSec, metrics_uptime);
58 }
59
60 return incremental_time;
61}
62
initial.commit09911bf2008-07-26 23:55:2963std::string MetricsLog::GetInstallDate() const {
64 PrefService* pref = g_browser_process->local_state();
65 if (pref) {
[email protected]ddd231e2010-06-29 20:35:1966 return pref->GetString(prefs::kMetricsClientIDTimestamp);
initial.commit09911bf2008-07-26 23:55:2967 } else {
68 NOTREACHED();
69 return "0";
70 }
71}
72
[email protected]1226abb2010-06-10 18:01:2873// static
74std::string MetricsLog::GetVersionString() {
75 scoped_ptr<FileVersionInfo> version_info(
[email protected]1eeb5e02010-07-20 23:02:1176 chrome::GetChromeVersionInfo());
[email protected]1226abb2010-06-10 18:01:2877 if (version_info.get()) {
78 std::string version = WideToUTF8(version_info->product_version());
79 if (!version_extension_.empty())
80 version += version_extension_;
81 if (!version_info->is_official_build())
82 version.append("-devel");
83 return version;
84 } else {
85 NOTREACHED() << "Unable to retrieve version string.";
86 }
87
88 return std::string();
89}
90
[email protected]0b33f80b2008-12-17 21:34:3691void MetricsLog::RecordIncrementalStabilityElements() {
92 DCHECK(!locked_);
93
94 PrefService* pref = g_browser_process->local_state();
95 DCHECK(pref);
96
[email protected]147bbc0b2009-01-06 19:37:4097 OPEN_ELEMENT_FOR_SCOPE("profile");
98 WriteCommonEventAttributes();
99
100 WriteInstallElement(); // Supply appversion.
101
102 {
103 OPEN_ELEMENT_FOR_SCOPE("stability"); // Minimal set of stability elements.
104 WriteRequiredStabilityAttributes(pref);
105 WriteRealtimeStabilityAttributes(pref);
106
107 WritePluginStabilityElements(pref);
108 }
[email protected]0b33f80b2008-12-17 21:34:36109}
110
initial.commit09911bf2008-07-26 23:55:29111void MetricsLog::WriteStabilityElement() {
112 DCHECK(!locked_);
113
114 PrefService* pref = g_browser_process->local_state();
115 DCHECK(pref);
116
117 // Get stability attributes out of Local State, zeroing out stored values.
118 // NOTE: This could lead to some data loss if this report isn't successfully
119 // sent, but that's true for all the metrics.
120
[email protected]ffaf78a2008-11-12 17:38:33121 OPEN_ELEMENT_FOR_SCOPE("stability");
[email protected]147bbc0b2009-01-06 19:37:40122 WriteRequiredStabilityAttributes(pref);
123 WriteRealtimeStabilityAttributes(pref);
initial.commit09911bf2008-07-26 23:55:29124
[email protected]0b33f80b2008-12-17 21:34:36125 // TODO(jar): The following are all optional, so we *could* optimize them for
126 // values of zero (and not include them).
[email protected]8e674e42008-07-30 16:05:48127 WriteIntAttribute("incompleteshutdowncount",
128 pref->GetInteger(
129 prefs::kStabilityIncompleteSessionEndCount));
130 pref->SetInteger(prefs::kStabilityIncompleteSessionEndCount, 0);
[email protected]0b33f80b2008-12-17 21:34:36131
132
[email protected]e73c01972008-08-13 00:18:24133 WriteIntAttribute("breakpadregistrationok",
134 pref->GetInteger(prefs::kStabilityBreakpadRegistrationSuccess));
135 pref->SetInteger(prefs::kStabilityBreakpadRegistrationSuccess, 0);
136 WriteIntAttribute("breakpadregistrationfail",
137 pref->GetInteger(prefs::kStabilityBreakpadRegistrationFail));
138 pref->SetInteger(prefs::kStabilityBreakpadRegistrationFail, 0);
139 WriteIntAttribute("debuggerpresent",
140 pref->GetInteger(prefs::kStabilityDebuggerPresent));
141 pref->SetInteger(prefs::kStabilityDebuggerPresent, 0);
142 WriteIntAttribute("debuggernotpresent",
143 pref->GetInteger(prefs::kStabilityDebuggerNotPresent));
144 pref->SetInteger(prefs::kStabilityDebuggerNotPresent, 0);
initial.commit09911bf2008-07-26 23:55:29145
[email protected]147bbc0b2009-01-06 19:37:40146 WritePluginStabilityElements(pref);
147}
148
149void MetricsLog::WritePluginStabilityElements(PrefService* pref) {
150 // Now log plugin stability info.
initial.commit09911bf2008-07-26 23:55:29151 const ListValue* plugin_stats_list = pref->GetList(
152 prefs::kStabilityPluginStats);
153 if (plugin_stats_list) {
[email protected]ffaf78a2008-11-12 17:38:33154 OPEN_ELEMENT_FOR_SCOPE("plugins");
initial.commit09911bf2008-07-26 23:55:29155 for (ListValue::const_iterator iter = plugin_stats_list->begin();
156 iter != plugin_stats_list->end(); ++iter) {
157 if (!(*iter)->IsType(Value::TYPE_DICTIONARY)) {
158 NOTREACHED();
159 continue;
160 }
161 DictionaryValue* plugin_dict = static_cast<DictionaryValue*>(*iter);
162
[email protected]8e50b602009-03-03 22:59:43163 std::wstring plugin_name;
164 plugin_dict->GetString(prefs::kStabilityPluginName, &plugin_name);
initial.commit09911bf2008-07-26 23:55:29165
[email protected]ffaf78a2008-11-12 17:38:33166 OPEN_ELEMENT_FOR_SCOPE("pluginstability");
[email protected]a27a9382009-02-11 23:55:10167 // Use "filename" instead of "name", otherwise we need to update the
168 // UMA servers.
[email protected]8e50b602009-03-03 22:59:43169 WriteAttribute("filename", CreateBase64Hash(WideToUTF8(plugin_name)));
initial.commit09911bf2008-07-26 23:55:29170
171 int launches = 0;
[email protected]8e50b602009-03-03 22:59:43172 plugin_dict->GetInteger(prefs::kStabilityPluginLaunches, &launches);
initial.commit09911bf2008-07-26 23:55:29173 WriteIntAttribute("launchcount", launches);
174
175 int instances = 0;
[email protected]8e50b602009-03-03 22:59:43176 plugin_dict->GetInteger(prefs::kStabilityPluginInstances, &instances);
initial.commit09911bf2008-07-26 23:55:29177 WriteIntAttribute("instancecount", instances);
178
179 int crashes = 0;
[email protected]8e50b602009-03-03 22:59:43180 plugin_dict->GetInteger(prefs::kStabilityPluginCrashes, &crashes);
initial.commit09911bf2008-07-26 23:55:29181 WriteIntAttribute("crashcount", crashes);
initial.commit09911bf2008-07-26 23:55:29182 }
183
184 pref->ClearPref(prefs::kStabilityPluginStats);
initial.commit09911bf2008-07-26 23:55:29185 }
initial.commit09911bf2008-07-26 23:55:29186}
187
[email protected]147bbc0b2009-01-06 19:37:40188void MetricsLog::WriteRequiredStabilityAttributes(PrefService* pref) {
[email protected]0b33f80b2008-12-17 21:34:36189 // The server refuses data that doesn't have certain values. crashcount and
190 // launchcount are currently "required" in the "stability" group.
191 WriteIntAttribute("launchcount",
192 pref->GetInteger(prefs::kStabilityLaunchCount));
193 pref->SetInteger(prefs::kStabilityLaunchCount, 0);
194 WriteIntAttribute("crashcount",
195 pref->GetInteger(prefs::kStabilityCrashCount));
196 pref->SetInteger(prefs::kStabilityCrashCount, 0);
197}
198
[email protected]147bbc0b2009-01-06 19:37:40199void MetricsLog::WriteRealtimeStabilityAttributes(PrefService* pref) {
[email protected]0b33f80b2008-12-17 21:34:36200 // Update the stats which are critical for real-time stability monitoring.
201 // Since these are "optional," only list ones that are non-zero, as the counts
202 // are aggergated (summed) server side.
203
204 int count = pref->GetInteger(prefs::kStabilityPageLoadCount);
205 if (count) {
206 WriteIntAttribute("pageloadcount", count);
207 pref->SetInteger(prefs::kStabilityPageLoadCount, 0);
208 }
209
210 count = pref->GetInteger(prefs::kStabilityRendererCrashCount);
211 if (count) {
212 WriteIntAttribute("renderercrashcount", count);
213 pref->SetInteger(prefs::kStabilityRendererCrashCount, 0);
214 }
215
[email protected]1f085622009-12-04 05:33:45216 count = pref->GetInteger(prefs::kStabilityExtensionRendererCrashCount);
217 if (count) {
218 WriteIntAttribute("extensionrenderercrashcount", count);
219 pref->SetInteger(prefs::kStabilityExtensionRendererCrashCount, 0);
220 }
221
[email protected]0b33f80b2008-12-17 21:34:36222 count = pref->GetInteger(prefs::kStabilityRendererHangCount);
223 if (count) {
224 WriteIntAttribute("rendererhangcount", count);
225 pref->SetInteger(prefs::kStabilityRendererHangCount, 0);
226 }
[email protected]1f085622009-12-04 05:33:45227
228 count = pref->GetInteger(prefs::kStabilityChildProcessCrashCount);
229 if (count) {
230 WriteIntAttribute("childprocesscrashcount", count);
231 pref->SetInteger(prefs::kStabilityChildProcessCrashCount, 0);
232 }
[email protected]9165f742010-03-10 22:55:01233
234 int64 recent_duration = GetIncrementalUptime(pref);
235 if (recent_duration)
236 WriteInt64Attribute("uptimesec", recent_duration);
[email protected]0b33f80b2008-12-17 21:34:36237}
238
initial.commit09911bf2008-07-26 23:55:29239void MetricsLog::WritePluginList(
240 const std::vector<WebPluginInfo>& plugin_list) {
241 DCHECK(!locked_);
242
[email protected]ffaf78a2008-11-12 17:38:33243 OPEN_ELEMENT_FOR_SCOPE("plugins");
initial.commit09911bf2008-07-26 23:55:29244
245 for (std::vector<WebPluginInfo>::const_iterator iter = plugin_list.begin();
246 iter != plugin_list.end(); ++iter) {
[email protected]ffaf78a2008-11-12 17:38:33247 OPEN_ELEMENT_FOR_SCOPE("plugin");
initial.commit09911bf2008-07-26 23:55:29248
249 // Plugin name and filename are hashed for the privacy of those
250 // testing unreleased new extensions.
[email protected]c9d811372010-06-23 21:44:57251 WriteAttribute("name", CreateBase64Hash(UTF16ToUTF8(iter->name)));
[email protected]046344c2009-01-13 00:54:21252 WriteAttribute("filename",
253 CreateBase64Hash(WideToUTF8(iter->path.BaseName().ToWStringHack())));
[email protected]c9d811372010-06-23 21:44:57254 WriteAttribute("version", UTF16ToUTF8(iter->version));
initial.commit09911bf2008-07-26 23:55:29255 }
initial.commit09911bf2008-07-26 23:55:29256}
257
[email protected]147bbc0b2009-01-06 19:37:40258void MetricsLog::WriteInstallElement() {
259 OPEN_ELEMENT_FOR_SCOPE("install");
260 WriteAttribute("installdate", GetInstallDate());
261 WriteIntAttribute("buildid", 0); // We're using appversion instead.
[email protected]147bbc0b2009-01-06 19:37:40262}
263
initial.commit09911bf2008-07-26 23:55:29264void MetricsLog::RecordEnvironment(
265 const std::vector<WebPluginInfo>& plugin_list,
266 const DictionaryValue* profile_metrics) {
267 DCHECK(!locked_);
268
269 PrefService* pref = g_browser_process->local_state();
270
[email protected]ffaf78a2008-11-12 17:38:33271 OPEN_ELEMENT_FOR_SCOPE("profile");
initial.commit09911bf2008-07-26 23:55:29272 WriteCommonEventAttributes();
273
[email protected]147bbc0b2009-01-06 19:37:40274 WriteInstallElement();
initial.commit09911bf2008-07-26 23:55:29275
276 WritePluginList(plugin_list);
277
278 WriteStabilityElement();
279
280 {
281 OPEN_ELEMENT_FOR_SCOPE("cpu");
[email protected]05f9b682008-09-29 22:18:01282 WriteAttribute("arch", base::SysInfo::CPUArchitecture());
initial.commit09911bf2008-07-26 23:55:29283 }
284
285 {
initial.commit09911bf2008-07-26 23:55:29286 OPEN_ELEMENT_FOR_SCOPE("memory");
[email protected]ed6fc352008-09-18 12:44:40287 WriteIntAttribute("mb", base::SysInfo::AmountOfPhysicalMemoryMB());
[email protected]d1be67b2008-11-19 20:28:38288#if defined(OS_WIN)
289 WriteIntAttribute("dllbase", reinterpret_cast<int>(&__ImageBase));
290#endif
initial.commit09911bf2008-07-26 23:55:29291 }
292
293 {
294 OPEN_ELEMENT_FOR_SCOPE("os");
295 WriteAttribute("name",
[email protected]05f9b682008-09-29 22:18:01296 base::SysInfo::OperatingSystemName());
initial.commit09911bf2008-07-26 23:55:29297 WriteAttribute("version",
[email protected]05f9b682008-09-29 22:18:01298 base::SysInfo::OperatingSystemVersion());
initial.commit09911bf2008-07-26 23:55:29299 }
300
301 {
[email protected]e8c287c872010-07-20 00:49:42302 OPEN_ELEMENT_FOR_SCOPE("gpu");
303 WriteIntAttribute("vendorid",
304 GpuProcessHost::Get()->gpu_info().vendor_id());
305 WriteIntAttribute("deviceid",
306 GpuProcessHost::Get()->gpu_info().device_id());
307 }
308
309 {
initial.commit09911bf2008-07-26 23:55:29310 OPEN_ELEMENT_FOR_SCOPE("display");
311 int width = 0;
312 int height = 0;
[email protected]05f9b682008-09-29 22:18:01313 base::SysInfo::GetPrimaryDisplayDimensions(&width, &height);
initial.commit09911bf2008-07-26 23:55:29314 WriteIntAttribute("xsize", width);
315 WriteIntAttribute("ysize", height);
[email protected]05f9b682008-09-29 22:18:01316 WriteIntAttribute("screens", base::SysInfo::DisplayCount());
initial.commit09911bf2008-07-26 23:55:29317 }
318
319 {
320 OPEN_ELEMENT_FOR_SCOPE("bookmarks");
321 int num_bookmarks_on_bookmark_bar =
322 pref->GetInteger(prefs::kNumBookmarksOnBookmarkBar);
323 int num_folders_on_bookmark_bar =
324 pref->GetInteger(prefs::kNumFoldersOnBookmarkBar);
325 int num_bookmarks_in_other_bookmarks_folder =
326 pref->GetInteger(prefs::kNumBookmarksInOtherBookmarkFolder);
327 int num_folders_in_other_bookmarks_folder =
328 pref->GetInteger(prefs::kNumFoldersInOtherBookmarkFolder);
329 {
330 OPEN_ELEMENT_FOR_SCOPE("bookmarklocation");
331 WriteAttribute("name", "full-tree");
332 WriteIntAttribute("foldercount",
333 num_folders_on_bookmark_bar + num_folders_in_other_bookmarks_folder);
334 WriteIntAttribute("itemcount",
335 num_bookmarks_on_bookmark_bar +
336 num_bookmarks_in_other_bookmarks_folder);
337 }
338 {
339 OPEN_ELEMENT_FOR_SCOPE("bookmarklocation");
340 WriteAttribute("name", "toolbar");
341 WriteIntAttribute("foldercount", num_folders_on_bookmark_bar);
342 WriteIntAttribute("itemcount", num_bookmarks_on_bookmark_bar);
343 }
344 }
345
346 {
347 OPEN_ELEMENT_FOR_SCOPE("keywords");
348 WriteIntAttribute("count", pref->GetInteger(prefs::kNumKeywords));
349 }
350
351 if (profile_metrics)
352 WriteAllProfilesMetrics(*profile_metrics);
initial.commit09911bf2008-07-26 23:55:29353}
354
355void MetricsLog::WriteAllProfilesMetrics(
356 const DictionaryValue& all_profiles_metrics) {
[email protected]e7b418b2010-07-30 19:47:47357 const std::string profile_prefix(WideToUTF8(prefs::kProfilePrefix));
initial.commit09911bf2008-07-26 23:55:29358 for (DictionaryValue::key_iterator i = all_profiles_metrics.begin_keys();
359 i != all_profiles_metrics.end_keys(); ++i) {
[email protected]e7b418b2010-07-30 19:47:47360 const std::string& key_name = *i;
initial.commit09911bf2008-07-26 23:55:29361 if (key_name.compare(0, profile_prefix.size(), profile_prefix) == 0) {
362 DictionaryValue* profile;
[email protected]4dad9ad82009-11-25 20:47:52363 if (all_profiles_metrics.GetDictionaryWithoutPathExpansion(key_name,
364 &profile))
initial.commit09911bf2008-07-26 23:55:29365 WriteProfileMetrics(key_name.substr(profile_prefix.size()), *profile);
366 }
367 }
368}
369
[email protected]e7b418b2010-07-30 19:47:47370void MetricsLog::WriteProfileMetrics(const std::string& profileidhash,
initial.commit09911bf2008-07-26 23:55:29371 const DictionaryValue& profile_metrics) {
372 OPEN_ELEMENT_FOR_SCOPE("userprofile");
[email protected]e7b418b2010-07-30 19:47:47373 WriteAttribute("profileidhash", profileidhash);
initial.commit09911bf2008-07-26 23:55:29374 for (DictionaryValue::key_iterator i = profile_metrics.begin_keys();
375 i != profile_metrics.end_keys(); ++i) {
376 Value* value;
[email protected]4dad9ad82009-11-25 20:47:52377 if (profile_metrics.GetWithoutPathExpansion(*i, &value)) {
[email protected]e7b418b2010-07-30 19:47:47378 DCHECK(*i != "id");
initial.commit09911bf2008-07-26 23:55:29379 switch (value->GetType()) {
380 case Value::TYPE_STRING: {
[email protected]5e324b72008-12-18 00:07:59381 std::string string_value;
initial.commit09911bf2008-07-26 23:55:29382 if (value->GetAsString(&string_value)) {
383 OPEN_ELEMENT_FOR_SCOPE("profileparam");
[email protected]e7b418b2010-07-30 19:47:47384 WriteAttribute("name", *i);
[email protected]5e324b72008-12-18 00:07:59385 WriteAttribute("value", string_value);
initial.commit09911bf2008-07-26 23:55:29386 }
387 break;
388 }
389
390 case Value::TYPE_BOOLEAN: {
391 bool bool_value;
392 if (value->GetAsBoolean(&bool_value)) {
393 OPEN_ELEMENT_FOR_SCOPE("profileparam");
[email protected]e7b418b2010-07-30 19:47:47394 WriteAttribute("name", *i);
initial.commit09911bf2008-07-26 23:55:29395 WriteIntAttribute("value", bool_value ? 1 : 0);
396 }
397 break;
398 }
399
400 case Value::TYPE_INTEGER: {
401 int int_value;
402 if (value->GetAsInteger(&int_value)) {
403 OPEN_ELEMENT_FOR_SCOPE("profileparam");
[email protected]e7b418b2010-07-30 19:47:47404 WriteAttribute("name", *i);
initial.commit09911bf2008-07-26 23:55:29405 WriteIntAttribute("value", int_value);
406 }
407 break;
408 }
409
410 default:
411 NOTREACHED();
412 break;
413 }
414 }
415 }
416}
417
418void MetricsLog::RecordOmniboxOpenedURL(const AutocompleteLog& log) {
419 DCHECK(!locked_);
420
[email protected]ffaf78a2008-11-12 17:38:33421 OPEN_ELEMENT_FOR_SCOPE("uielement");
initial.commit09911bf2008-07-26 23:55:29422 WriteAttribute("action", "autocomplete");
423 WriteAttribute("targetidhash", "");
424 // TODO(kochi): Properly track windows.
425 WriteIntAttribute("window", 0);
426 WriteCommonEventAttributes();
427
[email protected]ffaf78a2008-11-12 17:38:33428 {
429 OPEN_ELEMENT_FOR_SCOPE("autocomplete");
initial.commit09911bf2008-07-26 23:55:29430
[email protected]ffaf78a2008-11-12 17:38:33431 WriteIntAttribute("typedlength", static_cast<int>(log.text.length()));
432 WriteIntAttribute("selectedindex", static_cast<int>(log.selected_index));
433 WriteIntAttribute("completedlength",
434 static_cast<int>(log.inline_autocompleted_length));
[email protected]381e2992008-12-16 01:41:00435 const std::string input_type(
436 AutocompleteInput::TypeToString(log.input_type));
437 if (!input_type.empty())
438 WriteAttribute("inputtype", input_type);
initial.commit09911bf2008-07-26 23:55:29439
[email protected]ffaf78a2008-11-12 17:38:33440 for (AutocompleteResult::const_iterator i(log.result.begin());
441 i != log.result.end(); ++i) {
442 OPEN_ELEMENT_FOR_SCOPE("autocompleteitem");
443 if (i->provider)
444 WriteAttribute("provider", i->provider->name());
[email protected]381e2992008-12-16 01:41:00445 const std::string result_type(AutocompleteMatch::TypeToString(i->type));
446 if (!result_type.empty())
447 WriteAttribute("resulttype", result_type);
[email protected]ffaf78a2008-11-12 17:38:33448 WriteIntAttribute("relevance", i->relevance);
449 WriteIntAttribute("isstarred", i->starred ? 1 : 0);
450 }
initial.commit09911bf2008-07-26 23:55:29451 }
initial.commit09911bf2008-07-26 23:55:29452
453 ++num_events_;
454}