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

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

Issue 19894003: Move webplugininfo.h to content/public. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 5 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
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 <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 26 matching lines...) Expand all
37 #include "chrome/common/logging_chrome.h" 37 #include "chrome/common/logging_chrome.h"
38 #include "chrome/common/metrics/proto/omnibox_event.pb.h" 38 #include "chrome/common/metrics/proto/omnibox_event.pb.h"
39 #include "chrome/common/metrics/proto/profiler_event.pb.h" 39 #include "chrome/common/metrics/proto/profiler_event.pb.h"
40 #include "chrome/common/metrics/proto/system_profile.pb.h" 40 #include "chrome/common/metrics/proto/system_profile.pb.h"
41 #include "chrome/common/metrics/variations/variations_util.h" 41 #include "chrome/common/metrics/variations/variations_util.h"
42 #include "chrome/common/pref_names.h" 42 #include "chrome/common/pref_names.h"
43 #include "chrome/installer/util/google_update_settings.h" 43 #include "chrome/installer/util/google_update_settings.h"
44 #include "components/nacl/common/nacl_process_type.h" 44 #include "components/nacl/common/nacl_process_type.h"
45 #include "content/public/browser/gpu_data_manager.h" 45 #include "content/public/browser/gpu_data_manager.h"
46 #include "content/public/common/content_client.h" 46 #include "content/public/common/content_client.h"
47 #include "content/public/common/webplugininfo.h"
47 #include "device/bluetooth/bluetooth_adapter.h" 48 #include "device/bluetooth/bluetooth_adapter.h"
48 #include "device/bluetooth/bluetooth_adapter_factory.h" 49 #include "device/bluetooth/bluetooth_adapter_factory.h"
49 #include "device/bluetooth/bluetooth_device.h" 50 #include "device/bluetooth/bluetooth_device.h"
50 #include "gpu/config/gpu_info.h" 51 #include "gpu/config/gpu_info.h"
51 #include "ui/gfx/screen.h" 52 #include "ui/gfx/screen.h"
52 #include "url/gurl.h" 53 #include "url/gurl.h"
53 #include "webkit/plugins/webplugininfo.h"
54 54
55 #if defined(OS_ANDROID) 55 #if defined(OS_ANDROID)
56 #include "base/android/build_info.h" 56 #include "base/android/build_info.h"
57 #endif 57 #endif
58 58
59 #if defined(OS_WIN) 59 #if defined(OS_WIN)
60 #include "base/win/metro.h" 60 #include "base/win/metro.h"
61 #include "ui/base/win/dpi.h" 61 #include "ui/base/win/dpi.h"
62 62
63 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx 63 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 } 186 }
187 187
188 std::vector<Profile*> profiles = profile_manager->GetLoadedProfiles(); 188 std::vector<Profile*> profiles = profile_manager->GetLoadedProfiles();
189 if (profiles.empty()) 189 if (profiles.empty())
190 return NULL; 190 return NULL;
191 191
192 return PluginPrefs::GetForProfile(profiles.front()).get(); 192 return PluginPrefs::GetForProfile(profiles.front()).get();
193 } 193 }
194 194
195 // Fills |plugin| with the info contained in |plugin_info| and |plugin_prefs|. 195 // Fills |plugin| with the info contained in |plugin_info| and |plugin_prefs|.
196 void SetPluginInfo(const webkit::WebPluginInfo& plugin_info, 196 void SetPluginInfo(const content::WebPluginInfo& plugin_info,
197 const PluginPrefs* plugin_prefs, 197 const PluginPrefs* plugin_prefs,
198 SystemProfileProto::Plugin* plugin) { 198 SystemProfileProto::Plugin* plugin) {
199 plugin->set_name(UTF16ToUTF8(plugin_info.name)); 199 plugin->set_name(UTF16ToUTF8(plugin_info.name));
200 plugin->set_filename(plugin_info.path.BaseName().AsUTF8Unsafe()); 200 plugin->set_filename(plugin_info.path.BaseName().AsUTF8Unsafe());
201 plugin->set_version(UTF16ToUTF8(plugin_info.version)); 201 plugin->set_version(UTF16ToUTF8(plugin_info.version));
202 if (plugin_prefs) 202 if (plugin_prefs)
203 plugin->set_is_disabled(!plugin_prefs->IsPluginEnabled(plugin_info)); 203 plugin->set_is_disabled(!plugin_prefs->IsPluginEnabled(plugin_info));
204 } 204 }
205 205
206 void WriteFieldTrials(const std::vector<ActiveGroupId>& field_trial_ids, 206 void WriteFieldTrials(const std::vector<ActiveGroupId>& field_trial_ids,
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 void MetricsLog::set_version_extension(const std::string& extension) { 398 void MetricsLog::set_version_extension(const std::string& extension) {
399 g_version_extension.Get() = extension; 399 g_version_extension.Get() = extension;
400 } 400 }
401 401
402 // static 402 // static
403 const std::string& MetricsLog::version_extension() { 403 const std::string& MetricsLog::version_extension() {
404 return g_version_extension.Get(); 404 return g_version_extension.Get();
405 } 405 }
406 406
407 void MetricsLog::RecordIncrementalStabilityElements( 407 void MetricsLog::RecordIncrementalStabilityElements(
408 const std::vector<webkit::WebPluginInfo>& plugin_list) { 408 const std::vector<content::WebPluginInfo>& plugin_list) {
409 DCHECK(!locked()); 409 DCHECK(!locked());
410 410
411 PrefService* pref = GetPrefService(); 411 PrefService* pref = GetPrefService();
412 DCHECK(pref); 412 DCHECK(pref);
413 413
414 WriteRequiredStabilityAttributes(pref); 414 WriteRequiredStabilityAttributes(pref);
415 WriteRealtimeStabilityAttributes(pref); 415 WriteRealtimeStabilityAttributes(pref);
416 WritePluginStabilityElements(plugin_list, pref); 416 WritePluginStabilityElements(plugin_list, pref);
417 } 417 }
418 418
(...skipping 14 matching lines...) Expand all
433 // TODO(scottmg): NativeScreen maybe wrong. http://crbug.com/133312 433 // TODO(scottmg): NativeScreen maybe wrong. http://crbug.com/133312
434 return gfx::Screen::GetNativeScreen()->GetNumDisplays(); 434 return gfx::Screen::GetNativeScreen()->GetNumDisplays();
435 } 435 }
436 436
437 void MetricsLog::GetFieldTrialIds( 437 void MetricsLog::GetFieldTrialIds(
438 std::vector<ActiveGroupId>* field_trial_ids) const { 438 std::vector<ActiveGroupId>* field_trial_ids) const {
439 chrome_variations::GetFieldTrialActiveGroupIds(field_trial_ids); 439 chrome_variations::GetFieldTrialActiveGroupIds(field_trial_ids);
440 } 440 }
441 441
442 void MetricsLog::WriteStabilityElement( 442 void MetricsLog::WriteStabilityElement(
443 const std::vector<webkit::WebPluginInfo>& plugin_list, 443 const std::vector<content::WebPluginInfo>& plugin_list,
444 PrefService* pref) { 444 PrefService* pref) {
445 DCHECK(!locked()); 445 DCHECK(!locked());
446 446
447 // Get stability attributes out of Local State, zeroing out stored values. 447 // Get stability attributes out of Local State, zeroing out stored values.
448 // NOTE: This could lead to some data loss if this report isn't successfully 448 // NOTE: This could lead to some data loss if this report isn't successfully
449 // sent, but that's true for all the metrics. 449 // sent, but that's true for all the metrics.
450 450
451 WriteRequiredStabilityAttributes(pref); 451 WriteRequiredStabilityAttributes(pref);
452 WriteRealtimeStabilityAttributes(pref); 452 WriteRealtimeStabilityAttributes(pref);
453 453
(...skipping 22 matching lines...) Expand all
476 breakpad_registration_success_count); 476 breakpad_registration_success_count);
477 stability->set_breakpad_registration_failure_count( 477 stability->set_breakpad_registration_failure_count(
478 breakpad_registration_failure_count); 478 breakpad_registration_failure_count);
479 stability->set_debugger_present_count(debugger_present_count); 479 stability->set_debugger_present_count(debugger_present_count);
480 stability->set_debugger_not_present_count(debugger_not_present_count); 480 stability->set_debugger_not_present_count(debugger_not_present_count);
481 481
482 WritePluginStabilityElements(plugin_list, pref); 482 WritePluginStabilityElements(plugin_list, pref);
483 } 483 }
484 484
485 void MetricsLog::WritePluginStabilityElements( 485 void MetricsLog::WritePluginStabilityElements(
486 const std::vector<webkit::WebPluginInfo>& plugin_list, 486 const std::vector<content::WebPluginInfo>& plugin_list,
487 PrefService* pref) { 487 PrefService* pref) {
488 // Now log plugin stability info. 488 // Now log plugin stability info.
489 const ListValue* plugin_stats_list = pref->GetList( 489 const ListValue* plugin_stats_list = pref->GetList(
490 prefs::kStabilityPluginStats); 490 prefs::kStabilityPluginStats);
491 if (!plugin_stats_list) 491 if (!plugin_stats_list)
492 return; 492 return;
493 493
494 #if defined(ENABLE_PLUGINS) 494 #if defined(ENABLE_PLUGINS)
495 SystemProfileProto::Stability* stability = 495 SystemProfileProto::Stability* stability =
496 uma_proto()->mutable_system_profile()->mutable_stability(); 496 uma_proto()->mutable_system_profile()->mutable_stability();
497 PluginPrefs* plugin_prefs = GetPluginPrefs(); 497 PluginPrefs* plugin_prefs = GetPluginPrefs();
498 for (ListValue::const_iterator iter = plugin_stats_list->begin(); 498 for (ListValue::const_iterator iter = plugin_stats_list->begin();
499 iter != plugin_stats_list->end(); ++iter) { 499 iter != plugin_stats_list->end(); ++iter) {
500 if (!(*iter)->IsType(Value::TYPE_DICTIONARY)) { 500 if (!(*iter)->IsType(Value::TYPE_DICTIONARY)) {
501 NOTREACHED(); 501 NOTREACHED();
502 continue; 502 continue;
503 } 503 }
504 DictionaryValue* plugin_dict = static_cast<DictionaryValue*>(*iter); 504 DictionaryValue* plugin_dict = static_cast<DictionaryValue*>(*iter);
505 505
506 // Write the protobuf version. 506 // Write the protobuf version.
507 // Note that this search is potentially a quadratic operation, but given the 507 // Note that this search is potentially a quadratic operation, but given the
508 // low number of plugins installed on a "reasonable" setup, this should be 508 // low number of plugins installed on a "reasonable" setup, this should be
509 // fine. 509 // fine.
510 // TODO(isherman): Verify that this does not show up as a hotspot in 510 // TODO(isherman): Verify that this does not show up as a hotspot in
511 // profiler runs. 511 // profiler runs.
512 const webkit::WebPluginInfo* plugin_info = NULL; 512 const content::WebPluginInfo* plugin_info = NULL;
513 std::string plugin_name; 513 std::string plugin_name;
514 plugin_dict->GetString(prefs::kStabilityPluginName, &plugin_name); 514 plugin_dict->GetString(prefs::kStabilityPluginName, &plugin_name);
515 const string16 plugin_name_utf16 = UTF8ToUTF16(plugin_name); 515 const string16 plugin_name_utf16 = UTF8ToUTF16(plugin_name);
516 for (std::vector<webkit::WebPluginInfo>::const_iterator iter = 516 for (std::vector<content::WebPluginInfo>::const_iterator iter =
517 plugin_list.begin(); 517 plugin_list.begin();
518 iter != plugin_list.end(); ++iter) { 518 iter != plugin_list.end(); ++iter) {
519 if (iter->name == plugin_name_utf16) { 519 if (iter->name == plugin_name_utf16) {
520 plugin_info = &(*iter); 520 plugin_info = &(*iter);
521 break; 521 break;
522 } 522 }
523 } 523 }
524 524
525 if (!plugin_info) { 525 if (!plugin_info) {
526 NOTREACHED(); 526 NOTREACHED();
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 pref->SetInteger(prefs::kStabilitySystemUncleanShutdownCount, 0); 630 pref->SetInteger(prefs::kStabilitySystemUncleanShutdownCount, 0);
631 } 631 }
632 #endif // OS_CHROMEOS 632 #endif // OS_CHROMEOS
633 633
634 int64 recent_duration = GetIncrementalUptime(pref); 634 int64 recent_duration = GetIncrementalUptime(pref);
635 if (recent_duration) 635 if (recent_duration)
636 stability->set_uptime_sec(recent_duration); 636 stability->set_uptime_sec(recent_duration);
637 } 637 }
638 638
639 void MetricsLog::WritePluginList( 639 void MetricsLog::WritePluginList(
640 const std::vector<webkit::WebPluginInfo>& plugin_list) { 640 const std::vector<content::WebPluginInfo>& plugin_list) {
641 DCHECK(!locked()); 641 DCHECK(!locked());
642 642
643 #if defined(ENABLE_PLUGINS) 643 #if defined(ENABLE_PLUGINS)
644 PluginPrefs* plugin_prefs = GetPluginPrefs(); 644 PluginPrefs* plugin_prefs = GetPluginPrefs();
645 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile(); 645 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile();
646 for (std::vector<webkit::WebPluginInfo>::const_iterator iter = 646 for (std::vector<content::WebPluginInfo>::const_iterator iter =
647 plugin_list.begin(); 647 plugin_list.begin();
648 iter != plugin_list.end(); ++iter) { 648 iter != plugin_list.end(); ++iter) {
649 SystemProfileProto::Plugin* plugin = system_profile->add_plugin(); 649 SystemProfileProto::Plugin* plugin = system_profile->add_plugin();
650 SetPluginInfo(*iter, plugin_prefs, plugin); 650 SetPluginInfo(*iter, plugin_prefs, plugin);
651 } 651 }
652 #endif // defined(ENABLE_PLUGINS) 652 #endif // defined(ENABLE_PLUGINS)
653 } 653 }
654 654
655 void MetricsLog::RecordEnvironment( 655 void MetricsLog::RecordEnvironment(
656 const std::vector<webkit::WebPluginInfo>& plugin_list, 656 const std::vector<content::WebPluginInfo>& plugin_list,
657 const GoogleUpdateMetrics& google_update_metrics) { 657 const GoogleUpdateMetrics& google_update_metrics) {
658 DCHECK(!locked()); 658 DCHECK(!locked());
659 659
660 PrefService* pref = GetPrefService(); 660 PrefService* pref = GetPrefService();
661 WriteStabilityElement(plugin_list, pref); 661 WriteStabilityElement(plugin_list, pref);
662 662
663 RecordEnvironmentProto(plugin_list, google_update_metrics); 663 RecordEnvironmentProto(plugin_list, google_update_metrics);
664 } 664 }
665 665
666 void MetricsLog::RecordEnvironmentProto( 666 void MetricsLog::RecordEnvironmentProto(
667 const std::vector<webkit::WebPluginInfo>& plugin_list, 667 const std::vector<content::WebPluginInfo>& plugin_list,
668 const GoogleUpdateMetrics& google_update_metrics) { 668 const GoogleUpdateMetrics& google_update_metrics) {
669 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile(); 669 SystemProfileProto* system_profile = uma_proto()->mutable_system_profile();
670 670
671 std::string brand_code; 671 std::string brand_code;
672 if (google_util::GetBrand(&brand_code)) 672 if (google_util::GetBrand(&brand_code))
673 system_profile->set_brand_code(brand_code); 673 system_profile->set_brand_code(brand_code);
674 674
675 int enabled_date; 675 int enabled_date;
676 bool success = base::StringToInt(GetMetricsEnabledDate(GetPrefService()), 676 bool success = base::StringToInt(GetMetricsEnabledDate(GetPrefService()),
677 &enabled_date); 677 &enabled_date);
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 918
919 paired_device->set_vendor_prefix(vendor_prefix); 919 paired_device->set_vendor_prefix(vendor_prefix);
920 } 920 }
921 921
922 paired_device->set_vendor_id(device->GetVendorID()); 922 paired_device->set_vendor_id(device->GetVendorID());
923 paired_device->set_product_id(device->GetProductID()); 923 paired_device->set_product_id(device->GetProductID());
924 paired_device->set_device_id(device->GetDeviceID()); 924 paired_device->set_device_id(device->GetDeviceID());
925 } 925 }
926 #endif // defined(OS_CHROMEOS) 926 #endif // defined(OS_CHROMEOS)
927 } 927 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698