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

Unified Diff: chrome/browser/hang_monitor/hung_plugin_action.cc

Issue 9958104: Log when a browser plugin hangs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update based on jam@'s review comments Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/hang_monitor/hung_plugin_action.h ('k') | webkit/plugins/npapi/webplugin_delegate_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/hang_monitor/hung_plugin_action.cc
diff --git a/chrome/browser/hang_monitor/hung_plugin_action.cc b/chrome/browser/hang_monitor/hung_plugin_action.cc
index 57951c9d38fa16fc604305935e4039b49e6c2eff..bb38dcbd20985c77fe60ecfe3c0b55905a8a73d9 100644
--- a/chrome/browser/hang_monitor/hung_plugin_action.cc
+++ b/chrome/browser/hang_monitor/hung_plugin_action.cc
@@ -6,13 +6,42 @@
#include "chrome/browser/hang_monitor/hung_plugin_action.h"
+#include "base/metrics/histogram.h"
+#include "base/version.h"
#include "chrome/browser/simple_message_box.h"
#include "chrome/common/logging_chrome.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/win/hwnd_util.h"
+#include "webkit/plugins/npapi/plugin_group.h"
#include "webkit/plugins/npapi/webplugin_delegate_impl.h"
+namespace {
+
+const wchar_t kGTalkPluginName[] = L"Google Talk Plugin";
+const int kMaxGTalkPluginVersion = 10000;
+
+// Converts the version string of Google Talk Plugin to a number. The
+// version format is "major(1 digit).minor(1 digit).sub(1 or 2 digits)",
+// for example, "2.7.10" and "2.8.1". Converts the string to a number as
+// 1000 * major + 100 * minor + sub.
+int GetGTalkPluginVersion(const string16& version) {
+ int gtalk_plugin_version = 0;
+ scoped_ptr<Version> plugin_version(
+ webkit::npapi::PluginGroup::CreateVersionFromString(version));
+ if (plugin_version.get() && plugin_version->components().size() >= 3) {
+ gtalk_plugin_version = plugin_version->components()[0] * 1000 +
+ plugin_version->components()[1] * 100 +
+ plugin_version->components()[2];
+ if (gtalk_plugin_version > kMaxGTalkPluginVersion) {
+ gtalk_plugin_version = kMaxGTalkPluginVersion;
+ }
+ }
+ return gtalk_plugin_version;
+}
+
+} // namespace
+
HungPluginAction::HungPluginAction() : current_hung_plugin_window_(NULL) {
}
@@ -36,19 +65,29 @@ bool HungPluginAction::OnHungWindowDetected(HWND hung_window,
GetWindowThreadProcessId(hung_window, &hung_window_process_id);
GetWindowThreadProcessId(top_level_window, &top_level_window_process_id);
+ bool is_gtalk_plugin = false;
+ int gtalk_plugin_version = 0;
*action = HungWindowNotification::HUNG_WINDOW_IGNORE;
if (top_level_window_process_id != hung_window_process_id) {
+ string16 plugin_name;
+ string16 plugin_version;
+ GetPluginNameAndVersion(hung_window,
+ top_level_window_process_id,
+ &plugin_name,
+ &plugin_version);
+ if (plugin_name.empty()) {
+ plugin_name = l10n_util::GetStringUTF16(IDS_UNKNOWN_PLUGIN_NAME);
+ }
+
+ is_gtalk_plugin = (kGTalkPluginName == plugin_name);
+ if (is_gtalk_plugin) {
+ gtalk_plugin_version = GetGTalkPluginVersion(plugin_version);
+ }
+
if (logging::DialogsAreSuppressed()) {
NOTREACHED() << "Terminated a hung plugin process.";
*action = HungWindowNotification::HUNG_WINDOW_TERMINATE_PROCESS;
} else {
- string16 plugin_name;
- GetPluginName(hung_window,
- top_level_window_process_id,
- &plugin_name);
- if (plugin_name.empty()) {
- plugin_name = l10n_util::GetStringUTF16(IDS_UNKNOWN_PLUGIN_NAME);
- }
string16 msg = l10n_util::GetStringFUTF16(IDS_BROWSER_HANGMONITOR,
plugin_name);
string16 title = l10n_util::GetStringUTF16(IDS_BROWSER_HANGMONITOR_TITLE);
@@ -91,6 +130,18 @@ bool HungPluginAction::OnHungWindowDetected(HWND hung_window,
// Enable the top-level window just in case the plugin had been
// displaying a modal box that had disabled the top-level window
EnableWindow(top_level_window, TRUE);
+
+ UMA_HISTOGRAM_COUNTS("Plugin.Hung_Terminate_Process", 1);
+ if (is_gtalk_plugin) {
+ UMA_HISTOGRAM_ENUMERATION("GTalkPlugin.Hung_Terminate_Process",
jar (doing other things) 2012/04/03 19:20:39 We don't have a sparse histogram, and so the cost
+ gtalk_plugin_version, kMaxGTalkPluginVersion + 1);
+ }
+ } else {
+ UMA_HISTOGRAM_COUNTS("Plugin.Hung_Ignore", 1);
+ if (is_gtalk_plugin) {
+ UMA_HISTOGRAM_ENUMERATION("GTalkPlugin.Hung_Ignore",
+ gtalk_plugin_version, kMaxGTalkPluginVersion + 1);
jar (doing other things) 2012/04/03 19:20:39 This would be another 120KB :-/.
+ }
}
return continue_hang_detection;
}
@@ -107,10 +158,12 @@ void HungPluginAction::OnWindowResponsive(HWND window) {
}
}
-bool HungPluginAction::GetPluginName(HWND plugin_window,
- DWORD browser_process_id,
- std::wstring* plugin_name) {
+bool HungPluginAction::GetPluginNameAndVersion(HWND plugin_window,
+ DWORD browser_process_id,
+ std::wstring* plugin_name,
+ std::wstring* plugin_version) {
DCHECK(plugin_name);
+ DCHECK(plugin_version);
HWND window_to_check = plugin_window;
while (NULL != window_to_check) {
DWORD process_id = 0;
@@ -122,6 +175,8 @@ bool HungPluginAction::GetPluginName(HWND plugin_window,
}
if (webkit::npapi::WebPluginDelegateImpl::GetPluginNameFromWindow(
window_to_check, plugin_name)) {
+ webkit::npapi::WebPluginDelegateImpl::GetPluginVersionFromWindow(
+ window_to_check, plugin_version);
return true;
}
window_to_check = GetParent(window_to_check);
« no previous file with comments | « chrome/browser/hang_monitor/hung_plugin_action.h ('k') | webkit/plugins/npapi/webplugin_delegate_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698