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

Side by Side Diff: content/browser/renderer_host/render_view_host.cc

Issue 6973073: Avoid canceling a pending navigation if the old RVH commits right away. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix failing unit tests. Created 9 years, 6 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/render_view_host.h" 5 #include "content/browser/renderer_host/render_view_host.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 // action. 792 // action.
793 void RenderViewHost::OnMsgNavigate(const IPC::Message& msg) { 793 void RenderViewHost::OnMsgNavigate(const IPC::Message& msg) {
794 // Read the parameters out of the IPC message directly to avoid making another 794 // Read the parameters out of the IPC message directly to avoid making another
795 // copy when we filter the URLs. 795 // copy when we filter the URLs.
796 void* iter = NULL; 796 void* iter = NULL;
797 ViewHostMsg_FrameNavigate_Params validated_params; 797 ViewHostMsg_FrameNavigate_Params validated_params;
798 if (!IPC::ParamTraits<ViewHostMsg_FrameNavigate_Params>:: 798 if (!IPC::ParamTraits<ViewHostMsg_FrameNavigate_Params>::
799 Read(&msg, &iter, &validated_params)) 799 Read(&msg, &iter, &validated_params))
800 return; 800 return;
801 801
802 // If we're waiting for a beforeunload ack from this renderer and we receive 802 // If we're waiting for a cross-site beforeunload ack from this renderer and
803 // a Navigate message from the main frame, then the renderer was navigating 803 // we receive a Navigate message from the main frame, then the renderer was
804 // before it received the request. If it is during a cross-site navigation, 804 // navigating already and sent it before hearing the ViewMsg_Stop message.
805 // then we should forget about the beforeunload, because the navigation will 805 // We do not want to cancel the pending navigation in this case, since the
806 // now be canceled. (If it is instead during an attempt to close the page, 806 // old page will soon be stopped. Instead, treat this as a beforeunload ack
807 // we should be sure to keep waiting for the ack, which the new page will 807 // to allow the pending navigation to continue.
brettw 2011/06/02 08:48:24 This explanation seems reasonable, but I'm trustin
808 // send.)
809 //
810 // If we did not clear this state, an unresponsiveness timer might think we
811 // are waiting for an ack but are not in a cross-site navigation, and would
812 // close the tab. TODO(creis): That timer code should be refactored to only
813 // close the tab if we explicitly know the user tried to close the tab, and
814 // not just check for the absence of a cross-site navigation. Once that's
815 // fixed, this check can go away.
816 if (is_waiting_for_beforeunload_ack_ && 808 if (is_waiting_for_beforeunload_ack_ &&
817 unload_ack_is_for_cross_site_transition_ && 809 unload_ack_is_for_cross_site_transition_ &&
818 PageTransition::IsMainFrame(validated_params.transition)) { 810 PageTransition::IsMainFrame(validated_params.transition)) {
819 is_waiting_for_beforeunload_ack_ = false; 811 OnMsgShouldCloseACK(true);
820 StopHangMonitorTimeout(); 812 return;
821 } 813 }
822 814
823 // If we're waiting for an unload ack from this renderer and we receive a 815 // If we're waiting for an unload ack from this renderer and we receive a
824 // Navigate message, then the renderer was navigating before it received the 816 // Navigate message, then the renderer was navigating before it received the
825 // unload request. It will either respond to the unload request soon or our 817 // unload request. It will either respond to the unload request soon or our
826 // timer will expire. Either way, we should ignore this message, because we 818 // timer will expire. Either way, we should ignore this message, because we
827 // have already committed to closing this renderer. 819 // have already committed to closing this renderer.
828 if (is_waiting_for_unload_ack_) 820 if (is_waiting_for_unload_ack_)
829 return; 821 return;
830 822
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 if (view) { 1270 if (view) {
1279 view->ShowPopupMenu(params.bounds, 1271 view->ShowPopupMenu(params.bounds,
1280 params.item_height, 1272 params.item_height,
1281 params.item_font_size, 1273 params.item_font_size,
1282 params.selected_item, 1274 params.selected_item,
1283 params.popup_items, 1275 params.popup_items,
1284 params.right_aligned); 1276 params.right_aligned);
1285 } 1277 }
1286 } 1278 }
1287 #endif 1279 #endif
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/web_contents_unittest.cc ('k') | content/browser/tab_contents/navigation_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698