Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: chrome/browser/metrics/metrics_log.cc

Issue 9559017: [UMA] Include field trial tuples in the UMA upload. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Mock out scree size/count code for testing Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/metrics/metrics_log.h ('k') | chrome/browser/metrics/metrics_log_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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"
(...skipping 30 matching lines...) Expand all
41 #define OPEN_ELEMENT_FOR_SCOPE(name) ScopedElement scoped_element(this, name) 41 #define OPEN_ELEMENT_FOR_SCOPE(name) ScopedElement scoped_element(this, name)
42 42
43 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx 43 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx
44 #if defined(OS_WIN) 44 #if defined(OS_WIN)
45 extern "C" IMAGE_DOS_HEADER __ImageBase; 45 extern "C" IMAGE_DOS_HEADER __ImageBase;
46 #endif 46 #endif
47 47
48 using content::GpuDataManager; 48 using content::GpuDataManager;
49 using metrics::OmniboxEventProto; 49 using metrics::OmniboxEventProto;
50 using metrics::SystemProfileProto; 50 using metrics::SystemProfileProto;
51 typedef base::FieldTrial::NameGroupId NameGroupId;
51 52
52 namespace { 53 namespace {
53 54
54 // Returns the date at which the current metrics client ID was created as 55 // Returns the date at which the current metrics client ID was created as
55 // a string containing milliseconds since the epoch, or "0" if none was found. 56 // a string containing milliseconds since the epoch, or "0" if none was found.
56 std::string GetInstallDate() { 57 std::string GetInstallDate(PrefService* pref) {
57 PrefService* pref = g_browser_process->local_state(); 58 if (!pref) {
58 if (pref) {
59 return pref->GetString(prefs::kMetricsClientIDTimestamp);
60 } else {
61 NOTREACHED(); 59 NOTREACHED();
62 return "0"; 60 return "0";
63 } 61 }
62
63 return pref->GetString(prefs::kMetricsClientIDTimestamp);
64 } 64 }
65 65
66 OmniboxEventProto::InputType AsOmniboxEventInputType( 66 OmniboxEventProto::InputType AsOmniboxEventInputType(
67 AutocompleteInput::Type type) { 67 AutocompleteInput::Type type) {
68 switch (type) { 68 switch (type) {
69 case AutocompleteInput::INVALID: 69 case AutocompleteInput::INVALID:
70 return OmniboxEventProto::INVALID; 70 return OmniboxEventProto::INVALID;
71 case AutocompleteInput::UNKNOWN: 71 case AutocompleteInput::UNKNOWN:
72 return OmniboxEventProto::UNKNOWN; 72 return OmniboxEventProto::UNKNOWN;
73 case AutocompleteInput::REQUESTED_URL: 73 case AutocompleteInput::REQUESTED_URL:
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 void SetPluginInfo(const webkit::WebPluginInfo& plugin_info, 164 void SetPluginInfo(const webkit::WebPluginInfo& plugin_info,
165 const PluginPrefs* plugin_prefs, 165 const PluginPrefs* plugin_prefs,
166 SystemProfileProto::Plugin* plugin) { 166 SystemProfileProto::Plugin* plugin) {
167 plugin->set_name(UTF16ToUTF8(plugin_info.name)); 167 plugin->set_name(UTF16ToUTF8(plugin_info.name));
168 plugin->set_filename(plugin_info.path.BaseName().AsUTF8Unsafe()); 168 plugin->set_filename(plugin_info.path.BaseName().AsUTF8Unsafe());
169 plugin->set_version(UTF16ToUTF8(plugin_info.version)); 169 plugin->set_version(UTF16ToUTF8(plugin_info.version));
170 if (plugin_prefs) 170 if (plugin_prefs)
171 plugin->set_is_disabled(!plugin_prefs->IsPluginEnabled(plugin_info)); 171 plugin->set_is_disabled(!plugin_prefs->IsPluginEnabled(plugin_info));
172 } 172 }
173 173
174 void WriteFieldTrials(const std::vector<NameGroupId>& field_trial_ids,
175 SystemProfileProto* system_profile) {
176 for (std::vector<NameGroupId>::const_iterator it = field_trial_ids.begin();
177 it != field_trial_ids.end(); ++it) {
178 SystemProfileProto::FieldTrial* field_trial =
179 system_profile->add_field_trial();
180 field_trial->set_name_id(it->name);
181 field_trial->set_group_id(it->group);
182 }
183 }
184
174 } // namespace 185 } // namespace
175 186
176 static base::LazyInstance<std::string>::Leaky 187 static base::LazyInstance<std::string>::Leaky
177 g_version_extension = LAZY_INSTANCE_INITIALIZER; 188 g_version_extension = LAZY_INSTANCE_INITIALIZER;
178 189
179 MetricsLog::MetricsLog(const std::string& client_id, int session_id) 190 MetricsLog::MetricsLog(const std::string& client_id, int session_id)
180 : MetricsLogBase(client_id, session_id, MetricsLog::GetVersionString()) {} 191 : MetricsLogBase(client_id, session_id, MetricsLog::GetVersionString()) {}
181 192
182 MetricsLog::~MetricsLog() {} 193 MetricsLog::~MetricsLog() {}
183 194
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 g_version_extension.Get() = extension; 234 g_version_extension.Get() = extension;
224 } 235 }
225 236
226 // static 237 // static
227 const std::string& MetricsLog::version_extension() { 238 const std::string& MetricsLog::version_extension() {
228 return g_version_extension.Get(); 239 return g_version_extension.Get();
229 } 240 }
230 241
231 void MetricsLog::RecordIncrementalStabilityElements( 242 void MetricsLog::RecordIncrementalStabilityElements(
232 const std::vector<webkit::WebPluginInfo>& plugin_list) { 243 const std::vector<webkit::WebPluginInfo>& plugin_list) {
233 DCHECK(!locked_); 244 DCHECK(!locked());
234 245
235 PrefService* pref = g_browser_process->local_state(); 246 PrefService* pref = GetPrefService();
236 DCHECK(pref); 247 DCHECK(pref);
237 248
238 OPEN_ELEMENT_FOR_SCOPE("profile"); 249 OPEN_ELEMENT_FOR_SCOPE("profile");
239 WriteCommonEventAttributes(); 250 WriteCommonEventAttributes();
240 251
241 WriteInstallElement(); 252 WriteInstallElement();
242 253
243 { 254 {
244 OPEN_ELEMENT_FOR_SCOPE("stability"); // Minimal set of stability elements. 255 OPEN_ELEMENT_FOR_SCOPE("stability"); // Minimal set of stability elements.
245 WriteRequiredStabilityAttributes(pref); 256 WriteRequiredStabilityAttributes(pref);
246 WriteRealtimeStabilityAttributes(pref); 257 WriteRealtimeStabilityAttributes(pref);
247 258
248 WritePluginStabilityElements(plugin_list, pref); 259 WritePluginStabilityElements(plugin_list, pref);
249 } 260 }
250 } 261 }
251 262
263 PrefService* MetricsLog::GetPrefService() {
264 return g_browser_process->local_state();
265 }
266
267 gfx::Size MetricsLog::GetScreenSize() const {
268 return gfx::Screen::GetPrimaryMonitorSize();
269 }
270
271 int MetricsLog::GetScreenCount() const {
272 return gfx::Screen::GetNumMonitors();
273 }
274
275
276 void MetricsLog::GetFieldTrialIds(
277 std::vector<NameGroupId>* field_trial_ids) const {
278 base::FieldTrialList::GetFieldTrialNameGroupIds(field_trial_ids);
279 }
280
252 void MetricsLog::WriteStabilityElement( 281 void MetricsLog::WriteStabilityElement(
253 const std::vector<webkit::WebPluginInfo>& plugin_list, 282 const std::vector<webkit::WebPluginInfo>& plugin_list,
254 PrefService* pref) { 283 PrefService* pref) {
255 DCHECK(!locked_); 284 DCHECK(!locked());
256 285
257 // Get stability attributes out of Local State, zeroing out stored values. 286 // Get stability attributes out of Local State, zeroing out stored values.
258 // NOTE: This could lead to some data loss if this report isn't successfully 287 // NOTE: This could lead to some data loss if this report isn't successfully
259 // sent, but that's true for all the metrics. 288 // sent, but that's true for all the metrics.
260 289
261 OPEN_ELEMENT_FOR_SCOPE("stability"); 290 OPEN_ELEMENT_FOR_SCOPE("stability");
262 WriteRequiredStabilityAttributes(pref); 291 WriteRequiredStabilityAttributes(pref);
263 WriteRealtimeStabilityAttributes(pref); 292 WriteRealtimeStabilityAttributes(pref);
264 293
265 int incomplete_shutdown_count = 294 int incomplete_shutdown_count =
(...skipping 19 matching lines...) Expand all
285 WriteIntAttribute("incompleteshutdowncount", incomplete_shutdown_count); 314 WriteIntAttribute("incompleteshutdowncount", incomplete_shutdown_count);
286 WriteIntAttribute("breakpadregistrationok", 315 WriteIntAttribute("breakpadregistrationok",
287 breakpad_registration_success_count); 316 breakpad_registration_success_count);
288 WriteIntAttribute("breakpadregistrationfail", 317 WriteIntAttribute("breakpadregistrationfail",
289 breakpad_registration_failure_count); 318 breakpad_registration_failure_count);
290 WriteIntAttribute("debuggerpresent", debugger_present_count); 319 WriteIntAttribute("debuggerpresent", debugger_present_count);
291 WriteIntAttribute("debuggernotpresent", debugger_not_present_count); 320 WriteIntAttribute("debuggernotpresent", debugger_not_present_count);
292 321
293 // Write the protobuf version. 322 // Write the protobuf version.
294 SystemProfileProto::Stability* stability = 323 SystemProfileProto::Stability* stability =
295 uma_proto_.mutable_system_profile()->mutable_stability(); 324 uma_proto()->mutable_system_profile()->mutable_stability();
296 stability->set_incomplete_shutdown_count(incomplete_shutdown_count); 325 stability->set_incomplete_shutdown_count(incomplete_shutdown_count);
297 stability->set_breakpad_registration_success_count( 326 stability->set_breakpad_registration_success_count(
298 breakpad_registration_success_count); 327 breakpad_registration_success_count);
299 stability->set_breakpad_registration_failure_count( 328 stability->set_breakpad_registration_failure_count(
300 breakpad_registration_failure_count); 329 breakpad_registration_failure_count);
301 stability->set_debugger_present_count(debugger_present_count); 330 stability->set_debugger_present_count(debugger_present_count);
302 stability->set_debugger_not_present_count(debugger_not_present_count); 331 stability->set_debugger_not_present_count(debugger_not_present_count);
303 332
304 WritePluginStabilityElements(plugin_list, pref); 333 WritePluginStabilityElements(plugin_list, pref);
305 } 334 }
306 335
307 void MetricsLog::WritePluginStabilityElements( 336 void MetricsLog::WritePluginStabilityElements(
308 const std::vector<webkit::WebPluginInfo>& plugin_list, 337 const std::vector<webkit::WebPluginInfo>& plugin_list,
309 PrefService* pref) { 338 PrefService* pref) {
310 // Now log plugin stability info. 339 // Now log plugin stability info.
311 const ListValue* plugin_stats_list = pref->GetList( 340 const ListValue* plugin_stats_list = pref->GetList(
312 prefs::kStabilityPluginStats); 341 prefs::kStabilityPluginStats);
313 if (!plugin_stats_list) 342 if (!plugin_stats_list)
314 return; 343 return;
315 344
316 OPEN_ELEMENT_FOR_SCOPE("plugins"); 345 OPEN_ELEMENT_FOR_SCOPE("plugins");
317 SystemProfileProto::Stability* stability = 346 SystemProfileProto::Stability* stability =
318 uma_proto_.mutable_system_profile()->mutable_stability(); 347 uma_proto()->mutable_system_profile()->mutable_stability();
319 PluginPrefs* plugin_prefs = GetPluginPrefs(); 348 PluginPrefs* plugin_prefs = GetPluginPrefs();
320 for (ListValue::const_iterator iter = plugin_stats_list->begin(); 349 for (ListValue::const_iterator iter = plugin_stats_list->begin();
321 iter != plugin_stats_list->end(); ++iter) { 350 iter != plugin_stats_list->end(); ++iter) {
322 if (!(*iter)->IsType(Value::TYPE_DICTIONARY)) { 351 if (!(*iter)->IsType(Value::TYPE_DICTIONARY)) {
323 NOTREACHED(); 352 NOTREACHED();
324 continue; 353 continue;
325 } 354 }
326 DictionaryValue* plugin_dict = static_cast<DictionaryValue*>(*iter); 355 DictionaryValue* plugin_dict = static_cast<DictionaryValue*>(*iter);
327 356
328 std::string plugin_name; 357 std::string plugin_name;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 pref->SetInteger(prefs::kStabilityLaunchCount, 0); 422 pref->SetInteger(prefs::kStabilityLaunchCount, 0);
394 int crash_count = pref->GetInteger(prefs::kStabilityCrashCount); 423 int crash_count = pref->GetInteger(prefs::kStabilityCrashCount);
395 pref->SetInteger(prefs::kStabilityCrashCount, 0); 424 pref->SetInteger(prefs::kStabilityCrashCount, 0);
396 425
397 // Write the XML version. 426 // Write the XML version.
398 WriteIntAttribute("launchcount", launch_count); 427 WriteIntAttribute("launchcount", launch_count);
399 WriteIntAttribute("crashcount", crash_count); 428 WriteIntAttribute("crashcount", crash_count);
400 429
401 // Write the protobuf version. 430 // Write the protobuf version.
402 SystemProfileProto::Stability* stability = 431 SystemProfileProto::Stability* stability =
403 uma_proto_.mutable_system_profile()->mutable_stability(); 432 uma_proto()->mutable_system_profile()->mutable_stability();
404 stability->set_launch_count(launch_count); 433 stability->set_launch_count(launch_count);
405 stability->set_crash_count(crash_count); 434 stability->set_crash_count(crash_count);
406 } 435 }
407 436
408 void MetricsLog::WriteRealtimeStabilityAttributes(PrefService* pref) { 437 void MetricsLog::WriteRealtimeStabilityAttributes(PrefService* pref) {
409 // Update the stats which are critical for real-time stability monitoring. 438 // Update the stats which are critical for real-time stability monitoring.
410 // Since these are "optional," only list ones that are non-zero, as the counts 439 // Since these are "optional," only list ones that are non-zero, as the counts
411 // are aggergated (summed) server side. 440 // are aggergated (summed) server side.
412 441
413 SystemProfileProto::Stability* stability = 442 SystemProfileProto::Stability* stability =
414 uma_proto_.mutable_system_profile()->mutable_stability(); 443 uma_proto()->mutable_system_profile()->mutable_stability();
415 int count = pref->GetInteger(prefs::kStabilityPageLoadCount); 444 int count = pref->GetInteger(prefs::kStabilityPageLoadCount);
416 if (count) { 445 if (count) {
417 WriteIntAttribute("pageloadcount", count); 446 WriteIntAttribute("pageloadcount", count);
418 stability->set_page_load_count(count); 447 stability->set_page_load_count(count);
419 pref->SetInteger(prefs::kStabilityPageLoadCount, 0); 448 pref->SetInteger(prefs::kStabilityPageLoadCount, 0);
420 } 449 }
421 450
422 count = pref->GetInteger(prefs::kStabilityRendererCrashCount); 451 count = pref->GetInteger(prefs::kStabilityRendererCrashCount);
423 if (count) { 452 if (count) {
424 WriteIntAttribute("renderercrashcount", count); 453 WriteIntAttribute("renderercrashcount", count);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 498
470 int64 recent_duration = GetIncrementalUptime(pref); 499 int64 recent_duration = GetIncrementalUptime(pref);
471 if (recent_duration) { 500 if (recent_duration) {
472 WriteInt64Attribute("uptimesec", recent_duration); 501 WriteInt64Attribute("uptimesec", recent_duration);
473 stability->set_uptime_sec(recent_duration); 502 stability->set_uptime_sec(recent_duration);
474 } 503 }
475 } 504 }
476 505
477 void MetricsLog::WritePluginList( 506 void MetricsLog::WritePluginList(
478 const std::vector<webkit::WebPluginInfo>& plugin_list) { 507 const std::vector<webkit::WebPluginInfo>& plugin_list) {
479 DCHECK(!locked_); 508 DCHECK(!locked());
480 509
481 PluginPrefs* plugin_prefs = GetPluginPrefs(); 510 PluginPrefs* plugin_prefs = GetPluginPrefs();
482 511
483 OPEN_ELEMENT_FOR_SCOPE("plugins"); 512 OPEN_ELEMENT_FOR_SCOPE("plugins");
484 SystemProfileProto* system_profile = uma_proto_.mutable_system_profile(); 513 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile();
485 for (std::vector<webkit::WebPluginInfo>::const_iterator iter = 514 for (std::vector<webkit::WebPluginInfo>::const_iterator iter =
486 plugin_list.begin(); 515 plugin_list.begin();
487 iter != plugin_list.end(); ++iter) { 516 iter != plugin_list.end(); ++iter) {
488 std::string base64_name_hash; 517 std::string base64_name_hash;
489 uint64 numeric_name_hash_ignored; 518 uint64 numeric_name_hash_ignored;
490 CreateHashes(UTF16ToUTF8(iter->name), 519 CreateHashes(UTF16ToUTF8(iter->name),
491 &base64_name_hash, 520 &base64_name_hash,
492 &numeric_name_hash_ignored); 521 &numeric_name_hash_ignored);
493 522
494 std::string filename_bytes = iter->path.BaseName().AsUTF8Unsafe(); 523 std::string filename_bytes = iter->path.BaseName().AsUTF8Unsafe();
(...skipping 14 matching lines...) Expand all
509 if (plugin_prefs) 538 if (plugin_prefs)
510 WriteIntAttribute("disabled", !plugin_prefs->IsPluginEnabled(*iter)); 539 WriteIntAttribute("disabled", !plugin_prefs->IsPluginEnabled(*iter));
511 540
512 // Write the protobuf version. 541 // Write the protobuf version.
513 SystemProfileProto::Plugin* plugin = system_profile->add_plugin(); 542 SystemProfileProto::Plugin* plugin = system_profile->add_plugin();
514 SetPluginInfo(*iter, plugin_prefs, plugin); 543 SetPluginInfo(*iter, plugin_prefs, plugin);
515 } 544 }
516 } 545 }
517 546
518 void MetricsLog::WriteInstallElement() { 547 void MetricsLog::WriteInstallElement() {
519 std::string install_date = GetInstallDate(); 548 std::string install_date = GetInstallDate(GetPrefService());
520 549
521 // Write the XML version. 550 // Write the XML version.
522 OPEN_ELEMENT_FOR_SCOPE("install"); 551 OPEN_ELEMENT_FOR_SCOPE("install");
523 WriteAttribute("installdate", install_date); 552 WriteAttribute("installdate", install_date);
524 WriteIntAttribute("buildid", 0); // We're using appversion instead. 553 WriteIntAttribute("buildid", 0); // We're using appversion instead.
525 554
526 // Write the protobuf version. 555 // Write the protobuf version.
527 int numeric_install_date; 556 int numeric_install_date;
528 bool success = base::StringToInt(install_date, &numeric_install_date); 557 bool success = base::StringToInt(install_date, &numeric_install_date);
529 DCHECK(success); 558 DCHECK(success);
530 uma_proto_.mutable_system_profile()->set_install_date(numeric_install_date); 559 uma_proto()->mutable_system_profile()->set_install_date(numeric_install_date);
531 } 560 }
532 561
533 void MetricsLog::RecordEnvironment( 562 void MetricsLog::RecordEnvironment(
534 const std::vector<webkit::WebPluginInfo>& plugin_list, 563 const std::vector<webkit::WebPluginInfo>& plugin_list,
535 const DictionaryValue* profile_metrics) { 564 const DictionaryValue* profile_metrics) {
536 DCHECK(!locked_); 565 DCHECK(!locked());
537 566
538 PrefService* pref = g_browser_process->local_state(); 567 PrefService* pref = GetPrefService();
539 568
540 OPEN_ELEMENT_FOR_SCOPE("profile"); 569 OPEN_ELEMENT_FOR_SCOPE("profile");
541 WriteCommonEventAttributes(); 570 WriteCommonEventAttributes();
542 571
543 WriteInstallElement(); 572 WriteInstallElement();
544 573
545 WritePluginList(plugin_list); 574 WritePluginList(plugin_list);
546 575
547 WriteStabilityElement(plugin_list, pref); 576 WriteStabilityElement(plugin_list, pref);
548 577
549 SystemProfileProto* system_profile = uma_proto_.mutable_system_profile(); 578 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile();
550 system_profile->set_application_locale( 579 system_profile->set_application_locale(
551 content::GetContentClient()->browser()->GetApplicationLocale()); 580 content::GetContentClient()->browser()->GetApplicationLocale());
552 581
553 SystemProfileProto::Hardware* hardware = system_profile->mutable_hardware(); 582 SystemProfileProto::Hardware* hardware = system_profile->mutable_hardware();
554 { 583 {
555 std::string cpu_architecture = base::SysInfo::CPUArchitecture(); 584 std::string cpu_architecture = base::SysInfo::CPUArchitecture();
556 585
557 // Write the XML version. 586 // Write the XML version.
558 OPEN_ELEMENT_FOR_SCOPE("cpu"); 587 OPEN_ELEMENT_FOR_SCOPE("cpu");
559 WriteAttribute("arch", cpu_architecture); 588 WriteAttribute("arch", cpu_architecture);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 gpu->set_driver_version(gpu_info.driver_version); 641 gpu->set_driver_version(gpu_info.driver_version);
613 gpu->set_driver_date(gpu_info.driver_date); 642 gpu->set_driver_date(gpu_info.driver_date);
614 SystemProfileProto::Hardware::Graphics::PerformanceStatistics* 643 SystemProfileProto::Hardware::Graphics::PerformanceStatistics*
615 gpu_performance = gpu->mutable_performance_statistics(); 644 gpu_performance = gpu->mutable_performance_statistics();
616 gpu_performance->set_graphics_score(gpu_performance_stats.graphics); 645 gpu_performance->set_graphics_score(gpu_performance_stats.graphics);
617 gpu_performance->set_gaming_score(gpu_performance_stats.gaming); 646 gpu_performance->set_gaming_score(gpu_performance_stats.gaming);
618 gpu_performance->set_overall_score(gpu_performance_stats.overall); 647 gpu_performance->set_overall_score(gpu_performance_stats.overall);
619 } 648 }
620 649
621 { 650 {
622 const gfx::Size display_size = gfx::Screen::GetPrimaryMonitorSize(); 651 const gfx::Size display_size = GetScreenSize();
623 int display_width = display_size.width(); 652 int display_width = display_size.width();
624 int display_height = display_size.height(); 653 int display_height = display_size.height();
625 int screen_count = gfx::Screen::GetNumMonitors(); 654 int screen_count = GetScreenCount();
626 655
627 // Write the XML version. 656 // Write the XML version.
628 OPEN_ELEMENT_FOR_SCOPE("display"); 657 OPEN_ELEMENT_FOR_SCOPE("display");
629 WriteIntAttribute("xsize", display_width); 658 WriteIntAttribute("xsize", display_width);
630 WriteIntAttribute("ysize", display_height); 659 WriteIntAttribute("ysize", display_height);
631 WriteIntAttribute("screens", screen_count); 660 WriteIntAttribute("screens", screen_count);
632 661
633 // Write the protobuf version. 662 // Write the protobuf version.
634 hardware->set_primary_screen_width(display_width); 663 hardware->set_primary_screen_width(display_width);
635 hardware->set_primary_screen_height(display_height); 664 hardware->set_primary_screen_height(display_height);
(...skipping 27 matching lines...) Expand all
663 } 692 }
664 } 693 }
665 694
666 { 695 {
667 OPEN_ELEMENT_FOR_SCOPE("keywords"); 696 OPEN_ELEMENT_FOR_SCOPE("keywords");
668 WriteIntAttribute("count", pref->GetInteger(prefs::kNumKeywords)); 697 WriteIntAttribute("count", pref->GetInteger(prefs::kNumKeywords));
669 } 698 }
670 699
671 if (profile_metrics) 700 if (profile_metrics)
672 WriteAllProfilesMetrics(*profile_metrics); 701 WriteAllProfilesMetrics(*profile_metrics);
702
703 std::vector<NameGroupId> field_trial_ids;
704 GetFieldTrialIds(&field_trial_ids);
705 WriteFieldTrials(field_trial_ids, system_profile);
673 } 706 }
674 707
675 void MetricsLog::WriteAllProfilesMetrics( 708 void MetricsLog::WriteAllProfilesMetrics(
676 const DictionaryValue& all_profiles_metrics) { 709 const DictionaryValue& all_profiles_metrics) {
677 const std::string profile_prefix(prefs::kProfilePrefix); 710 const std::string profile_prefix(prefs::kProfilePrefix);
678 for (DictionaryValue::key_iterator i = all_profiles_metrics.begin_keys(); 711 for (DictionaryValue::key_iterator i = all_profiles_metrics.begin_keys();
679 i != all_profiles_metrics.end_keys(); ++i) { 712 i != all_profiles_metrics.end_keys(); ++i) {
680 const std::string& key_name = *i; 713 const std::string& key_name = *i;
681 if (key_name.compare(0, profile_prefix.size(), profile_prefix) == 0) { 714 if (key_name.compare(0, profile_prefix.size(), profile_prefix) == 0) {
682 DictionaryValue* profile; 715 DictionaryValue* profile;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 762
730 default: 763 default:
731 NOTREACHED(); 764 NOTREACHED();
732 break; 765 break;
733 } 766 }
734 } 767 }
735 } 768 }
736 } 769 }
737 770
738 void MetricsLog::RecordOmniboxOpenedURL(const AutocompleteLog& log) { 771 void MetricsLog::RecordOmniboxOpenedURL(const AutocompleteLog& log) {
739 DCHECK(!locked_); 772 DCHECK(!locked());
740 773
741 // Write the XML version. 774 // Write the XML version.
742 OPEN_ELEMENT_FOR_SCOPE("uielement"); 775 OPEN_ELEMENT_FOR_SCOPE("uielement");
743 WriteAttribute("action", "autocomplete"); 776 WriteAttribute("action", "autocomplete");
744 WriteAttribute("targetidhash", ""); 777 WriteAttribute("targetidhash", "");
745 // TODO(kochi): Properly track windows. 778 // TODO(kochi): Properly track windows.
746 WriteIntAttribute("window", 0); 779 WriteIntAttribute("window", 0);
747 if (log.tab_id != -1) { 780 if (log.tab_id != -1) {
748 // If we know what tab the autocomplete URL was opened in, log it. 781 // If we know what tab the autocomplete URL was opened in, log it.
749 WriteIntAttribute("tab", static_cast<int>(log.tab_id)); 782 WriteIntAttribute("tab", static_cast<int>(log.tab_id));
(...skipping 28 matching lines...) Expand all
778 WriteAttribute("provider", i->provider->name()); 811 WriteAttribute("provider", i->provider->name());
779 const std::string result_type(AutocompleteMatch::TypeToString(i->type)); 812 const std::string result_type(AutocompleteMatch::TypeToString(i->type));
780 if (!result_type.empty()) 813 if (!result_type.empty())
781 WriteAttribute("resulttype", result_type); 814 WriteAttribute("resulttype", result_type);
782 WriteIntAttribute("relevance", i->relevance); 815 WriteIntAttribute("relevance", i->relevance);
783 WriteIntAttribute("isstarred", i->starred ? 1 : 0); 816 WriteIntAttribute("isstarred", i->starred ? 1 : 0);
784 } 817 }
785 } 818 }
786 819
787 // Write the protobuf version. 820 // Write the protobuf version.
788 OmniboxEventProto* omnibox_event = uma_proto_.add_omnibox_event(); 821 OmniboxEventProto* omnibox_event = uma_proto()->add_omnibox_event();
789 omnibox_event->set_time(MetricsLogBase::GetCurrentTime()); 822 omnibox_event->set_time(MetricsLogBase::GetCurrentTime());
790 if (log.tab_id != -1) { 823 if (log.tab_id != -1) {
791 // If we know what tab the autocomplete URL was opened in, log it. 824 // If we know what tab the autocomplete URL was opened in, log it.
792 omnibox_event->set_tab_id(log.tab_id); 825 omnibox_event->set_tab_id(log.tab_id);
793 } 826 }
794 omnibox_event->set_typed_length(log.text.length()); 827 omnibox_event->set_typed_length(log.text.length());
795 omnibox_event->set_selected_index(log.selected_index); 828 omnibox_event->set_selected_index(log.selected_index);
796 omnibox_event->set_completed_length(log.inline_autocompleted_length); 829 omnibox_event->set_completed_length(log.inline_autocompleted_length);
797 omnibox_event->set_input_type(AsOmniboxEventInputType(log.input_type)); 830 omnibox_event->set_input_type(AsOmniboxEventInputType(log.input_type));
798 for (AutocompleteResult::const_iterator i(log.result.begin()); 831 for (AutocompleteResult::const_iterator i(log.result.begin());
799 i != log.result.end(); ++i) { 832 i != log.result.end(); ++i) {
800 OmniboxEventProto::Suggestion* suggestion = omnibox_event->add_suggestion(); 833 OmniboxEventProto::Suggestion* suggestion = omnibox_event->add_suggestion();
801 suggestion->set_provider(AsOmniboxEventProviderType(i->provider)); 834 suggestion->set_provider(AsOmniboxEventProviderType(i->provider));
802 suggestion->set_result_type(AsOmniboxEventResultType(i->type)); 835 suggestion->set_result_type(AsOmniboxEventResultType(i->type));
803 suggestion->set_relevance(i->relevance); 836 suggestion->set_relevance(i->relevance);
804 suggestion->set_is_starred(i->starred); 837 suggestion->set_is_starred(i->starred);
805 } 838 }
806 839
807 ++num_events_; 840 ++num_events_;
808 } 841 }
OLDNEW
« no previous file with comments | « chrome/browser/metrics/metrics_log.h ('k') | chrome/browser/metrics/metrics_log_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698