Create PluginMetricsProvider class.

Also changes ProvideStabilityMetrics() to take a SystemProfileProto* instead
of the stability section, since the plugin provider needs to inspect things
in the system profile when writing its stability data.

Also, cleans up some header includes.

BUG=374220
R=isherman@chromium.org, thestig@chromium.org
TBR=thestig@chromium.org

Review URL: https://codereview.chromium.org/299783004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272462 0039d316-1c4b-4281-b951-d872f2087c98
parent 0aaa299b
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
#include "chrome/common/switch_utils.h" #include "chrome/common/switch_utils.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "chrome/installer/util/google_update_constants.h" #include "chrome/installer/util/google_update_constants.h"
#include "chrome/installer/util/google_update_settings.h"
#include "components/policy/core/common/policy_service.h" #include "components/policy/core/common/policy_service.h"
#include "components/signin/core/common/profile_management_switches.h" #include "components/signin/core/common/profile_management_switches.h"
#include "components/translate/core/browser/translate_download_manager.h" #include "components/translate/core/browser/translate_download_manager.h"
......
...@@ -39,7 +39,7 @@ AndroidMetricsProvider::~AndroidMetricsProvider() { ...@@ -39,7 +39,7 @@ AndroidMetricsProvider::~AndroidMetricsProvider() {
void AndroidMetricsProvider::ProvideStabilityMetrics( void AndroidMetricsProvider::ProvideStabilityMetrics(
metrics::SystemProfileProto_Stability* stability_proto) { metrics::SystemProfileProto* system_profile_proto) {
ConvertStabilityPrefsToHistograms(); ConvertStabilityPrefsToHistograms();
} }
......
...@@ -25,7 +25,7 @@ class AndroidMetricsProvider : public metrics::MetricsProvider { ...@@ -25,7 +25,7 @@ class AndroidMetricsProvider : public metrics::MetricsProvider {
// metrics::MetricsDataProvider: // metrics::MetricsDataProvider:
virtual void ProvideStabilityMetrics( virtual void ProvideStabilityMetrics(
metrics::SystemProfileProto_Stability* stability_proto) OVERRIDE; metrics::SystemProfileProto* system_profile_proto) OVERRIDE;
// Registers local state prefs used by this class. // Registers local state prefs used by this class.
static void RegisterPrefs(PrefRegistrySimple* registry); static void RegisterPrefs(PrefRegistrySimple* registry);
......
...@@ -79,8 +79,10 @@ void ChromeStabilityMetricsProvider::OnRecordingDisabled() { ...@@ -79,8 +79,10 @@ void ChromeStabilityMetricsProvider::OnRecordingDisabled() {
} }
void ChromeStabilityMetricsProvider::ProvideStabilityMetrics( void ChromeStabilityMetricsProvider::ProvideStabilityMetrics(
metrics::SystemProfileProto_Stability* stability_proto) { metrics::SystemProfileProto* system_profile_proto) {
PrefService* pref = g_browser_process->local_state(); PrefService* pref = g_browser_process->local_state();
metrics::SystemProfileProto_Stability* stability_proto =
system_profile_proto->mutable_stability();
int count = pref->GetInteger(prefs::kStabilityPageLoadCount); int count = pref->GetInteger(prefs::kStabilityPageLoadCount);
if (count) { if (count) {
......
...@@ -29,7 +29,7 @@ class ChromeStabilityMetricsProvider : public metrics::MetricsProvider, ...@@ -29,7 +29,7 @@ class ChromeStabilityMetricsProvider : public metrics::MetricsProvider,
virtual void OnRecordingEnabled() OVERRIDE; virtual void OnRecordingEnabled() OVERRIDE;
virtual void OnRecordingDisabled() OVERRIDE; virtual void OnRecordingDisabled() OVERRIDE;
virtual void ProvideStabilityMetrics( virtual void ProvideStabilityMetrics(
metrics::SystemProfileProto_Stability* stability_proto) OVERRIDE; metrics::SystemProfileProto* system_profile_proto) OVERRIDE;
private: private:
// content::NotificationObserver: // content::NotificationObserver:
......
...@@ -26,8 +26,6 @@ ...@@ -26,8 +26,6 @@
#include "base/tracked_objects.h" #include "base/tracked_objects.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/metrics/extension_metrics.h" #include "chrome/browser/metrics/extension_metrics.h"
#include "chrome/browser/plugins/plugin_prefs.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "components/metrics/metrics_provider.h" #include "components/metrics/metrics_provider.h"
#include "components/metrics/metrics_service_client.h" #include "components/metrics/metrics_service_client.h"
...@@ -37,7 +35,6 @@ ...@@ -37,7 +35,6 @@
#include "components/variations/active_field_trials.h" #include "components/variations/active_field_trials.h"
#include "content/public/browser/gpu_data_manager.h" #include "content/public/browser/gpu_data_manager.h"
#include "content/public/common/content_client.h" #include "content/public/common/content_client.h"
#include "content/public/common/webplugininfo.h"
#include "gpu/config/gpu_info.h" #include "gpu/config/gpu_info.h"
#include "ui/gfx/screen.h" #include "ui/gfx/screen.h"
#include "url/gurl.h" #include "url/gurl.h"
...@@ -116,38 +113,6 @@ std::string ComputeSHA1(const std::string& data) { ...@@ -116,38 +113,6 @@ std::string ComputeSHA1(const std::string& data) {
return base::HexEncode(sha1.data(), sha1.size()); return base::HexEncode(sha1.data(), sha1.size());
} }
#if defined(ENABLE_PLUGINS)
// Returns the plugin preferences corresponding for this user, if available.
// If multiple user profiles are loaded, returns the preferences corresponding
// to an arbitrary one of the profiles.
PluginPrefs* GetPluginPrefs() {
ProfileManager* profile_manager = g_browser_process->profile_manager();
if (!profile_manager) {
// The profile manager can be NULL when testing.
return NULL;
}
std::vector<Profile*> profiles = profile_manager->GetLoadedProfiles();
if (profiles.empty())
return NULL;
return PluginPrefs::GetForProfile(profiles.front()).get();
}
// Fills |plugin| with the info contained in |plugin_info| and |plugin_prefs|.
void SetPluginInfo(const content::WebPluginInfo& plugin_info,
const PluginPrefs* plugin_prefs,
SystemProfileProto::Plugin* plugin) {
plugin->set_name(base::UTF16ToUTF8(plugin_info.name));
plugin->set_filename(plugin_info.path.BaseName().AsUTF8Unsafe());
plugin->set_version(base::UTF16ToUTF8(plugin_info.version));
plugin->set_is_pepper(plugin_info.is_pepper_plugin());
if (plugin_prefs)
plugin->set_is_disabled(!plugin_prefs->IsPluginEnabled(plugin_info));
}
#endif // defined(ENABLE_PLUGINS)
void WriteFieldTrials(const std::vector<ActiveGroupId>& field_trial_ids, void WriteFieldTrials(const std::vector<ActiveGroupId>& field_trial_ids,
SystemProfileProto* system_profile) { SystemProfileProto* system_profile) {
for (std::vector<ActiveGroupId>::const_iterator it = for (std::vector<ActiveGroupId>::const_iterator it =
...@@ -280,11 +245,6 @@ MetricsLog::MetricsLog(const std::string& client_id, ...@@ -280,11 +245,6 @@ MetricsLog::MetricsLog(const std::string& client_id,
MetricsLog::~MetricsLog() {} MetricsLog::~MetricsLog() {}
// static
void MetricsLog::RegisterPrefs(PrefRegistrySimple* registry) {
registry->RegisterListPref(prefs::kStabilityPluginStats);
}
void MetricsLog::RecordStabilityMetrics( void MetricsLog::RecordStabilityMetrics(
const std::vector<metrics::MetricsProvider*>& metrics_providers, const std::vector<metrics::MetricsProvider*>& metrics_providers,
base::TimeDelta incremental_uptime, base::TimeDelta incremental_uptime,
...@@ -301,7 +261,6 @@ void MetricsLog::RecordStabilityMetrics( ...@@ -301,7 +261,6 @@ void MetricsLog::RecordStabilityMetrics(
// sent, but that's true for all the metrics. // sent, but that's true for all the metrics.
WriteRequiredStabilityAttributes(pref); WriteRequiredStabilityAttributes(pref);
WritePluginStabilityElements(pref);
// Record recent delta for critical stability metrics. We can't wait for a // Record recent delta for critical stability metrics. We can't wait for a
// restart to gather these, as that delay biases our observation away from // restart to gather these, as that delay biases our observation away from
...@@ -309,10 +268,9 @@ void MetricsLog::RecordStabilityMetrics( ...@@ -309,10 +268,9 @@ void MetricsLog::RecordStabilityMetrics(
// uma log upload, just as we send histogram data. // uma log upload, just as we send histogram data.
WriteRealtimeStabilityAttributes(pref, incremental_uptime, uptime); WriteRealtimeStabilityAttributes(pref, incremental_uptime, uptime);
SystemProfileProto::Stability* stability = SystemProfileProto* system_profile = uma_proto()->mutable_system_profile();
uma_proto()->mutable_system_profile()->mutable_stability();
for (size_t i = 0; i < metrics_providers.size(); ++i) for (size_t i = 0; i < metrics_providers.size(); ++i)
metrics_providers[i]->ProvideStabilityMetrics(stability); metrics_providers[i]->ProvideStabilityMetrics(system_profile);
// Omit some stats unless this is the initial stability log. // Omit some stats unless this is the initial stability log.
if (log_type() != INITIAL_STABILITY_LOG) if (log_type() != INITIAL_STABILITY_LOG)
...@@ -336,6 +294,8 @@ void MetricsLog::RecordStabilityMetrics( ...@@ -336,6 +294,8 @@ void MetricsLog::RecordStabilityMetrics(
// TODO(jar): The following are all optional, so we *could* optimize them for // TODO(jar): The following are all optional, so we *could* optimize them for
// values of zero (and not include them). // values of zero (and not include them).
SystemProfileProto::Stability* stability =
system_profile->mutable_stability();
stability->set_incomplete_shutdown_count(incomplete_shutdown_count); stability->set_incomplete_shutdown_count(incomplete_shutdown_count);
stability->set_breakpad_registration_success_count( stability->set_breakpad_registration_success_count(
breakpad_registration_success_count); breakpad_registration_success_count);
...@@ -382,76 +342,6 @@ bool MetricsLog::HasStabilityMetrics() const { ...@@ -382,76 +342,6 @@ bool MetricsLog::HasStabilityMetrics() const {
return uma_proto()->system_profile().stability().has_launch_count(); return uma_proto()->system_profile().stability().has_launch_count();
} }
void MetricsLog::WritePluginStabilityElements(PrefService* pref) {
// Now log plugin stability info.
const base::ListValue* plugin_stats_list = pref->GetList(
prefs::kStabilityPluginStats);
if (!plugin_stats_list)
return;
#if defined(ENABLE_PLUGINS)
SystemProfileProto::Stability* stability =
uma_proto()->mutable_system_profile()->mutable_stability();
for (base::ListValue::const_iterator iter = plugin_stats_list->begin();
iter != plugin_stats_list->end(); ++iter) {
if (!(*iter)->IsType(base::Value::TYPE_DICTIONARY)) {
NOTREACHED();
continue;
}
base::DictionaryValue* plugin_dict =
static_cast<base::DictionaryValue*>(*iter);
// Note that this search is potentially a quadratic operation, but given the
// low number of plugins installed on a "reasonable" setup, this should be
// fine.
// TODO(isherman): Verify that this does not show up as a hotspot in
// profiler runs.
const SystemProfileProto::Plugin* system_profile_plugin = NULL;
std::string plugin_name;
plugin_dict->GetString(prefs::kStabilityPluginName, &plugin_name);
const SystemProfileProto& system_profile = uma_proto()->system_profile();
for (int i = 0; i < system_profile.plugin_size(); ++i) {
if (system_profile.plugin(i).name() == plugin_name) {
system_profile_plugin = &system_profile.plugin(i);
break;
}
}
if (!system_profile_plugin) {
NOTREACHED();
continue;
}
SystemProfileProto::Stability::PluginStability* plugin_stability =
stability->add_plugin_stability();
*plugin_stability->mutable_plugin() = *system_profile_plugin;
int launches = 0;
plugin_dict->GetInteger(prefs::kStabilityPluginLaunches, &launches);
if (launches > 0)
plugin_stability->set_launch_count(launches);
int instances = 0;
plugin_dict->GetInteger(prefs::kStabilityPluginInstances, &instances);
if (instances > 0)
plugin_stability->set_instance_count(instances);
int crashes = 0;
plugin_dict->GetInteger(prefs::kStabilityPluginCrashes, &crashes);
if (crashes > 0)
plugin_stability->set_crash_count(crashes);
int loading_errors = 0;
plugin_dict->GetInteger(prefs::kStabilityPluginLoadingErrors,
&loading_errors);
if (loading_errors > 0)
plugin_stability->set_loading_error_count(loading_errors);
}
#endif // defined(ENABLE_PLUGINS)
pref->ClearPref(prefs::kStabilityPluginStats);
}
// The server refuses data that doesn't have certain values. crashcount and // The server refuses data that doesn't have certain values. crashcount and
// launchcount are currently "required" in the "stability" group. // launchcount are currently "required" in the "stability" group.
// TODO(isherman): Stop writing these attributes specially once the migration to // TODO(isherman): Stop writing these attributes specially once the migration to
...@@ -497,25 +387,8 @@ void MetricsLog::WriteRealtimeStabilityAttributes( ...@@ -497,25 +387,8 @@ void MetricsLog::WriteRealtimeStabilityAttributes(
stability->set_uptime_sec(uptime_sec); stability->set_uptime_sec(uptime_sec);
} }
void MetricsLog::WritePluginList(
const std::vector<content::WebPluginInfo>& plugin_list) {
DCHECK(!locked());
#if defined(ENABLE_PLUGINS)
PluginPrefs* plugin_prefs = GetPluginPrefs();
SystemProfileProto* system_profile = uma_proto()->mutable_system_profile();
for (std::vector<content::WebPluginInfo>::const_iterator iter =
plugin_list.begin();
iter != plugin_list.end(); ++iter) {
SystemProfileProto::Plugin* plugin = system_profile->add_plugin();
SetPluginInfo(*iter, plugin_prefs, plugin);
}
#endif // defined(ENABLE_PLUGINS)
}
void MetricsLog::RecordEnvironment( void MetricsLog::RecordEnvironment(
const std::vector<metrics::MetricsProvider*>& metrics_providers, const std::vector<metrics::MetricsProvider*>& metrics_providers,
const std::vector<content::WebPluginInfo>& plugin_list,
const std::vector<variations::ActiveGroupId>& synthetic_trials) { const std::vector<variations::ActiveGroupId>& synthetic_trials) {
DCHECK(!HasEnvironment()); DCHECK(!HasEnvironment());
...@@ -595,7 +468,6 @@ void MetricsLog::RecordEnvironment( ...@@ -595,7 +468,6 @@ void MetricsLog::RecordEnvironment(
WriteScreenDPIInformationProto(hardware); WriteScreenDPIInformationProto(hardware);
#endif #endif
WritePluginList(plugin_list);
extension_metrics_.WriteExtensionList(uma_proto()->mutable_system_profile()); extension_metrics_.WriteExtensionList(uma_proto()->mutable_system_profile());
std::vector<ActiveGroupId> field_trial_ids; std::vector<ActiveGroupId> field_trial_ids;
......
...@@ -14,13 +14,11 @@ ...@@ -14,13 +14,11 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "chrome/browser/metrics/extension_metrics.h" #include "chrome/browser/metrics/extension_metrics.h"
#include "chrome/common/variations/variations_util.h" #include "chrome/common/variations/variations_util.h"
#include "chrome/installer/util/google_update_settings.h"
#include "components/metrics/metrics_log_base.h" #include "components/metrics/metrics_log_base.h"
#include "ui/gfx/size.h" #include "ui/gfx/size.h"
class HashedExtensionMetrics; class HashedExtensionMetrics;
class PrefService; class PrefService;
class PrefRegistrySimple;
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
class MetricsLogChromeOS; class MetricsLogChromeOS;
...@@ -62,8 +60,6 @@ class MetricsLog : public metrics::MetricsLogBase { ...@@ -62,8 +60,6 @@ class MetricsLog : public metrics::MetricsLogBase {
metrics::MetricsServiceClient* client); metrics::MetricsServiceClient* client);
virtual ~MetricsLog(); virtual ~MetricsLog();
static void RegisterPrefs(PrefRegistrySimple* registry);
// Records the current operating environment, including metrics provided by // Records the current operating environment, including metrics provided by
// the specified set of |metrics_providers|. Takes the list of installed // the specified set of |metrics_providers|. Takes the list of installed
// plugins, Google Update statistics, and synthetic trial IDs as parameters // plugins, Google Update statistics, and synthetic trial IDs as parameters
...@@ -73,7 +69,6 @@ class MetricsLog : public metrics::MetricsLogBase { ...@@ -73,7 +69,6 @@ class MetricsLog : public metrics::MetricsLogBase {
// is determined by the pref value. // is determined by the pref value.
void RecordEnvironment( void RecordEnvironment(
const std::vector<metrics::MetricsProvider*>& metrics_providers, const std::vector<metrics::MetricsProvider*>& metrics_providers,
const std::vector<content::WebPluginInfo>& plugin_list,
const std::vector<variations::ActiveGroupId>& synthetic_trials); const std::vector<variations::ActiveGroupId>& synthetic_trials);
// Loads the environment proto that was saved by the last RecordEnvironment() // Loads the environment proto that was saved by the last RecordEnvironment()
...@@ -145,9 +140,6 @@ class MetricsLog : public metrics::MetricsLogBase { ...@@ -145,9 +140,6 @@ class MetricsLog : public metrics::MetricsLogBase {
// call to RecordStabilityMetrics(). // call to RecordStabilityMetrics().
bool HasStabilityMetrics() const; bool HasStabilityMetrics() const;
// Within stability group, write plugin crash stats.
void WritePluginStabilityElements(PrefService* pref);
// Within the stability group, write required attributes. // Within the stability group, write required attributes.
void WriteRequiredStabilityAttributes(PrefService* pref); void WriteRequiredStabilityAttributes(PrefService* pref);
...@@ -159,9 +151,6 @@ class MetricsLog : public metrics::MetricsLogBase { ...@@ -159,9 +151,6 @@ class MetricsLog : public metrics::MetricsLogBase {
base::TimeDelta incremental_uptime, base::TimeDelta incremental_uptime,
base::TimeDelta uptime); base::TimeDelta uptime);
// Writes the list of installed plugins.
void WritePluginList(const std::vector<content::WebPluginInfo>& plugin_list);
// Used to interact with the embedder. Weak pointer; must outlive |this| // Used to interact with the embedder. Weak pointer; must outlive |this|
// instance. // instance.
metrics::MetricsServiceClient* const client_; metrics::MetricsServiceClient* const client_;
......
This diff is collapsed.
...@@ -39,6 +39,7 @@ class GoogleUpdateMetricsProviderWin; ...@@ -39,6 +39,7 @@ class GoogleUpdateMetricsProviderWin;
class MetricsReportingScheduler; class MetricsReportingScheduler;
class PrefService; class PrefService;
class PrefRegistrySimple; class PrefRegistrySimple;
class PluginMetricsProvider;
namespace base { namespace base {
class DictionaryValue; class DictionaryValue;
...@@ -51,7 +52,6 @@ struct ActiveGroupId; ...@@ -51,7 +52,6 @@ struct ActiveGroupId;
} }
namespace content { namespace content {
struct WebPluginInfo;
} }
namespace metrics { namespace metrics {
...@@ -171,12 +171,8 @@ class MetricsService ...@@ -171,12 +171,8 @@ class MetricsService
virtual void InconsistencyDetectedInLoggedCount(int amount) OVERRIDE; virtual void InconsistencyDetectedInLoggedCount(int amount) OVERRIDE;
// Implementation of content::BrowserChildProcessObserver // Implementation of content::BrowserChildProcessObserver
virtual void BrowserChildProcessHostConnected(
const content::ChildProcessData& data) OVERRIDE;
virtual void BrowserChildProcessCrashed( virtual void BrowserChildProcessCrashed(
const content::ChildProcessData& data) OVERRIDE; const content::ChildProcessData& data) OVERRIDE;
virtual void BrowserChildProcessInstanceCreated(
const content::ChildProcessData& data) OVERRIDE;
// This should be called when the application is not idle, i.e. the user seems // This should be called when the application is not idle, i.e. the user seems
// to be interacting with the application. // to be interacting with the application.
...@@ -274,8 +270,6 @@ class MetricsService ...@@ -274,8 +270,6 @@ class MetricsService
NEED_TO_SHUTDOWN = ~CLEANLY_SHUTDOWN NEED_TO_SHUTDOWN = ~CLEANLY_SHUTDOWN
}; };
struct ChildProcessStats;
typedef std::vector<SyntheticTrialGroup> SyntheticTrialGroups; typedef std::vector<SyntheticTrialGroup> SyntheticTrialGroups;
// First part of the init task. Called on the FILE thread to load hardware // First part of the init task. Called on the FILE thread to load hardware
...@@ -287,10 +281,9 @@ class MetricsService ...@@ -287,10 +281,9 @@ class MetricsService
// loading plugin information. // loading plugin information.
void OnInitTaskGotHardwareClass(const std::string& hardware_class); void OnInitTaskGotHardwareClass(const std::string& hardware_class);
// Callback from PluginService::GetPlugins() that continues the init task by // Called after the Plugin init task has been completed that continues the
// launching a task to gather Google Update statistics. // init task by launching a task to gather Google Update statistics.
void OnInitTaskGotPluginInfo( void OnInitTaskGotPluginInfo();
const std::vector<content::WebPluginInfo>& plugins);
// Called after GoogleUpdate init task has been completed that continues the // Called after GoogleUpdate init task has been completed that continues the
// init task by loading profiler data. // init task by loading profiler data.
...@@ -400,14 +393,6 @@ class MetricsService ...@@ -400,14 +393,6 @@ class MetricsService
// Records that the browser was shut down cleanly. // Records that the browser was shut down cleanly.
void LogCleanShutdown(); void LogCleanShutdown();
// Returns reference to ChildProcessStats corresponding to |data|.
ChildProcessStats& GetChildProcessStats(
const content::ChildProcessData& data);
// Saves plugin-related updates from the in-object buffer to Local State
// for retrieval next time we send a Profile log (generally next launch).
void RecordPluginChanges(PrefService* pref);
// Records state that should be periodically saved, like uptime and // Records state that should be periodically saved, like uptime and
// buffered plugin stability statistics. // buffered plugin stability statistics.
void RecordCurrentState(PrefService* pref); void RecordCurrentState(PrefService* pref);
...@@ -418,10 +403,6 @@ class MetricsService ...@@ -418,10 +403,6 @@ class MetricsService
// Sets the value of the specified path in prefs and schedules a save. // Sets the value of the specified path in prefs and schedules a save.
void RecordBooleanPrefValue(const char* path, bool value); void RecordBooleanPrefValue(const char* path, bool value);
// Returns true if process of type |type| should be counted as a plugin
// process, and false otherwise.
static bool IsPluginProcess(int process_type);
// Returns a list of synthetic field trials that were active for the entire // Returns a list of synthetic field trials that were active for the entire
// duration of the current log. // duration of the current log.
void GetCurrentSyntheticFieldTrials( void GetCurrentSyntheticFieldTrials(
...@@ -480,8 +461,9 @@ class MetricsService ...@@ -480,8 +461,9 @@ class MetricsService
// empty string. // empty string.
std::string hardware_class_; std::string hardware_class_;
// The list of plugins which was retrieved on the file thread. #if defined(ENABLE_PLUGINS)
std::vector<content::WebPluginInfo> plugins_; PluginMetricsProvider* plugin_metrics_provider_;
#endif
#if defined(OS_WIN) #if defined(OS_WIN)
GoogleUpdateMetricsProviderWin* google_update_metrics_provider_; GoogleUpdateMetricsProviderWin* google_update_metrics_provider_;
...@@ -509,9 +491,6 @@ class MetricsService ...@@ -509,9 +491,6 @@ class MetricsService
WindowMap window_map_; WindowMap window_map_;
int next_window_id_; int next_window_id_;
// Buffer of child process notifications for quick access.
std::map<base::string16, ChildProcessStats> child_process_stats_buffer_;
// Weak pointers factory used to post task on different threads. All weak // Weak pointers factory used to post task on different threads. All weak
// pointers managed by this factory have the same lifetime as MetricsService. // pointers managed by this factory have the same lifetime as MetricsService.
base::WeakPtrFactory<MetricsService> self_ptr_factory_; base::WeakPtrFactory<MetricsService> self_ptr_factory_;
......
...@@ -16,8 +16,6 @@ ...@@ -16,8 +16,6 @@
#include "components/metrics/metrics_service_observer.h" #include "components/metrics/metrics_service_observer.h"
#include "components/metrics/test_metrics_service_client.h" #include "components/metrics/test_metrics_service_client.h"
#include "components/variations/metrics_util.h" #include "components/variations/metrics_util.h"
#include "content/public/common/process_type.h"
#include "content/public/common/webplugininfo.h"
#include "content/public/test/test_browser_thread_bundle.h" #include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/size.h" #include "ui/gfx/size.h"
...@@ -172,15 +170,6 @@ class TestMetricsServiceObserver : public MetricsServiceObserver { ...@@ -172,15 +170,6 @@ class TestMetricsServiceObserver : public MetricsServiceObserver {
} // namespace } // namespace
TEST_F(MetricsServiceTest, IsPluginProcess) {
EXPECT_TRUE(
MetricsService::IsPluginProcess(content::PROCESS_TYPE_PLUGIN));
EXPECT_TRUE(
MetricsService::IsPluginProcess(content::PROCESS_TYPE_PPAPI_PLUGIN));
EXPECT_FALSE(
MetricsService::IsPluginProcess(content::PROCESS_TYPE_GPU));
}
TEST_F(MetricsServiceTest, InitialStabilityLogAfterCleanShutDown) { TEST_F(MetricsServiceTest, InitialStabilityLogAfterCleanShutDown) {
EnableMetricsReporting(); EnableMetricsReporting();
GetLocalState()->SetBoolean(prefs::kStabilityExitedCleanly, true); GetLocalState()->SetBoolean(prefs::kStabilityExitedCleanly, true);
...@@ -204,7 +193,6 @@ TEST_F(MetricsServiceTest, InitialStabilityLogAfterCrash) { ...@@ -204,7 +193,6 @@ TEST_F(MetricsServiceTest, InitialStabilityLogAfterCrash) {
metrics::TestMetricsServiceClient client; metrics::TestMetricsServiceClient client;
TestMetricsLog log("client", 1, &client); TestMetricsLog log("client", 1, &client);
log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(),
std::vector<content::WebPluginInfo>(),
std::vector<variations::ActiveGroupId>()); std::vector<variations::ActiveGroupId>());
// Record stability build time and version from previous session, so that // Record stability build time and version from previous session, so that
......
This diff is collapsed.
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_METRICS_PLUGIN_METRICS_PROVIDER_H_
#define CHROME_BROWSER_METRICS_PLUGIN_METRICS_PROVIDER_H_
#include <map>
#include <vector>
#include "base/basictypes.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
#include "components/metrics/metrics_provider.h"
#include "content/public/browser/browser_child_process_observer.h"
namespace base {
class FilePath;
}
namespace content {
struct WebPluginInfo;
}
class PrefRegistrySimple;
class PrefService;
// PluginMetricsProvider is responsible for adding out plugin information to
// the UMA proto.
class PluginMetricsProvider : public metrics::MetricsProvider,
public content::BrowserChildProcessObserver {
public:
explicit PluginMetricsProvider(PrefService* local_state);
virtual ~PluginMetricsProvider();
// Fetches plugin information data asynchronously and calls |done_callback|
// when done.
void GetPluginInformation(const base::Closure& done_callback);
// metrics::MetricsDataProvider:
virtual void ProvideSystemProfileMetrics(
metrics::SystemProfileProto* system_profile_proto) OVERRIDE;
virtual void ProvideStabilityMetrics(
metrics::SystemProfileProto* system_profile_proto) OVERRIDE;
// Saves plugin-related updates from the in-object buffer to Local State
// for retrieval next time we send a Profile log (generally next launch).
void RecordPluginChanges();
// Notifies the provider about an error loading the plugin at |plugin_path|.
void LogPluginLoadingError(const base::FilePath& plugin_path);
// Sets this provider's list of plugins, exposed for testing.
void SetPluginsForTesting(const std::vector<content::WebPluginInfo>& plugins);
// Returns true if process of type |type| should be counted as a plugin
// process, and false otherwise.
static bool IsPluginProcess(int process_type);
// Registers local state prefs used by this class.
static void RegisterPrefs(PrefRegistrySimple* registry);
private:
struct ChildProcessStats;
// Receives the plugin list from the PluginService and calls |done_callback|.
void OnGotPlugins(const base::Closure& done_callback,
const std::vector<content::WebPluginInfo>& plugins);
// Returns reference to ChildProcessStats corresponding to |data|.
ChildProcessStats& GetChildProcessStats(
const content::ChildProcessData& data);
// content::BrowserChildProcessObserver:
virtual void BrowserChildProcessHostConnected(
const content::ChildProcessData& data) OVERRIDE;
virtual void BrowserChildProcessCrashed(
const content::ChildProcessData& data) OVERRIDE;
virtual void BrowserChildProcessInstanceCreated(
const content::ChildProcessData& data) OVERRIDE;
PrefService* local_state_;
// The list of plugins which was retrieved on the file thread.
std::vector<content::WebPluginInfo> plugins_;
// Buffer of child process notifications for quick access.
std::map<base::string16, ChildProcessStats> child_process_stats_buffer_;
base::WeakPtrFactory<PluginMetricsProvider> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(PluginMetricsProvider);
};
#endif // CHROME_BROWSER_METRICS_PLUGIN_METRICS_PROVIDER_H_
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/metrics/plugin_metrics_provider.h"
#include <string>
#include "base/basictypes.h"
#include "base/prefs/pref_service.h"
#include "base/prefs/scoped_user_pref_update.h"
#include "base/prefs/testing_pref_service.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/common/pref_names.h"
#include "components/metrics/proto/system_profile.pb.h"
#include "content/public/common/process_type.h"
#include "content/public/common/webplugininfo.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
content::WebPluginInfo CreateFakePluginInfo(
const std::string& name,
const base::FilePath::CharType* path,
const std::string& version,
bool is_pepper) {
content::WebPluginInfo plugin(base::UTF8ToUTF16(name),
base::FilePath(path),
base::UTF8ToUTF16(version),
base::string16());
if (is_pepper)
plugin.type = content::WebPluginInfo::PLUGIN_TYPE_PEPPER_IN_PROCESS;
else
plugin.type = content::WebPluginInfo::PLUGIN_TYPE_NPAPI;
return plugin;
}
} // namespace
TEST(PluginMetricsProviderTest, IsPluginProcess) {
EXPECT_TRUE(PluginMetricsProvider::IsPluginProcess(
content::PROCESS_TYPE_PLUGIN));
EXPECT_TRUE(PluginMetricsProvider::IsPluginProcess(
content::PROCESS_TYPE_PPAPI_PLUGIN));
EXPECT_FALSE(PluginMetricsProvider::IsPluginProcess(
content::PROCESS_TYPE_GPU));
}
TEST(PluginMetricsProviderTest, Plugins) {
content::TestBrowserThreadBundle thread_bundle;
TestingPrefServiceSimple prefs;
PluginMetricsProvider::RegisterPrefs(prefs.registry());
PluginMetricsProvider provider(&prefs);
std::vector<content::WebPluginInfo> plugins;
plugins.push_back(CreateFakePluginInfo("p1", FILE_PATH_LITERAL("p1.plugin"),
"1.5", true));
plugins.push_back(CreateFakePluginInfo("p2", FILE_PATH_LITERAL("p2.plugin"),
"2.0", false));
provider.SetPluginsForTesting(plugins);
metrics::SystemProfileProto system_profile;
provider.ProvideSystemProfileMetrics(&system_profile);
ASSERT_EQ(2, system_profile.plugin_size());
EXPECT_EQ("p1", system_profile.plugin(0).name());
EXPECT_EQ("p1.plugin", system_profile.plugin(0).filename());
EXPECT_EQ("1.5", system_profile.plugin(0).version());
EXPECT_TRUE(system_profile.plugin(0).is_pepper());
EXPECT_EQ("p2", system_profile.plugin(1).name());
EXPECT_EQ("p2.plugin", system_profile.plugin(1).filename());
EXPECT_EQ("2.0", system_profile.plugin(1).version());
EXPECT_FALSE(system_profile.plugin(1).is_pepper());
// Now set some plugin stability stats for p2 and verify they're recorded.
scoped_ptr<base::DictionaryValue> plugin_dict(new base::DictionaryValue);
plugin_dict->SetString(prefs::kStabilityPluginName, "p2");
plugin_dict->SetInteger(prefs::kStabilityPluginLaunches, 1);
plugin_dict->SetInteger(prefs::kStabilityPluginCrashes, 2);
plugin_dict->SetInteger(prefs::kStabilityPluginInstances, 3);
plugin_dict->SetInteger(prefs::kStabilityPluginLoadingErrors, 4);
{
ListPrefUpdate update(&prefs, prefs::kStabilityPluginStats);
update.Get()->Append(plugin_dict.release());
}
provider.ProvideStabilityMetrics(&system_profile);
const metrics::SystemProfileProto_Stability& stability =
system_profile.stability();
ASSERT_EQ(1, stability.plugin_stability_size());
EXPECT_EQ("p2", stability.plugin_stability(0).plugin().name());
EXPECT_EQ("p2.plugin", stability.plugin_stability(0).plugin().filename());
EXPECT_EQ("2.0", stability.plugin_stability(0).plugin().version());
EXPECT_FALSE(stability.plugin_stability(0).plugin().is_pepper());
EXPECT_EQ(1, stability.plugin_stability(0).launch_count());
EXPECT_EQ(2, stability.plugin_stability(0).crash_count());
EXPECT_EQ(3, stability.plugin_stability(0).instance_count());
EXPECT_EQ(4, stability.plugin_stability(0).loading_error_count());
}
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
#include "chrome/browser/media/media_capture_devices_dispatcher.h" #include "chrome/browser/media/media_capture_devices_dispatcher.h"
#include "chrome/browser/media/media_device_id_salt.h" #include "chrome/browser/media/media_device_id_salt.h"
#include "chrome/browser/media/media_stream_devices_controller.h" #include "chrome/browser/media/media_stream_devices_controller.h"
#include "chrome/browser/metrics/metrics_log.h"
#include "chrome/browser/metrics/metrics_service.h" #include "chrome/browser/metrics/metrics_service.h"
#include "chrome/browser/metrics/variations/variations_service.h" #include "chrome/browser/metrics/variations/variations_service.h"
#include "chrome/browser/net/http_server_properties_manager.h" #include "chrome/browser/net/http_server_properties_manager.h"
...@@ -232,7 +231,6 @@ void RegisterLocalState(PrefRegistrySimple* registry) { ...@@ -232,7 +231,6 @@ void RegisterLocalState(PrefRegistrySimple* registry) {
IntranetRedirectDetector::RegisterPrefs(registry); IntranetRedirectDetector::RegisterPrefs(registry);
IOThread::RegisterPrefs(registry); IOThread::RegisterPrefs(registry);
KeywordEditorController::RegisterPrefs(registry); KeywordEditorController::RegisterPrefs(registry);
MetricsLog::RegisterPrefs(registry);
MetricsService::RegisterPrefs(registry); MetricsService::RegisterPrefs(registry);
PrefProxyConfigTrackerImpl::RegisterPrefs(registry); PrefProxyConfigTrackerImpl::RegisterPrefs(registry);
ProfileInfoCache::RegisterPrefs(registry); ProfileInfoCache::RegisterPrefs(registry);
......
...@@ -1218,6 +1218,8 @@ ...@@ -1218,6 +1218,8 @@
'browser/metrics/omnibox_metrics_provider.h', 'browser/metrics/omnibox_metrics_provider.h',
'browser/metrics/perf_provider_chromeos.cc', 'browser/metrics/perf_provider_chromeos.cc',
'browser/metrics/perf_provider_chromeos.h', 'browser/metrics/perf_provider_chromeos.h',
'browser/metrics/plugin_metrics_provider.cc',
'browser/metrics/plugin_metrics_provider.h',
'browser/metrics/thread_watcher.cc', 'browser/metrics/thread_watcher.cc',
'browser/metrics/thread_watcher.h', 'browser/metrics/thread_watcher.h',
'browser/metrics/thread_watcher_android.cc', 'browser/metrics/thread_watcher_android.cc',
...@@ -2863,6 +2865,7 @@ ...@@ -2863,6 +2865,7 @@
}, { # enable_plugins==0 }, { # enable_plugins==0
'sources/': [ 'sources/': [
['exclude', '^browser/guest_view/web_view/plugin_permission_helper'], ['exclude', '^browser/guest_view/web_view/plugin_permission_helper'],
['exclude', '^browser/metrics/plugin_metrics_provider'],
['exclude', '^browser/pepper_'], ['exclude', '^browser/pepper_'],
['exclude', '^browser/plugins/'], ['exclude', '^browser/plugins/'],
['exclude', '^browser/renderer_host/pepper/'], ['exclude', '^browser/renderer_host/pepper/'],
......
...@@ -1087,6 +1087,7 @@ ...@@ -1087,6 +1087,7 @@
'browser/metrics/metrics_log_unittest.cc', 'browser/metrics/metrics_log_unittest.cc',
'browser/metrics/metrics_service_unittest.cc', 'browser/metrics/metrics_service_unittest.cc',
'browser/metrics/metrics_state_manager_unittest.cc', 'browser/metrics/metrics_state_manager_unittest.cc',
'browser/metrics/plugin_metrics_provider_unittest.cc',
'browser/metrics/thread_watcher_unittest.cc', 'browser/metrics/thread_watcher_unittest.cc',
'browser/metrics/thread_watcher_android_unittest.cc', 'browser/metrics/thread_watcher_android_unittest.cc',
'browser/metrics/time_ticks_experiment_unittest.cc', 'browser/metrics/time_ticks_experiment_unittest.cc',
...@@ -2247,7 +2248,7 @@ ...@@ -2247,7 +2248,7 @@
['exclude', '^browser/plugins/'], ['exclude', '^browser/plugins/'],
], ],
'sources!': [ 'sources!': [
'browser/plugins/plugin_info_message_filter_unittest.cc', 'browser/metrics/plugin_metrics_provider_unittest.cc',
], ],
}], }],
['enable_printing!=1', { ['enable_printing!=1', {
......
...@@ -34,7 +34,7 @@ class MetricsProvider { ...@@ -34,7 +34,7 @@ class MetricsProvider {
// directly into |stability_proto| fields or by logging stability histograms // directly into |stability_proto| fields or by logging stability histograms
// via the UMA_STABILITY_HISTOGRAM_ENUMERATION() macro. // via the UMA_STABILITY_HISTOGRAM_ENUMERATION() macro.
virtual void ProvideStabilityMetrics( virtual void ProvideStabilityMetrics(
SystemProfileProto_Stability* stability_proto) {} SystemProfileProto* system_profile_proto) {}
// Provides general metrics that are neither system profile nor stability // Provides general metrics that are neither system profile nor stability
// metrics. // metrics.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment