Commit 83ce153a authored by bauerb@chromium.org's avatar bauerb@chromium.org

Quit MessageLoop in ui_test_utils::DOMOperationObserver when the RenderView goes away.

This should turn some timeouts caused by a renderer crash into immediate failures.

BUG=106541
TEST=less timeouts


Review URL: http://codereview.chromium.org/8834012

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113501 0039d316-1c4b-4281-b951-d872f2087c98
parent 4a852226
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#include "content/browser/tab_contents/navigation_controller.h" #include "content/browser/tab_contents/navigation_controller.h"
#include "content/browser/tab_contents/navigation_entry.h" #include "content/browser/tab_contents/navigation_entry.h"
#include "content/browser/tab_contents/tab_contents.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/notification_service.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "googleurl/src/gurl.h" #include "googleurl/src/gurl.h"
...@@ -73,10 +74,12 @@ namespace ui_test_utils { ...@@ -73,10 +74,12 @@ namespace ui_test_utils {
namespace { namespace {
class DOMOperationObserver : public content::NotificationObserver { class DOMOperationObserver : public content::NotificationObserver,
public TabContentsObserver {
public: public:
explicit DOMOperationObserver(RenderViewHost* render_view_host) 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, registrar_.Add(this, chrome::NOTIFICATION_DOM_OPERATION_RESPONSE,
content::Source<RenderViewHost>(render_view_host)); content::Source<RenderViewHost>(render_view_host));
ui_test_utils::RunMessageLoop(); ui_test_utils::RunMessageLoop();
...@@ -84,7 +87,7 @@ class DOMOperationObserver : public content::NotificationObserver { ...@@ -84,7 +87,7 @@ class DOMOperationObserver : public content::NotificationObserver {
virtual void Observe(int type, virtual void Observe(int type,
const content::NotificationSource& source, const content::NotificationSource& source,
const content::NotificationDetails& details) { const content::NotificationDetails& details) OVERRIDE {
DCHECK(type == chrome::NOTIFICATION_DOM_OPERATION_RESPONSE); DCHECK(type == chrome::NOTIFICATION_DOM_OPERATION_RESPONSE);
content::Details<DomOperationNotificationDetails> dom_op_details(details); content::Details<DomOperationNotificationDetails> dom_op_details(details);
response_ = dom_op_details->json(); response_ = dom_op_details->json();
...@@ -92,6 +95,11 @@ class DOMOperationObserver : public content::NotificationObserver { ...@@ -92,6 +95,11 @@ class DOMOperationObserver : public content::NotificationObserver {
MessageLoopForUI::current()->Quit(); 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 { bool GetResponse(std::string* response) WARN_UNUSED_RESULT {
*response = response_; *response = response_;
return did_respond_; return did_respond_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment