summaryrefslogtreecommitdiffstats
path: root/chrome/browser/render_view_host.cc
diff options
context:
space:
mode:
authorojan@google.com <ojan@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-06 01:18:56 +0000
committerojan@google.com <ojan@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-06 01:18:56 +0000
commitd878bab389753cb876231717217a7e470b5a261f (patch)
tree1f806e2126df04174e396755994ad9f2eec87c7c /chrome/browser/render_view_host.cc
parentdcc8f1c678af98247adc7a056ace7e6c145ed189 (diff)
downloadchromium_src-d878bab389753cb876231717217a7e470b5a261f.zip
chromium_src-d878bab389753cb876231717217a7e470b5a261f.tar.gz
chromium_src-d878bab389753cb876231717217a7e470b5a261f.tar.bz2
Bandaid patch so that we continue with crosssite navigations instead of closing the tab if the beforeunload /unload handler hangs. This patch does the right user-visible behavior, but I'm not a huge fan of the plumbing necessary to make it work. Totally open to cleanup suggestions.
There's also currently one bug that I haven't been able to pinpoint in the UI test. It only treats the first UI test of the four that I run as a cross-site navigation. No matter which test I run first. I wonder if there is some state I should be setting/clearing before/after each test run? Also there's a DHECK that we hit that the UI test exposed. I 'm not sure it's a case that a user could actually hit though and it's not new with this code, so I added a TODO. Can I get help from a mac person on adding the UI test to the xcode project? BUG=3198 Review URL: http://codereview.chromium.org/8920 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4855 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/render_view_host.cc')
-rw-r--r--chrome/browser/render_view_host.cc33
1 files changed, 15 insertions, 18 deletions
diff --git a/chrome/browser/render_view_host.cc b/chrome/browser/render_view_host.cc
index 84f5a7d..8f866ec 100644
--- a/chrome/browser/render_view_host.cc
+++ b/chrome/browser/render_view_host.cc
@@ -243,9 +243,6 @@ void RenderViewHost::FirePageBeforeUnload() {
}
void RenderViewHost::FirePageUnload() {
- // Start the hang monitor in case the renderer hangs in the unload handler.
- is_waiting_for_unload_ack_ = true;
- StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS));
ClosePage(site_instance()->process_host_id(),
routing_id());
}
@@ -267,6 +264,10 @@ void RenderViewHost::ClosePageIgnoringUnloadEvents(int render_process_host_id,
void RenderViewHost::ClosePage(int new_render_process_host_id,
int new_request_id) {
+ // Start the hang monitor in case the renderer hangs in the unload handler.
+ is_waiting_for_unload_ack_ = true;
+ StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS));
+
if (IsRenderViewLive()) {
Send(new ViewMsg_ClosePage(routing_id_,
new_render_process_host_id,
@@ -280,9 +281,15 @@ void RenderViewHost::ClosePage(int new_render_process_host_id,
}
}
-void RenderViewHost::SetHasPendingCrossSiteRequest(bool has_pending_request) {
+void RenderViewHost::SetHasPendingCrossSiteRequest(bool has_pending_request,
+ int request_id) {
Singleton<CrossSiteRequestManager>()->SetHasPendingCrossSiteRequest(
process()->host_id(), routing_id_, has_pending_request);
+ pending_request_id_ = request_id;
+}
+
+int RenderViewHost::GetPendingRequestId() {
+ return pending_request_id_;
}
void RenderViewHost::OnCrossSiteResponse(int new_render_process_host_id,
@@ -1041,6 +1048,7 @@ void RenderViewHost::OnMsgRunJavaScriptMessage(
StopHangMonitorTimeout();
if (modal_dialog_count_++ == 0)
SetEvent(modal_dialog_event_.Get());
+ bool did_suppress_message = false;
delegate_->RunJavaScriptMessage(message, default_prompt, flags, reply_msg);
}
@@ -1251,22 +1259,11 @@ void RenderViewHost::OnQueryFormFieldAutofill(const std::wstring& field_name,
}
void RenderViewHost::NotifyRendererUnresponsive() {
- if (is_waiting_for_unload_ack_ &&
- !Singleton<CrossSiteRequestManager>()->HasPendingCrossSiteRequest(
- process()->host_id(), routing_id_)) {
- // If the tab hangs in the beforeunload/unload handler there's really
- // nothing we can do to recover. Pretend the unload listeners have
- // all fired and close the tab. If the hang is in the beforeunload handler
- // then the user will not have the option of cancelling the close.
- UnloadListenerHasFired();
- delegate_->Close(this);
- return;
- }
-
// If the debugger is attached, we're going to be unresponsive anytime it's
// stopped at a breakpoint.
- if (!debugger_attached_)
- delegate_->RendererUnresponsive(this);
+ if (!debugger_attached_) {
+ delegate_->RendererUnresponsive(this, is_waiting_for_unload_ack_);
+ }
}
void RenderViewHost::NotifyRendererResponsive() {