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

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

Issue 83023006: Remove plugin_list param from MetricsLog::RecordStabilityMetrics. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 years, 1 month 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 <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 void MetricsLog::set_version_extension(const std::string& extension) { 417 void MetricsLog::set_version_extension(const std::string& extension) {
418 g_version_extension.Get() = extension; 418 g_version_extension.Get() = extension;
419 } 419 }
420 420
421 // static 421 // static
422 const std::string& MetricsLog::version_extension() { 422 const std::string& MetricsLog::version_extension() {
423 return g_version_extension.Get(); 423 return g_version_extension.Get();
424 } 424 }
425 425
426 void MetricsLog::RecordStabilityMetrics( 426 void MetricsLog::RecordStabilityMetrics(
427 const std::vector<content::WebPluginInfo>& plugin_list,
428 base::TimeDelta incremental_uptime, 427 base::TimeDelta incremental_uptime,
429 LogType log_type) { 428 LogType log_type) {
430 DCHECK_NE(NO_LOG, log_type); 429 DCHECK_NE(NO_LOG, log_type);
431 DCHECK(!locked()); 430 DCHECK(!locked());
431 // Check UMA enabled date presence to ensure system profile has been filled.
432 DCHECK(uma_proto()->system_profile().has_uma_enabled_date());
432 433
433 PrefService* pref = GetPrefService(); 434 PrefService* pref = GetPrefService();
434 DCHECK(pref); 435 DCHECK(pref);
435 436
436 // Get stability attributes out of Local State, zeroing out stored values. 437 // Get stability attributes out of Local State, zeroing out stored values.
437 // NOTE: This could lead to some data loss if this report isn't successfully 438 // NOTE: This could lead to some data loss if this report isn't successfully
438 // sent, but that's true for all the metrics. 439 // sent, but that's true for all the metrics.
439 440
440 WriteRequiredStabilityAttributes(pref); 441 WriteRequiredStabilityAttributes(pref);
441 WritePluginStabilityElements(plugin_list, pref); 442 WritePluginStabilityElements(pref);
442 443
443 // Record recent delta for critical stability metrics. We can't wait for a 444 // Record recent delta for critical stability metrics. We can't wait for a
444 // restart to gather these, as that delay biases our observation away from 445 // restart to gather these, as that delay biases our observation away from
445 // users that run happily for a looooong time. We send increments with each 446 // users that run happily for a looooong time. We send increments with each
446 // uma log upload, just as we send histogram data. 447 // uma log upload, just as we send histogram data.
447 WriteRealtimeStabilityAttributes(pref, incremental_uptime); 448 WriteRealtimeStabilityAttributes(pref, incremental_uptime);
448 449
449 // Omit some stats unless this is the initial stability log. 450 // Omit some stats unless this is the initial stability log.
450 if (log_type != INITIAL_LOG) 451 if (log_type != INITIAL_LOG)
451 return; 452 return;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 int MetricsLog::GetScreenCount() const { 496 int MetricsLog::GetScreenCount() const {
496 // TODO(scottmg): NativeScreen maybe wrong. http://crbug.com/133312 497 // TODO(scottmg): NativeScreen maybe wrong. http://crbug.com/133312
497 return gfx::Screen::GetNativeScreen()->GetNumDisplays(); 498 return gfx::Screen::GetNativeScreen()->GetNumDisplays();
498 } 499 }
499 500
500 void MetricsLog::GetFieldTrialIds( 501 void MetricsLog::GetFieldTrialIds(
501 std::vector<ActiveGroupId>* field_trial_ids) const { 502 std::vector<ActiveGroupId>* field_trial_ids) const {
502 chrome_variations::GetFieldTrialActiveGroupIds(field_trial_ids); 503 chrome_variations::GetFieldTrialActiveGroupIds(field_trial_ids);
503 } 504 }
504 505
505 void MetricsLog::WritePluginStabilityElements( 506 void MetricsLog::WritePluginStabilityElements(PrefService* pref) {
506 const std::vector<content::WebPluginInfo>& plugin_list,
507 PrefService* pref) {
508 // Now log plugin stability info. 507 // Now log plugin stability info.
509 const ListValue* plugin_stats_list = pref->GetList( 508 const ListValue* plugin_stats_list = pref->GetList(
510 prefs::kStabilityPluginStats); 509 prefs::kStabilityPluginStats);
511 if (!plugin_stats_list) 510 if (!plugin_stats_list)
512 return; 511 return;
513 512
514 #if defined(ENABLE_PLUGINS) 513 #if defined(ENABLE_PLUGINS)
515 SystemProfileProto::Stability* stability = 514 SystemProfileProto::Stability* stability =
516 uma_proto()->mutable_system_profile()->mutable_stability(); 515 uma_proto()->mutable_system_profile()->mutable_stability();
517 PluginPrefs* plugin_prefs = GetPluginPrefs();
518 for (ListValue::const_iterator iter = plugin_stats_list->begin(); 516 for (ListValue::const_iterator iter = plugin_stats_list->begin();
519 iter != plugin_stats_list->end(); ++iter) { 517 iter != plugin_stats_list->end(); ++iter) {
520 if (!(*iter)->IsType(Value::TYPE_DICTIONARY)) { 518 if (!(*iter)->IsType(Value::TYPE_DICTIONARY)) {
521 NOTREACHED(); 519 NOTREACHED();
522 continue; 520 continue;
523 } 521 }
524 DictionaryValue* plugin_dict = static_cast<DictionaryValue*>(*iter); 522 DictionaryValue* plugin_dict = static_cast<DictionaryValue*>(*iter);
525 523
526 // Write the protobuf version.
527 // Note that this search is potentially a quadratic operation, but given the 524 // Note that this search is potentially a quadratic operation, but given the
528 // low number of plugins installed on a "reasonable" setup, this should be 525 // low number of plugins installed on a "reasonable" setup, this should be
529 // fine. 526 // fine.
530 // TODO(isherman): Verify that this does not show up as a hotspot in 527 // TODO(isherman): Verify that this does not show up as a hotspot in
531 // profiler runs. 528 // profiler runs.
532 const content::WebPluginInfo* plugin_info = NULL; 529 const SystemProfileProto::Plugin* system_profile_plugin = NULL;
533 std::string plugin_name; 530 std::string plugin_name;
534 plugin_dict->GetString(prefs::kStabilityPluginName, &plugin_name); 531 plugin_dict->GetString(prefs::kStabilityPluginName, &plugin_name);
535 const string16 plugin_name_utf16 = UTF8ToUTF16(plugin_name); 532 const SystemProfileProto& system_profile = uma_proto()->system_profile();
536 for (std::vector<content::WebPluginInfo>::const_iterator iter = 533 for (int i = 0; i < system_profile.plugin_size(); ++i) {
537 plugin_list.begin(); 534 if (system_profile.plugin(i).name() == plugin_name) {
538 iter != plugin_list.end(); ++iter) { 535 system_profile_plugin = &system_profile.plugin(i);
539 if (iter->name == plugin_name_utf16) {
540 plugin_info = &(*iter);
541 break; 536 break;
542 } 537 }
543 } 538 }
544 539
545 if (!plugin_info) { 540 if (!system_profile_plugin) {
546 NOTREACHED(); 541 NOTREACHED();
547 continue; 542 continue;
548 } 543 }
549 544
550 SystemProfileProto::Stability::PluginStability* plugin_stability = 545 SystemProfileProto::Stability::PluginStability* plugin_stability =
551 stability->add_plugin_stability(); 546 stability->add_plugin_stability();
552 SetPluginInfo(*plugin_info, plugin_prefs, 547 *plugin_stability->mutable_plugin() = *system_profile_plugin;
553 plugin_stability->mutable_plugin());
554 548
555 int launches = 0; 549 int launches = 0;
556 plugin_dict->GetInteger(prefs::kStabilityPluginLaunches, &launches); 550 plugin_dict->GetInteger(prefs::kStabilityPluginLaunches, &launches);
557 if (launches > 0) 551 if (launches > 0)
558 plugin_stability->set_launch_count(launches); 552 plugin_stability->set_launch_count(launches);
559 553
560 int instances = 0; 554 int instances = 0;
561 plugin_dict->GetInteger(prefs::kStabilityPluginInstances, &instances); 555 plugin_dict->GetInteger(prefs::kStabilityPluginInstances, &instances);
562 if (instances > 0) 556 if (instances > 0)
563 plugin_stability->set_instance_count(instances); 557 plugin_stability->set_instance_count(instances);
(...skipping 28 matching lines...) Expand all
592 uma_proto()->mutable_system_profile()->mutable_stability(); 586 uma_proto()->mutable_system_profile()->mutable_stability();
593 stability->set_launch_count(launch_count); 587 stability->set_launch_count(launch_count);
594 stability->set_crash_count(crash_count); 588 stability->set_crash_count(crash_count);
595 } 589 }
596 590
597 void MetricsLog::WriteRealtimeStabilityAttributes( 591 void MetricsLog::WriteRealtimeStabilityAttributes(
598 PrefService* pref, 592 PrefService* pref,
599 base::TimeDelta incremental_uptime) { 593 base::TimeDelta incremental_uptime) {
600 // Update the stats which are critical for real-time stability monitoring. 594 // Update the stats which are critical for real-time stability monitoring.
601 // Since these are "optional," only list ones that are non-zero, as the counts 595 // Since these are "optional," only list ones that are non-zero, as the counts
602 // are aggergated (summed) server side. 596 // are aggregated (summed) server side.
603 597
604 SystemProfileProto::Stability* stability = 598 SystemProfileProto::Stability* stability =
605 uma_proto()->mutable_system_profile()->mutable_stability(); 599 uma_proto()->mutable_system_profile()->mutable_stability();
606 int count = pref->GetInteger(prefs::kStabilityPageLoadCount); 600 int count = pref->GetInteger(prefs::kStabilityPageLoadCount);
607 if (count) { 601 if (count) {
608 stability->set_page_load_count(count); 602 stability->set_page_load_count(count);
609 pref->SetInteger(prefs::kStabilityPageLoadCount, 0); 603 pref->SetInteger(prefs::kStabilityPageLoadCount, 0);
610 } 604 }
611 605
612 count = pref->GetInteger(prefs::kStabilityRendererCrashCount); 606 count = pref->GetInteger(prefs::kStabilityRendererCrashCount);
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 947
954 // We invalidate the user count if it changed while the log was open. 948 // We invalidate the user count if it changed while the log was open.
955 if (system_profile->has_multi_profile_user_count() && 949 if (system_profile->has_multi_profile_user_count() &&
956 user_count != system_profile->multi_profile_user_count()) 950 user_count != system_profile->multi_profile_user_count())
957 user_count = 0; 951 user_count = 0;
958 952
959 system_profile->set_multi_profile_user_count(user_count); 953 system_profile->set_multi_profile_user_count(user_count);
960 } 954 }
961 } 955 }
962 #endif 956 #endif
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