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

Unified Diff: chrome/browser/ui/webui/hung_renderer_dialog.h

Issue 8462015: Tests for WebUI Hung Renderer Dialog (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: TabContentsObserver Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/hung_renderer_dialog.js ('k') | chrome/browser/ui/webui/hung_renderer_dialog.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/hung_renderer_dialog.h
diff --git a/chrome/browser/ui/webui/hung_renderer_dialog.h b/chrome/browser/ui/webui/hung_renderer_dialog.h
index e26a8a13a4a92d438076b05fd3ac9b31c4f8cc3d..6f432ffc78224dc3fc72458d9949a1a9e047b202 100644
--- a/chrome/browser/ui/webui/hung_renderer_dialog.h
+++ b/chrome/browser/ui/webui/hung_renderer_dialog.h
@@ -9,9 +9,11 @@
#include <string>
#include <vector>
+#include "base/memory/scoped_ptr.h"
#include "base/string16.h"
#include "base/values.h"
#include "chrome/browser/ui/webui/html_dialog_ui.h"
+#include "content/browser/tab_contents/tab_contents_observer.h"
#include "ui/gfx/native_widget_types.h"
class TabContents;
@@ -26,7 +28,39 @@ class HungRendererDialog : private HtmlDialogUIDelegate {
static void HideHungRendererDialog(TabContents* contents);
private:
- HungRendererDialog();
+ class TabContentsObserverImpl : public TabContentsObserver {
+ public:
+ TabContentsObserverImpl(HungRendererDialog* dialog,
+ TabContents* contents)
+ : TabContentsObserver(contents),
+ contents_(contents),
+ dialog_(dialog) {
+ }
+
+ // TabContentsObserver overrides:
+ virtual void RenderViewGone() OVERRIDE {
+ dialog_->HideDialog(contents_);
+ }
+ virtual void TabContentsDestroyed(TabContents* tab) OVERRIDE {
+ dialog_->HideDialog(contents_);
+ }
+
+ private:
+ TabContents* contents_; // weak
+ HungRendererDialog* dialog_; // weak
+
+ DISALLOW_COPY_AND_ASSIGN(TabContentsObserverImpl);
+ };
flackr 2011/11/14 15:48:24 Move function bodies to the .cc file. The general
wyck 2011/11/14 18:08:38 Done.
+
+ friend class HungRendererDialogUITest;
+
+ // Shows a hung renderer dialog that, if not enabled, won't kill processes
+ // or restart hang timers.
+ static void ShowHungRendererDialogInternal(TabContents* contents,
+ bool is_enabled);
+
+ explicit HungRendererDialog(bool is_enabled);
+ ~HungRendererDialog();
// Shows the hung renderer dialog.
void ShowDialog(TabContents* contents);
@@ -53,9 +87,17 @@ class HungRendererDialog : private HtmlDialogUIDelegate {
// The dialog handler.
HungRendererDialogHandler* handler_;
+ // A safety switch that must be enabled to allow actual killing of processes
+ // or restarting of the hang timer. This is necessary so that tests can
+ // create a disabled version of this dialog that won't kill processes or
+ // restart timers when the dialog closes at the end of the test.
+ bool is_enabled_;
+
// The dialog window.
gfx::NativeWindow window_;
+ scoped_ptr<TabContentsObserverImpl> contents_observer_;
+
DISALLOW_COPY_AND_ASSIGN(HungRendererDialog);
};
« no previous file with comments | « chrome/browser/resources/hung_renderer_dialog.js ('k') | chrome/browser/ui/webui/hung_renderer_dialog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698