diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-11 23:55:10 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-11 23:55:10 +0000 |
commit | a27a938d8511abfaf89d6e2d0e4d4242c76dffed (patch) | |
tree | 98b133536459106b96a0ee09e0deb94b8d92c4b3 /chrome/browser/metrics | |
parent | 342c2c40bd1729fe985d5a6ee06f6eb28bbcdc22 (diff) | |
download | chromium_src-a27a938d8511abfaf89d6e2d0e4d4242c76dffed.zip chromium_src-a27a938d8511abfaf89d6e2d0e4d4242c76dffed.tar.gz chromium_src-a27a938d8511abfaf89d6e2d0e4d4242c76dffed.tar.bz2 |
Refactor plugin process code in the browser process so that the browser/about:memory/task manager/metrics code doesn't depend on PluginProcessHost pointers. In a future changelist I'll add one central child process registry in the browser process.
Review URL: http://codereview.chromium.org/20196
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9621 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/metrics')
-rw-r--r-- | chrome/browser/metrics/metrics_log.cc | 13 | ||||
-rw-r--r-- | chrome/browser/metrics/metrics_service.cc | 67 | ||||
-rw-r--r-- | chrome/browser/metrics/metrics_service.h | 36 |
3 files changed, 58 insertions, 58 deletions
diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc index 3603e0c..27cb88e 100644 --- a/chrome/browser/metrics/metrics_log.cc +++ b/chrome/browser/metrics/metrics_log.cc @@ -382,16 +382,13 @@ void MetricsLog::WritePluginStabilityElements(PrefService* pref) { } DictionaryValue* plugin_dict = static_cast<DictionaryValue*>(*iter); - std::wstring plugin_path; - plugin_dict->GetString(prefs::kStabilityPluginPath, &plugin_path); - plugin_path = file_util::GetFilenameFromPath(plugin_path); - if (plugin_path.empty()) { - NOTREACHED(); - continue; - } + std::wstring plugin_name; + plugin_dict->GetString(prefs::kStabilityPluginName, &plugin_name); OPEN_ELEMENT_FOR_SCOPE("pluginstability"); - WriteAttribute("filename", CreateBase64Hash(WideToUTF8(plugin_path))); + // Use "filename" instead of "name", otherwise we need to update the + // UMA servers. + WriteAttribute("filename", CreateBase64Hash(WideToUTF8(plugin_name))); int launches = 0; plugin_dict->GetInteger(prefs::kStabilityPluginLaunches, &launches); diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc index b25b5b1..55aca76 100644 --- a/chrome/browser/metrics/metrics_service.cc +++ b/chrome/browser/metrics/metrics_service.cc @@ -170,12 +170,12 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/load_notification_details.h" #include "chrome/browser/memory_details.h" -#include "chrome/browser/plugin_process_info.h" #include "chrome/browser/plugin_service.h" #include "chrome/browser/profile.h" #include "chrome/browser/renderer_host/render_process_host.h" #include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url_model.h" +#include "chrome/common/child_process_info.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/libxml_utils.h" #include "chrome/common/notification_service.h" @@ -464,10 +464,10 @@ void MetricsService::Observe(NotificationType type, LogRendererInSandbox(*Details<bool>(details).ptr()); break; - case NotificationType::PLUGIN_PROCESS_HOST_CONNECTED: - case NotificationType::PLUGIN_PROCESS_CRASHED: - case NotificationType::PLUGIN_INSTANCE_CREATED: - LogPluginChange(type, source, details); + case NotificationType::CHILD_PROCESS_HOST_CONNECTED: + case NotificationType::CHILD_PROCESS_CRASHED: + case NotificationType::CHILD_INSTANCE_CREATED: + LogChildProcessChange(type, source, details); break; case NotificationType::TEMPLATE_URL_MODEL_LOADED: @@ -723,11 +723,11 @@ void MetricsService::ListenerRegistration(bool start_listening) { start_listening); AddOrRemoveObserver(this, NotificationType::RENDERER_PROCESS_HANG, start_listening); - AddOrRemoveObserver(this, NotificationType::PLUGIN_PROCESS_HOST_CONNECTED, + AddOrRemoveObserver(this, NotificationType::CHILD_PROCESS_HOST_CONNECTED, start_listening); - AddOrRemoveObserver(this, NotificationType::PLUGIN_INSTANCE_CREATED, + AddOrRemoveObserver(this, NotificationType::CHILD_INSTANCE_CREATED, start_listening); - AddOrRemoveObserver(this, NotificationType::PLUGIN_PROCESS_CRASHED, + AddOrRemoveObserver(this, NotificationType::CHILD_PROCESS_CRASHED, start_listening); AddOrRemoveObserver(this, NotificationType::TEMPLATE_URL_MODEL_LOADED, start_listening); @@ -1533,26 +1533,29 @@ void MetricsService::LogRendererHang() { IncrementPrefValue(prefs::kStabilityRendererHangCount); } -void MetricsService::LogPluginChange(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details) { - FilePath plugin = Details<PluginProcessInfo>(details)->plugin_path(); +void MetricsService::LogChildProcessChange( + NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { + const std::wstring& child_name = + Details<ChildProcessInfo>(details)->name(); - if (plugin_stats_buffer_.find(plugin) == plugin_stats_buffer_.end()) { - plugin_stats_buffer_[plugin] = PluginStats(); + if (child_process_stats_buffer_.find(child_name) == + child_process_stats_buffer_.end()) { + child_process_stats_buffer_[child_name] = ChildProcessStats(); } - PluginStats& stats = plugin_stats_buffer_[plugin]; + ChildProcessStats& stats = child_process_stats_buffer_[child_name]; switch (type.value) { - case NotificationType::PLUGIN_PROCESS_HOST_CONNECTED: + case NotificationType::CHILD_PROCESS_HOST_CONNECTED: stats.process_launches++; break; - case NotificationType::PLUGIN_INSTANCE_CREATED: + case NotificationType::CHILD_INSTANCE_CREATED: stats.instances++; break; - case NotificationType::PLUGIN_PROCESS_CRASHED: + case NotificationType::CHILD_PROCESS_CRASHED: stats.process_crashes++; break; @@ -1620,18 +1623,18 @@ void MetricsService::RecordPluginChanges(PrefService* pref) { } DictionaryValue* plugin_dict = static_cast<DictionaryValue*>(*value_iter); - FilePath::StringType plugin_path_str; - plugin_dict->GetString(prefs::kStabilityPluginPath, &plugin_path_str); - if (plugin_path_str.empty()) { + std::wstring plugin_name; + plugin_dict->GetString(prefs::kStabilityPluginName, &plugin_name); + if (plugin_name.empty()) { NOTREACHED(); continue; } - FilePath plugin_path(plugin_path_str); - if (plugin_stats_buffer_.find(plugin_path) == plugin_stats_buffer_.end()) + if (child_process_stats_buffer_.find(plugin_name) == + child_process_stats_buffer_.end()) continue; - PluginStats stats = plugin_stats_buffer_[plugin_path]; + ChildProcessStats stats = child_process_stats_buffer_[plugin_name]; if (stats.process_launches) { int launches = 0; plugin_dict->GetInteger(prefs::kStabilityPluginLaunches, &launches); @@ -1651,19 +1654,19 @@ void MetricsService::RecordPluginChanges(PrefService* pref) { plugin_dict->SetInteger(prefs::kStabilityPluginInstances, instances); } - plugin_stats_buffer_.erase(plugin_path); + child_process_stats_buffer_.erase(plugin_name); } // Now go through and add dictionaries for plugins that didn't already have // reports in Local State. - for (std::map<FilePath, PluginStats>::iterator cache_iter = - plugin_stats_buffer_.begin(); - cache_iter != plugin_stats_buffer_.end(); ++cache_iter) { - FilePath plugin_path = cache_iter->first; - PluginStats stats = cache_iter->second; + for (std::map<std::wstring, ChildProcessStats>::iterator cache_iter = + child_process_stats_buffer_.begin(); + cache_iter != child_process_stats_buffer_.end(); ++cache_iter) { + std::wstring plugin_name = cache_iter->first; + ChildProcessStats stats = cache_iter->second; DictionaryValue* plugin_dict = new DictionaryValue; - plugin_dict->SetString(prefs::kStabilityPluginPath, plugin_path.value()); + plugin_dict->SetString(prefs::kStabilityPluginName, plugin_name); plugin_dict->SetInteger(prefs::kStabilityPluginLaunches, stats.process_launches); plugin_dict->SetInteger(prefs::kStabilityPluginCrashes, @@ -1672,7 +1675,7 @@ void MetricsService::RecordPluginChanges(PrefService* pref) { stats.instances); plugins->Append(plugin_dict); } - plugin_stats_buffer_.clear(); + child_process_stats_buffer_.clear(); } bool MetricsService::CanLogNotification(NotificationType type, diff --git a/chrome/browser/metrics/metrics_service.h b/chrome/browser/metrics/metrics_service.h index 64780d7..d42d953 100644 --- a/chrome/browser/metrics/metrics_service.h +++ b/chrome/browser/metrics/metrics_service.h @@ -15,7 +15,6 @@ #include <vector> #include "base/basictypes.h" -#include "base/file_path.h" #include "base/histogram.h" #include "base/scoped_ptr.h" #include "base/values.h" @@ -30,22 +29,23 @@ class PrefService; class Profile; class TemplateURLModel; -// This is used to quickly log stats from plugin-related notifications in -// MetricsService::plugin_stats_buffer_. The buffer's contents are transferred +// This is used to quickly log stats from child process related notifications in +// MetricsService::child_stats_buffer_. The buffer's contents are transferred // out when Local State is periodically saved. The information is then // reported to the UMA server on next launch. -struct PluginStats { +struct ChildProcessStats { public: - PluginStats() : process_launches(0), process_crashes(0), instances(0) {} + ChildProcessStats() : process_launches(0), process_crashes(0), instances(0) {} - // The number of times that the given plugin process has been launched + // The number of times that the given child process has been launched int process_launches; - // The number of times that the given plugin process has crashed + // The number of times that the given child process has crashed int process_crashes; - // The number of instances of this plugin that have been created. - // An instance is a DOM object rendered by this plugin during a page load. + // The number of instances of this child process that have been created. + // An instance is a DOM object rendered by this child process during a page + // load. int instances; }; @@ -315,12 +315,12 @@ class MetricsService : public NotificationObserver, // Sets preferences for the for the number of bookmarks in model. void LogBookmarks(BookmarkModel* model); - // Records a plugin-related notification. These are recorded to an in-object - // buffer because these notifications are sent on page load, and we don't - // want to slow that down. - void LogPluginChange(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details); + // Records a child process related notification. These are recorded to an + // in-object buffer because these notifications are sent on page load, and we + // don't want to slow that down. + void LogChildProcessChange(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details); // Logs keywords specific metrics. Keyword metrics are recorded in the // profile specific metrics. @@ -421,9 +421,9 @@ class MetricsService : public NotificationObserver, WindowMap window_map_; int next_window_id_; - // Buffer of plugin notifications for quick access. See PluginStats - // documentation above for more details. - std::map<FilePath, PluginStats> plugin_stats_buffer_; + // Buffer of child process notifications for quick access. See + // ChildProcessStats documentation above for more details. + std::map<std::wstring, ChildProcessStats> child_process_stats_buffer_; ScopedRunnableMethodFactory<MetricsService> log_sender_factory_; ScopedRunnableMethodFactory<MetricsService> state_saver_factory_; |