summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/frame
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-11 22:03:15 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-11 22:03:15 +0000
commitc6e6700f0ad9075d6ef675dd4de0626570929000 (patch)
tree10621884ce2a81d52326ac3d8e32cc1063b88895 /chrome/browser/views/frame
parent83ec6d395d0b8a836370579368e1b365a3abbca4 (diff)
downloadchromium_src-c6e6700f0ad9075d6ef675dd4de0626570929000.zip
chromium_src-c6e6700f0ad9075d6ef675dd4de0626570929000.tar.gz
chromium_src-c6e6700f0ad9075d6ef675dd4de0626570929000.tar.bz2
Move the hang monitor to the BrowserView, since it's highly Windows/HWND specific.
http://crbug.com/4310 Review URL: http://codereview.chromium.org/10601 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5211 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/frame')
-rw-r--r--chrome/browser/views/frame/browser_view.cc43
-rw-r--r--chrome/browser/views/frame/browser_view.h23
2 files changed, 64 insertions, 2 deletions
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 5a992b8..e26cc95 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -59,6 +59,10 @@ static const int kSeparationLineHeight = 1;
static const wchar_t* kBrowserWindowKey = L"__BROWSER_WINDOW__";
// The distance between tiled windows.
static const int kWindowTilePixels = 10;
+// How frequently we check for hung plugin windows.
+static const int kDefaultHungPluginDetectFrequency = 2000;
+// How long do we wait before we consider a window hung (in ms).
+static const int kDefaultPluginMessageResponseTimeout = 30000;
static const struct { bool separator; int command; int label; } kMenuLayout[] = {
{ true, 0, 0 },
@@ -98,6 +102,8 @@ BrowserView::BrowserView(Browser* browser)
contents_container_(NULL),
initialized_(false),
can_drop_(false),
+ hung_window_detector_(&hung_plugin_action_),
+ ticker_(0),
#ifdef CHROME_PERSONALIZATION
personalization_enabled_(false),
personalization_(NULL),
@@ -111,6 +117,10 @@ BrowserView::BrowserView(Browser* browser)
BrowserView::~BrowserView() {
browser_->tabstrip_model()->RemoveObserver(this);
+
+ // Stop hung plugin monitoring.
+ ticker_.Stop();
+ ticker_.UnregisterTickHandler(&hung_window_detector_);
}
void BrowserView::WindowMoved() {
@@ -260,6 +270,14 @@ unsigned int BrowserView::FeaturesForBrowserType(BrowserType::Type type) {
return features;
}
+// static
+void BrowserView::RegisterBrowserViewPrefs(PrefService* prefs) {
+ prefs->RegisterIntegerPref(prefs::kPluginMessageResponseTimeout,
+ kDefaultPluginMessageResponseTimeout);
+ prefs->RegisterIntegerPref(prefs::kHungPluginDetectFrequency,
+ kDefaultHungPluginDetectFrequency);
+}
+
///////////////////////////////////////////////////////////////////////////////
// BrowserView, BrowserWindow implementation:
@@ -268,6 +286,11 @@ void BrowserView::Init() {
// at it later when all we have is a HWND.
SetProp(GetContainer()->GetHWND(), kBrowserWindowKey, this);
+ // Start a hung plugin window detector for this browser object (as long as
+ // hang detection is not disabled).
+ if (!CommandLine().HasSwitch(switches::kDisableHangMonitor))
+ InitHangMonitor();
+
LoadAccelerators();
SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME));
@@ -1125,6 +1148,26 @@ int BrowserView::GetCommandIDForAppCommandID(int app_command_id) const {
return -1;
}
+void BrowserView::InitHangMonitor() {
+ PrefService* pref_service = g_browser_process->local_state();
+ int plugin_message_response_timeout =
+ pref_service->GetInteger(prefs::kPluginMessageResponseTimeout);
+ int hung_plugin_detect_freq =
+ pref_service->GetInteger(prefs::kHungPluginDetectFrequency);
+ if ((hung_plugin_detect_freq > 0) &&
+ hung_window_detector_.Initialize(GetContainer()->GetHWND(),
+ plugin_message_response_timeout)) {
+ ticker_.set_tick_interval(hung_plugin_detect_freq);
+ ticker_.RegisterTickHandler(&hung_window_detector_);
+ ticker_.Start();
+
+ pref_service->SetInteger(prefs::kPluginMessageResponseTimeout,
+ plugin_message_response_timeout);
+ pref_service->SetInteger(prefs::kHungPluginDetectFrequency,
+ hung_plugin_detect_freq);
+ }
+}
+
// static
void BrowserView::InitClass() {
static bool initialized = false;
diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h
index 8e04f6d..73ba719 100644
--- a/chrome/browser/views/frame/browser_view.h
+++ b/chrome/browser/views/frame/browser_view.h
@@ -7,6 +7,8 @@
#include "chrome/browser/browser_type.h"
#include "chrome/browser/browser_window.h"
+#include "chrome/browser/hang_monitor/hung_plugin_action.h"
+#include "chrome/browser/hang_monitor/hung_window_detector.h"
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/views/frame/browser_frame.h"
#include "chrome/common/pref_member.h"
@@ -130,6 +132,9 @@ class BrowserView : public BrowserWindow,
// Returns the set of WindowFeatures supported by the specified BrowserType.
static unsigned int FeaturesForBrowserType(BrowserType::Type type);
+ // Register preferences specific to this view.
+ static void RegisterBrowserViewPrefs(PrefService* prefs);
+
// Overridden from BrowserWindow:
virtual void Init();
virtual void Show(int command, bool adjust_to_fit);
@@ -202,8 +207,6 @@ class BrowserView : public BrowserWindow,
}
#endif
-
-
protected:
// Overridden from views::View:
virtual void Layout();
@@ -291,6 +294,9 @@ class BrowserView : public BrowserWindow,
// Retrieves the command id for the specified Windows app command.
int GetCommandIDForAppCommandID(int app_command_id) const;
+ // Initialize the hung plugin detector.
+ void InitHangMonitor();
+
// Initialize class statics.
static void InitClass();
@@ -352,6 +358,19 @@ class BrowserView : public BrowserWindow,
// The delegate for the encoding menu.
scoped_ptr<EncodingMenuControllerDelegate> encoding_menu_delegate_;
+ // This object is used to perform periodic actions in a worker
+ // thread. It is currently used to monitor hung plugin windows.
+ WorkerThreadTicker ticker_;
+
+ // This object is initialized with the frame window HWND. This
+ // object is also passed as a tick handler with the ticker_ object.
+ // It is used to periodically monitor for hung plugin windows
+ HungWindowDetector hung_window_detector_;
+
+ // This object is invoked by hung_window_detector_ when it detects a hung
+ // plugin window.
+ HungPluginAction hung_plugin_action_;
+
// P13N stuff
#ifdef CHROME_PERSONALIZATION
FramePersonalization personalization_;