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

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

Issue 11615002: Exclude PluginService for builds with enable_plugins==0 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years 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
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 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 333
334 OPEN_ELEMENT_FOR_SCOPE("profile"); 334 OPEN_ELEMENT_FOR_SCOPE("profile");
335 WriteCommonEventAttributes(); 335 WriteCommonEventAttributes();
336 336
337 WriteInstallElement(); 337 WriteInstallElement();
338 338
339 { 339 {
340 OPEN_ELEMENT_FOR_SCOPE("stability"); // Minimal set of stability elements. 340 OPEN_ELEMENT_FOR_SCOPE("stability"); // Minimal set of stability elements.
341 WriteRequiredStabilityAttributes(pref); 341 WriteRequiredStabilityAttributes(pref);
342 WriteRealtimeStabilityAttributes(pref); 342 WriteRealtimeStabilityAttributes(pref);
343
344 WritePluginStabilityElements(plugin_list, pref); 343 WritePluginStabilityElements(plugin_list, pref);
345 } 344 }
346 } 345 }
347 346
348 PrefService* MetricsLog::GetPrefService() { 347 PrefService* MetricsLog::GetPrefService() {
349 return g_browser_process->local_state(); 348 return g_browser_process->local_state();
350 } 349 }
351 350
352 gfx::Size MetricsLog::GetScreenSize() const { 351 gfx::Size MetricsLog::GetScreenSize() const {
353 return gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().GetSizeInPixel(); 352 return gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().GetSizeInPixel();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 void MetricsLog::WritePluginStabilityElements( 425 void MetricsLog::WritePluginStabilityElements(
427 const std::vector<webkit::WebPluginInfo>& plugin_list, 426 const std::vector<webkit::WebPluginInfo>& plugin_list,
428 PrefService* pref) { 427 PrefService* pref) {
429 // Now log plugin stability info. 428 // Now log plugin stability info.
430 const ListValue* plugin_stats_list = pref->GetList( 429 const ListValue* plugin_stats_list = pref->GetList(
431 prefs::kStabilityPluginStats); 430 prefs::kStabilityPluginStats);
432 if (!plugin_stats_list) 431 if (!plugin_stats_list)
433 return; 432 return;
434 433
435 OPEN_ELEMENT_FOR_SCOPE("plugins"); 434 OPEN_ELEMENT_FOR_SCOPE("plugins");
435
436 #if defined(ENABLE_PLUGINS)
436 SystemProfileProto::Stability* stability = 437 SystemProfileProto::Stability* stability =
437 uma_proto()->mutable_system_profile()->mutable_stability(); 438 uma_proto()->mutable_system_profile()->mutable_stability();
438 PluginPrefs* plugin_prefs = GetPluginPrefs(); 439 PluginPrefs* plugin_prefs = GetPluginPrefs();
439 for (ListValue::const_iterator iter = plugin_stats_list->begin(); 440 for (ListValue::const_iterator iter = plugin_stats_list->begin();
440 iter != plugin_stats_list->end(); ++iter) { 441 iter != plugin_stats_list->end(); ++iter) {
441 if (!(*iter)->IsType(Value::TYPE_DICTIONARY)) { 442 if (!(*iter)->IsType(Value::TYPE_DICTIONARY)) {
442 NOTREACHED(); 443 NOTREACHED();
443 continue; 444 continue;
444 } 445 }
445 DictionaryValue* plugin_dict = static_cast<DictionaryValue*>(*iter); 446 DictionaryValue* plugin_dict = static_cast<DictionaryValue*>(*iter);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 // Write the protobuf version. 499 // Write the protobuf version.
499 SystemProfileProto::Stability::PluginStability* plugin_stability = 500 SystemProfileProto::Stability::PluginStability* plugin_stability =
500 stability->add_plugin_stability(); 501 stability->add_plugin_stability();
501 SetPluginInfo(*plugin_info, plugin_prefs, 502 SetPluginInfo(*plugin_info, plugin_prefs,
502 plugin_stability->mutable_plugin()); 503 plugin_stability->mutable_plugin());
503 plugin_stability->set_launch_count(launches); 504 plugin_stability->set_launch_count(launches);
504 plugin_stability->set_instance_count(instances); 505 plugin_stability->set_instance_count(instances);
505 plugin_stability->set_crash_count(crashes); 506 plugin_stability->set_crash_count(crashes);
506 plugin_stability->set_loading_error_count(loading_errors); 507 plugin_stability->set_loading_error_count(loading_errors);
507 } 508 }
509 #endif // defined(ENABLE_PLUGINS)
508 510
509 pref->ClearPref(prefs::kStabilityPluginStats); 511 pref->ClearPref(prefs::kStabilityPluginStats);
510 } 512 }
511 513
512 // The server refuses data that doesn't have certain values. crashcount and 514 // The server refuses data that doesn't have certain values. crashcount and
513 // launchcount are currently "required" in the "stability" group. 515 // launchcount are currently "required" in the "stability" group.
514 // TODO(isherman): Stop writing these attributes specially once the migration to 516 // TODO(isherman): Stop writing these attributes specially once the migration to
515 // protobufs is complete. 517 // protobufs is complete.
516 void MetricsLog::WriteRequiredStabilityAttributes(PrefService* pref) { 518 void MetricsLog::WriteRequiredStabilityAttributes(PrefService* pref) {
517 int launch_count = pref->GetInteger(prefs::kStabilityLaunchCount); 519 int launch_count = pref->GetInteger(prefs::kStabilityLaunchCount);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 WriteInt64Attribute("uptimesec", recent_duration); 599 WriteInt64Attribute("uptimesec", recent_duration);
598 stability->set_uptime_sec(recent_duration); 600 stability->set_uptime_sec(recent_duration);
599 } 601 }
600 } 602 }
601 603
602 void MetricsLog::WritePluginList( 604 void MetricsLog::WritePluginList(
603 const std::vector<webkit::WebPluginInfo>& plugin_list, 605 const std::vector<webkit::WebPluginInfo>& plugin_list,
604 bool write_as_xml) { 606 bool write_as_xml) {
605 DCHECK(!locked()); 607 DCHECK(!locked());
606 608
609 OPEN_ELEMENT_FOR_SCOPE("plugins");
610
611 #if defined(ENABLE_PLUGINS)
607 PluginPrefs* plugin_prefs = GetPluginPrefs(); 612 PluginPrefs* plugin_prefs = GetPluginPrefs();
608
609 OPEN_ELEMENT_FOR_SCOPE("plugins");
610 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile(); 613 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile();
611 for (std::vector<webkit::WebPluginInfo>::const_iterator iter = 614 for (std::vector<webkit::WebPluginInfo>::const_iterator iter =
612 plugin_list.begin(); 615 plugin_list.begin();
613 iter != plugin_list.end(); ++iter) { 616 iter != plugin_list.end(); ++iter) {
614 if (write_as_xml) { 617 if (write_as_xml) {
615 std::string base64_name_hash; 618 std::string base64_name_hash;
616 uint64 numeric_hash_ignored; 619 uint64 numeric_hash_ignored;
617 CreateHashes(UTF16ToUTF8(iter->name), &base64_name_hash, 620 CreateHashes(UTF16ToUTF8(iter->name), &base64_name_hash,
618 &numeric_hash_ignored); 621 &numeric_hash_ignored);
619 622
(...skipping 11 matching lines...) Expand all
631 WriteAttribute("filename", base64_filename_hash); 634 WriteAttribute("filename", base64_filename_hash);
632 WriteAttribute("version", UTF16ToUTF8(iter->version)); 635 WriteAttribute("version", UTF16ToUTF8(iter->version));
633 if (plugin_prefs) 636 if (plugin_prefs)
634 WriteIntAttribute("disabled", !plugin_prefs->IsPluginEnabled(*iter)); 637 WriteIntAttribute("disabled", !plugin_prefs->IsPluginEnabled(*iter));
635 } else { 638 } else {
636 // Write the protobuf version. 639 // Write the protobuf version.
637 SystemProfileProto::Plugin* plugin = system_profile->add_plugin(); 640 SystemProfileProto::Plugin* plugin = system_profile->add_plugin();
638 SetPluginInfo(*iter, plugin_prefs, plugin); 641 SetPluginInfo(*iter, plugin_prefs, plugin);
639 } 642 }
640 } 643 }
644 #endif // defined(ENABLE_PLUGINS)
641 } 645 }
642 646
643 void MetricsLog::WriteInstallElement() { 647 void MetricsLog::WriteInstallElement() {
644 // Write the XML version. 648 // Write the XML version.
645 // We'll write the protobuf version in RecordEnvironmentProto(). 649 // We'll write the protobuf version in RecordEnvironmentProto().
646 OPEN_ELEMENT_FOR_SCOPE("install"); 650 OPEN_ELEMENT_FOR_SCOPE("install");
647 WriteAttribute("installdate", GetMetricsEnabledDate(GetPrefService())); 651 WriteAttribute("installdate", GetMetricsEnabledDate(GetPrefService()));
648 WriteIntAttribute("buildid", 0); // We're using appversion instead. 652 WriteIntAttribute("buildid", 0); // We're using appversion instead.
649 } 653 }
650 654
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 ProductDataToProto(google_update_metrics.google_update_data, 1029 ProductDataToProto(google_update_metrics.google_update_data,
1026 google_update->mutable_google_update_status()); 1030 google_update->mutable_google_update_status());
1027 } 1031 }
1028 1032
1029 if (!google_update_metrics.product_data.version.empty()) { 1033 if (!google_update_metrics.product_data.version.empty()) {
1030 ProductDataToProto(google_update_metrics.product_data, 1034 ProductDataToProto(google_update_metrics.product_data,
1031 google_update->mutable_client_status()); 1035 google_update->mutable_client_status());
1032 } 1036 }
1033 #endif // defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN) 1037 #endif // defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN)
1034 } 1038 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service_unittest.cc ('k') | chrome/browser/metrics/metrics_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698