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

Unified Diff: chrome/test/base/ui_test_utils.cc

Issue 8834012: Quit MessageLoop in ui_test_utils::DOMOperationObserver when the RenderView goes away. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/base/ui_test_utils.cc
diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc
index 8adafef7ebf0414bd7984e9d811bce22701a6214..1c186357058b157b4acbc6adfda04e1624119454 100644
--- a/chrome/test/base/ui_test_utils.cc
+++ b/chrome/test/base/ui_test_utils.cc
@@ -50,6 +50,7 @@
#include "content/browser/tab_contents/navigation_controller.h"
#include "content/browser/tab_contents/navigation_entry.h"
#include "content/browser/tab_contents/tab_contents.h"
+#include "content/browser/tab_contents/tab_contents_observer.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_process_host.h"
#include "googleurl/src/gurl.h"
@@ -73,10 +74,12 @@ namespace ui_test_utils {
namespace {
-class DOMOperationObserver : public content::NotificationObserver {
+class DOMOperationObserver : public content::NotificationObserver,
+ public TabContentsObserver {
public:
explicit DOMOperationObserver(RenderViewHost* render_view_host)
- : did_respond_(false) {
+ : TabContentsObserver(render_view_host->delegate()->GetAsTabContents()),
+ did_respond_(false) {
registrar_.Add(this, chrome::NOTIFICATION_DOM_OPERATION_RESPONSE,
content::Source<RenderViewHost>(render_view_host));
ui_test_utils::RunMessageLoop();
@@ -84,7 +87,7 @@ class DOMOperationObserver : public content::NotificationObserver {
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details) {
+ const content::NotificationDetails& details) OVERRIDE {
DCHECK(type == chrome::NOTIFICATION_DOM_OPERATION_RESPONSE);
content::Details<DomOperationNotificationDetails> dom_op_details(details);
response_ = dom_op_details->json();
@@ -92,6 +95,11 @@ class DOMOperationObserver : public content::NotificationObserver {
MessageLoopForUI::current()->Quit();
}
+ // Overridden from content::TabContentsObserver:
+ virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE {
+ MessageLoopForUI::current()->Quit();
+ }
+
bool GetResponse(std::string* response) WARN_UNUSED_RESULT {
*response = response_;
return did_respond_;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698