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

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

Issue 88503002: Have the unload event execute in background on cross-site navigations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_impl.h" 5 #include "content/browser/renderer_host/render_view_host_impl.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 using blink::WebMediaPlayerAction; 95 using blink::WebMediaPlayerAction;
96 using blink::WebPluginAction; 96 using blink::WebPluginAction;
97 97
98 namespace content { 98 namespace content {
99 namespace { 99 namespace {
100 100
101 // Delay to wait on closing the WebContents for a beforeunload/unload handler to 101 // Delay to wait on closing the WebContents for a beforeunload/unload handler to
102 // fire. 102 // fire.
103 const int kUnloadTimeoutMS = 1000; 103 const int kUnloadTimeoutMS = 1000;
104 104
105 // Delay to wait on closing the WebContents for an unload/handler to fire when
106 // swapping renderers. The old renderer will allways be sent to the background
Charlie Reis 2013/11/26 19:35:00 nit: always As Ojan wondered, have you checked wh
107 // since the unload handler cannot show dialogues.
108 // http://crbug.com/323528.
109 const int kUnloadSwapTimeoutMS = 0;
110
105 // Translate a WebKit text direction into a base::i18n one. 111 // Translate a WebKit text direction into a base::i18n one.
106 base::i18n::TextDirection WebTextDirectionToChromeTextDirection( 112 base::i18n::TextDirection WebTextDirectionToChromeTextDirection(
107 blink::WebTextDirection dir) { 113 blink::WebTextDirection dir) {
108 switch (dir) { 114 switch (dir) {
109 case blink::WebTextDirectionLeftToRight: 115 case blink::WebTextDirectionLeftToRight:
110 return base::i18n::LEFT_TO_RIGHT; 116 return base::i18n::LEFT_TO_RIGHT;
111 case blink::WebTextDirectionRightToLeft: 117 case blink::WebTextDirectionRightToLeft:
112 return base::i18n::RIGHT_TO_LEFT; 118 return base::i18n::RIGHT_TO_LEFT;
113 default: 119 default:
114 NOTREACHED(); 120 NOTREACHED();
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 } 693 }
688 694
689 void RenderViewHostImpl::SuppressDialogsUntilSwapOut() { 695 void RenderViewHostImpl::SuppressDialogsUntilSwapOut() {
690 Send(new ViewMsg_SuppressDialogsUntilSwapOut(GetRoutingID())); 696 Send(new ViewMsg_SuppressDialogsUntilSwapOut(GetRoutingID()));
691 } 697 }
692 698
693 void RenderViewHostImpl::SwapOut() { 699 void RenderViewHostImpl::SwapOut() {
694 // This will be set back to false in OnSwapOutACK, just before we replace 700 // This will be set back to false in OnSwapOutACK, just before we replace
695 // this RVH with the pending RVH. 701 // this RVH with the pending RVH.
696 is_waiting_for_unload_ack_ = true; 702 is_waiting_for_unload_ack_ = true;
697 // Start the hang monitor in case the renderer hangs in the unload handler.
698 // Increment the in-flight event count, to ensure that input events won't
699 // cancel the timeout timer.
700 increment_in_flight_event_count();
701 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS));
702 703
703 if (IsRenderViewLive()) { 704 if (IsRenderViewLive()) {
704 Send(new ViewMsg_SwapOut(GetRoutingID())); 705 Send(new ViewMsg_SwapOut(GetRoutingID()));
706 // The hang monitor will immediately time out, which will cause the old
707 // renderer to go execute the unload event in the background. The swap out
708 // can then proceed without any delay.
709 // http://crbug.com/323528.
710 increment_in_flight_event_count();
711 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadSwapTimeoutMS));
Charlie Reis 2013/11/26 19:35:00 Moving these calls inside the if seems like a prob
705 } else { 712 } else {
706 // This RenderViewHost doesn't have a live renderer, so just skip the unload 713 // This RenderViewHost doesn't have a live renderer, so just skip the unload
707 // event. 714 // event.
708 OnSwappedOut(true); 715 OnSwappedOut(true);
709 } 716 }
710 } 717 }
711 718
712 void RenderViewHostImpl::OnSwapOutACK() { 719 void RenderViewHostImpl::OnSwapOutACK() {
713 OnSwappedOut(false); 720 OnSwappedOut(false);
714 } 721 }
(...skipping 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after
2285 void RenderViewHostImpl::AttachToFrameTree() { 2292 void RenderViewHostImpl::AttachToFrameTree() {
2286 FrameTree* frame_tree = delegate_->GetFrameTree(); 2293 FrameTree* frame_tree = delegate_->GetFrameTree();
2287 2294
2288 frame_tree->SwapMainFrame(main_render_frame_host_.get()); 2295 frame_tree->SwapMainFrame(main_render_frame_host_.get());
2289 if (main_frame_id() != FrameTreeNode::kInvalidFrameId) { 2296 if (main_frame_id() != FrameTreeNode::kInvalidFrameId) {
2290 frame_tree->OnFirstNavigationAfterSwap(main_frame_id()); 2297 frame_tree->OnFirstNavigationAfterSwap(main_frame_id());
2291 } 2298 }
2292 } 2299 }
2293 2300
2294 } // namespace content 2301 } // namespace content
OLDNEW
« 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