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

Side by Side Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 606113005: Move RenderViewHost swap out state to RenderFrameHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix review suggestions Created 6 years, 2 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/frame_host/render_frame_host_impl.h" 5 #include "content/browser/frame_host/render_frame_host_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 case blink::WebTextDirectionRightToLeft: 142 case blink::WebTextDirectionRightToLeft:
143 return base::i18n::RIGHT_TO_LEFT; 143 return base::i18n::RIGHT_TO_LEFT;
144 default: 144 default:
145 NOTREACHED(); 145 NOTREACHED();
146 return base::i18n::UNKNOWN_DIRECTION; 146 return base::i18n::UNKNOWN_DIRECTION;
147 } 147 }
148 } 148 }
149 149
150 } // namespace 150 } // namespace
151 151
152 // static
153 bool RenderFrameHostImpl::IsRFHStateActive(RenderFrameHostImplState rfh_state) {
154 return rfh_state == STATE_DEFAULT;
155 }
156
157 // static
152 RenderFrameHost* RenderFrameHost::FromID(int render_process_id, 158 RenderFrameHost* RenderFrameHost::FromID(int render_process_id,
153 int render_frame_id) { 159 int render_frame_id) {
154 return RenderFrameHostImpl::FromID(render_process_id, render_frame_id); 160 return RenderFrameHostImpl::FromID(render_process_id, render_frame_id);
155 } 161 }
156 162
157 // static 163 // static
158 RenderFrameHostImpl* RenderFrameHostImpl::FromID(int process_id, 164 RenderFrameHostImpl* RenderFrameHostImpl::FromID(int process_id,
159 int routing_id) { 165 int routing_id) {
160 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
161 RoutingIDFrameMap* frames = g_routing_id_frame_map.Pointer(); 167 RoutingIDFrameMap* frames = g_routing_id_frame_map.Pointer();
162 RoutingIDFrameMap::iterator it = frames->find( 168 RoutingIDFrameMap::iterator it = frames->find(
163 RenderFrameHostID(process_id, routing_id)); 169 RenderFrameHostID(process_id, routing_id));
164 return it == frames->end() ? NULL : it->second; 170 return it == frames->end() ? NULL : it->second;
165 } 171 }
166 172
167 RenderFrameHostImpl::RenderFrameHostImpl(RenderViewHostImpl* render_view_host, 173 RenderFrameHostImpl::RenderFrameHostImpl(RenderViewHostImpl* render_view_host,
168 RenderFrameHostDelegate* delegate, 174 RenderFrameHostDelegate* delegate,
169 FrameTree* frame_tree, 175 FrameTree* frame_tree,
170 FrameTreeNode* frame_tree_node, 176 FrameTreeNode* frame_tree_node,
171 int routing_id, 177 int routing_id,
172 bool is_swapped_out) 178 bool is_swapped_out)
173 : render_view_host_(render_view_host), 179 : render_view_host_(render_view_host),
174 delegate_(delegate), 180 delegate_(delegate),
175 cross_process_frame_connector_(NULL), 181 cross_process_frame_connector_(NULL),
176 render_frame_proxy_host_(NULL), 182 render_frame_proxy_host_(NULL),
177 frame_tree_(frame_tree), 183 frame_tree_(frame_tree),
178 frame_tree_node_(frame_tree_node), 184 frame_tree_node_(frame_tree_node),
179 routing_id_(routing_id), 185 routing_id_(routing_id),
180 is_swapped_out_(is_swapped_out),
181 render_frame_created_(false), 186 render_frame_created_(false),
182 navigations_suspended_(false), 187 navigations_suspended_(false),
188 is_waiting_for_beforeunload_ack_(false),
189 unload_ack_is_for_cross_site_transition_(false),
183 weak_ptr_factory_(this) { 190 weak_ptr_factory_(this) {
184 frame_tree_->RegisterRenderFrameHost(this); 191 frame_tree_->RegisterRenderFrameHost(this);
185 GetProcess()->AddRoute(routing_id_, this); 192 GetProcess()->AddRoute(routing_id_, this);
186 g_routing_id_frame_map.Get().insert(std::make_pair( 193 g_routing_id_frame_map.Get().insert(std::make_pair(
187 RenderFrameHostID(GetProcess()->GetID(), routing_id_), 194 RenderFrameHostID(GetProcess()->GetID(), routing_id_),
188 this)); 195 this));
189 196
197 if (is_swapped_out) {
198 rfh_state_ = STATE_SWAPPED_OUT;
199 } else {
200 rfh_state_ = STATE_DEFAULT;
201 GetSiteInstance()->increment_active_frame_count();
202 }
203
190 if (GetProcess()->GetServiceRegistry()) { 204 if (GetProcess()->GetServiceRegistry()) {
191 RenderFrameSetupPtr setup; 205 RenderFrameSetupPtr setup;
192 GetProcess()->GetServiceRegistry()->ConnectToRemoteService(&setup); 206 GetProcess()->GetServiceRegistry()->ConnectToRemoteService(&setup);
193 mojo::ServiceProviderPtr service_provider; 207 mojo::ServiceProviderPtr service_provider;
194 setup->GetServiceProviderForFrame(routing_id_, 208 setup->GetServiceProviderForFrame(routing_id_,
195 mojo::Get(&service_provider)); 209 mojo::Get(&service_provider));
196 service_registry_.BindRemoteServiceProvider( 210 service_registry_.BindRemoteServiceProvider(
197 service_provider.PassMessagePipe()); 211 service_provider.PassMessagePipe());
198 } 212 }
213
214 swapout_event_monitor_timeout_.reset(new TimeoutMonitor(base::Bind(
215 &RenderFrameHostImpl::OnSwappedOut, weak_ptr_factory_.GetWeakPtr())));
199 } 216 }
200 217
201 RenderFrameHostImpl::~RenderFrameHostImpl() { 218 RenderFrameHostImpl::~RenderFrameHostImpl() {
202 GetProcess()->RemoveRoute(routing_id_); 219 GetProcess()->RemoveRoute(routing_id_);
203 g_routing_id_frame_map.Get().erase( 220 g_routing_id_frame_map.Get().erase(
204 RenderFrameHostID(GetProcess()->GetID(), routing_id_)); 221 RenderFrameHostID(GetProcess()->GetID(), routing_id_));
205 222
206 if (delegate_) 223 if (delegate_)
207 delegate_->RenderFrameDeleted(this); 224 delegate_->RenderFrameDeleted(this);
208 225
209 FrameAccessibility::GetInstance()->OnRenderFrameHostDestroyed(this); 226 FrameAccessibility::GetInstance()->OnRenderFrameHostDestroyed(this);
210 227
228 // If this was swapped out, it already decremented the active frame count of
229 // the SiteInstance it belongs to.
230 if (IsRFHStateActive(rfh_state_))
231 GetSiteInstance()->decrement_active_frame_count();
232
211 // Notify the FrameTree that this RFH is going away, allowing it to shut down 233 // Notify the FrameTree that this RFH is going away, allowing it to shut down
212 // the corresponding RenderViewHost if it is no longer needed. 234 // the corresponding RenderViewHost if it is no longer needed.
213 frame_tree_->UnregisterRenderFrameHost(this); 235 frame_tree_->UnregisterRenderFrameHost(this);
214 } 236 }
215 237
216 int RenderFrameHostImpl::GetRoutingID() { 238 int RenderFrameHostImpl::GetRoutingID() {
217 return routing_id_; 239 return routing_id_;
218 } 240 }
219 241
220 SiteInstance* RenderFrameHostImpl::GetSiteInstance() { 242 SiteInstanceImpl* RenderFrameHostImpl::GetSiteInstance() {
221 return render_view_host_->GetSiteInstance(); 243 return render_view_host_->GetSiteInstance();
222 } 244 }
223 245
224 RenderProcessHost* RenderFrameHostImpl::GetProcess() { 246 RenderProcessHost* RenderFrameHostImpl::GetProcess() {
225 // TODO(nasko): This should return its own process, once we have working 247 // TODO(nasko): This should return its own process, once we have working
226 // cross-process navigation for subframes. 248 // cross-process navigation for subframes.
227 return render_view_host_->GetProcess(); 249 return render_view_host_->GetProcess();
228 } 250 }
229 251
230 RenderFrameHost* RenderFrameHostImpl::GetParent() { 252 RenderFrameHost* RenderFrameHostImpl::GetParent() {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 315
294 bool RenderFrameHostImpl::Send(IPC::Message* message) { 316 bool RenderFrameHostImpl::Send(IPC::Message* message) {
295 if (IPC_MESSAGE_ID_CLASS(message->type()) == InputMsgStart) { 317 if (IPC_MESSAGE_ID_CLASS(message->type()) == InputMsgStart) {
296 return render_view_host_->input_router()->SendInput( 318 return render_view_host_->input_router()->SendInput(
297 make_scoped_ptr(message)); 319 make_scoped_ptr(message));
298 } 320 }
299 321
300 // Route IPCs through the RenderFrameProxyHost when in swapped out state. 322 // Route IPCs through the RenderFrameProxyHost when in swapped out state.
301 // Note: For subframes in --site-per-process mode, we don't use swapped out 323 // Note: For subframes in --site-per-process mode, we don't use swapped out
302 // RenderFrameHosts. 324 // RenderFrameHosts.
303 if (frame_tree_node_->IsMainFrame() && render_view_host_->IsSwappedOut()) { 325 if (frame_tree_node_->IsMainFrame() && is_swapped_out()) {
304 DCHECK(render_frame_proxy_host_); 326 DCHECK(render_frame_proxy_host_);
305 return render_frame_proxy_host_->Send(message); 327 return render_frame_proxy_host_->Send(message);
306 } 328 }
307 329
308 return GetProcess()->Send(message); 330 return GetProcess()->Send(message);
309 } 331 }
310 332
311 bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) { 333 bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) {
312 // Filter out most IPC messages if this renderer is swapped out. 334 // Filter out most IPC messages if this frame is swapped out.
313 // We still want to handle certain ACKs to keep our state consistent. 335 // We still want to handle certain ACKs to keep our state consistent.
314 // TODO(nasko): Only check RenderViewHost state, as this object's own state 336 if (is_swapped_out()) {
315 // isn't yet properly updated. Transition this check once the swapped out
316 // state is correct in RenderFrameHost itself.
317 if (render_view_host_->IsSwappedOut()) {
318 if (!SwappedOutMessages::CanHandleWhileSwappedOut(msg)) { 337 if (!SwappedOutMessages::CanHandleWhileSwappedOut(msg)) {
319 // If this is a synchronous message and we decided not to handle it, 338 // If this is a synchronous message and we decided not to handle it,
320 // we must send an error reply, or else the renderer will be stuck 339 // we must send an error reply, or else the renderer will be stuck
321 // and won't respond to future requests. 340 // and won't respond to future requests.
322 if (msg.is_sync()) { 341 if (msg.is_sync()) {
323 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); 342 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg);
324 reply->set_reply_error(); 343 reply->set_reply_error();
325 Send(reply); 344 Send(reply);
326 } 345 }
327 // Don't continue looking for someone to handle it. 346 // Don't continue looking for someone to handle it.
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 return; 681 return;
663 TRACE_EVENT1("navigation", "RenderFrameHostImpl::OnDidCommitProvisionalLoad", 682 TRACE_EVENT1("navigation", "RenderFrameHostImpl::OnDidCommitProvisionalLoad",
664 "url", validated_params.url.possibly_invalid_spec()); 683 "url", validated_params.url.possibly_invalid_spec());
665 684
666 // If we're waiting for a cross-site beforeunload ack from this renderer and 685 // If we're waiting for a cross-site beforeunload ack from this renderer and
667 // we receive a Navigate message from the main frame, then the renderer was 686 // we receive a Navigate message from the main frame, then the renderer was
668 // navigating already and sent it before hearing the FrameMsg_Stop message. 687 // navigating already and sent it before hearing the FrameMsg_Stop message.
669 // We do not want to cancel the pending navigation in this case, since the 688 // We do not want to cancel the pending navigation in this case, since the
670 // old page will soon be stopped. Instead, treat this as a beforeunload ack 689 // old page will soon be stopped. Instead, treat this as a beforeunload ack
671 // to allow the pending navigation to continue. 690 // to allow the pending navigation to continue.
672 if (render_view_host_->is_waiting_for_beforeunload_ack_ && 691 if (is_waiting_for_beforeunload_ack_ &&
673 render_view_host_->unload_ack_is_for_cross_site_transition_ && 692 unload_ack_is_for_cross_site_transition_ &&
674 ui::PageTransitionIsMainFrame(validated_params.transition)) { 693 ui::PageTransitionIsMainFrame(validated_params.transition)) {
675 OnBeforeUnloadACK(true, send_before_unload_start_time_, 694 OnBeforeUnloadACK(true, send_before_unload_start_time_,
676 base::TimeTicks::Now()); 695 base::TimeTicks::Now());
677 return; 696 return;
678 } 697 }
679 698
680 // If we're waiting for an unload ack from this renderer and we receive a 699 // If we're waiting for an unload ack from this renderer and we receive a
681 // Navigate message, then the renderer was navigating before it received the 700 // Navigate message, then the renderer was navigating before it received the
682 // unload request. It will either respond to the unload request soon or our 701 // unload request. It will either respond to the unload request soon or our
683 // timer will expire. Either way, we should ignore this message, because we 702 // timer will expire. Either way, we should ignore this message, because we
684 // have already committed to closing this renderer. 703 // have already committed to closing this renderer.
685 if (render_view_host_->IsWaitingForUnloadACK()) 704 if (IsWaitingForUnloadACK())
686 return; 705 return;
687 706
688 RenderProcessHost* process = GetProcess(); 707 RenderProcessHost* process = GetProcess();
689 708
690 // Attempts to commit certain off-limits URL should be caught more strictly 709 // Attempts to commit certain off-limits URL should be caught more strictly
691 // than our FilterURL checks below. If a renderer violates this policy, it 710 // than our FilterURL checks below. If a renderer violates this policy, it
692 // should be killed. 711 // should be killed.
693 if (!CanCommitURL(validated_params.url)) { 712 if (!CanCommitURL(validated_params.url)) {
694 VLOG(1) << "Blocked URL " << validated_params.url.spec(); 713 VLOG(1) << "Blocked URL " << validated_params.url.spec();
695 validated_params.url = GURL(url::kAboutBlankURL); 714 validated_params.url = GURL(url::kAboutBlankURL);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 delegate_->DidDeferAfterResponseStarted(transition_data); 776 delegate_->DidDeferAfterResponseStarted(transition_data);
758 } 777 }
759 778
760 void RenderFrameHostImpl::SwapOut(RenderFrameProxyHost* proxy) { 779 void RenderFrameHostImpl::SwapOut(RenderFrameProxyHost* proxy) {
761 // The end of this event is in OnSwapOutACK when the RenderFrame has completed 780 // The end of this event is in OnSwapOutACK when the RenderFrame has completed
762 // the operation and sends back an IPC message. 781 // the operation and sends back an IPC message.
763 // The trace event may not end properly if the ACK times out. We expect this 782 // The trace event may not end properly if the ACK times out. We expect this
764 // to be fixed when RenderViewHostImpl::OnSwapOut moves to RenderFrameHost. 783 // to be fixed when RenderViewHostImpl::OnSwapOut moves to RenderFrameHost.
765 TRACE_EVENT_ASYNC_BEGIN0("navigation", "RenderFrameHostImpl::SwapOut", this); 784 TRACE_EVENT_ASYNC_BEGIN0("navigation", "RenderFrameHostImpl::SwapOut", this);
766 785
767 // TODO(creis): Move swapped out state to RFH. Until then, only update it 786 // If this RenderFrameHost is not in the default state, it must have already
768 // when swapping out the main frame. 787 // gone through this, therefore just return.
769 if (!GetParent()) { 788 if (rfh_state_ != RenderFrameHostImpl::STATE_DEFAULT)
770 // If this RenderViewHost is not in the default state, it must have already 789 return;
771 // gone through this, therefore just return.
772 if (render_view_host_->rvh_state_ != RenderViewHostImpl::STATE_DEFAULT)
773 return;
774 790
775 render_view_host_->SetState( 791 SetState(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT);
776 RenderViewHostImpl::STATE_PENDING_SWAP_OUT); 792 swapout_event_monitor_timeout_->Start(
777 render_view_host_->unload_event_monitor_timeout_->Start( 793 base::TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS));
778 base::TimeDelta::FromMilliseconds(
779 RenderViewHostImpl::kUnloadTimeoutMS));
780 }
781 794
782 set_render_frame_proxy_host(proxy); 795 set_render_frame_proxy_host(proxy);
783 796
784 if (IsRenderFrameLive()) 797 if (IsRenderFrameLive())
785 Send(new FrameMsg_SwapOut(routing_id_, proxy->GetRoutingID())); 798 Send(new FrameMsg_SwapOut(routing_id_, proxy->GetRoutingID()));
786 799
787 if (!GetParent()) 800 if (!GetParent())
788 delegate_->SwappedOut(this); 801 delegate_->SwappedOut(this);
789 else
790 set_swapped_out(true);
791 } 802 }
792 803
793 void RenderFrameHostImpl::OnBeforeUnloadACK( 804 void RenderFrameHostImpl::OnBeforeUnloadACK(
794 bool proceed, 805 bool proceed,
795 const base::TimeTicks& renderer_before_unload_start_time, 806 const base::TimeTicks& renderer_before_unload_start_time,
796 const base::TimeTicks& renderer_before_unload_end_time) { 807 const base::TimeTicks& renderer_before_unload_end_time) {
797 TRACE_EVENT_ASYNC_END0( 808 TRACE_EVENT_ASYNC_END0(
798 "navigation", "RenderFrameHostImpl::BeforeUnload", this); 809 "navigation", "RenderFrameHostImpl::BeforeUnload", this);
799 // TODO(creis): Support properly beforeunload on subframes. For now just 810 // TODO(creis): Support beforeunload on subframes. For now just pretend that
800 // pretend that the handler ran and allowed the navigation to proceed. 811 // the handler ran and allowed the navigation to proceed.
801 if (GetParent()) { 812 if (GetParent()) {
802 render_view_host_->is_waiting_for_beforeunload_ack_ = false; 813 is_waiting_for_beforeunload_ack_ = false;
803 frame_tree_node_->render_manager()->OnBeforeUnloadACK( 814 frame_tree_node_->render_manager()->OnBeforeUnloadACK(
804 render_view_host_->unload_ack_is_for_cross_site_transition_, proceed, 815 unload_ack_is_for_cross_site_transition_, proceed,
805 renderer_before_unload_end_time); 816 renderer_before_unload_end_time);
806 return; 817 return;
807 } 818 }
808 819
809 render_view_host_->decrement_in_flight_event_count(); 820 render_view_host_->decrement_in_flight_event_count();
810 render_view_host_->StopHangMonitorTimeout(); 821 render_view_host_->StopHangMonitorTimeout();
811 // If this renderer navigated while the beforeunload request was in flight, we 822 // If this renderer navigated while the beforeunload request was in flight, we
812 // may have cleared this state in OnDidCommitProvisionalLoad, in which case we 823 // may have cleared this state in OnDidCommitProvisionalLoad, in which case we
813 // can ignore this message. 824 // can ignore this message.
814 // However renderer might also be swapped out but we still want to proceed 825 // However renderer might also be swapped out but we still want to proceed
815 // with navigation, otherwise it would block future navigations. This can 826 // with navigation, otherwise it would block future navigations. This can
816 // happen when pending cross-site navigation is canceled by a second one just 827 // happen when pending cross-site navigation is canceled by a second one just
817 // before OnDidCommitProvisionalLoad while current RVH is waiting for commit 828 // before OnDidCommitProvisionalLoad while current RVH is waiting for commit
818 // but second navigation is started from the beginning. 829 // but second navigation is started from the beginning.
819 if (!render_view_host_->is_waiting_for_beforeunload_ack_) { 830 if (!is_waiting_for_beforeunload_ack_) {
820 return; 831 return;
821 } 832 }
822 833
823 render_view_host_->is_waiting_for_beforeunload_ack_ = false; 834 is_waiting_for_beforeunload_ack_ = false;
824 835
825 base::TimeTicks before_unload_end_time; 836 base::TimeTicks before_unload_end_time;
826 if (!send_before_unload_start_time_.is_null() && 837 if (!send_before_unload_start_time_.is_null() &&
827 !renderer_before_unload_start_time.is_null() && 838 !renderer_before_unload_start_time.is_null() &&
828 !renderer_before_unload_end_time.is_null()) { 839 !renderer_before_unload_end_time.is_null()) {
829 // When passing TimeTicks across process boundaries, we need to compensate 840 // When passing TimeTicks across process boundaries, we need to compensate
830 // for any skew between the processes. Here we are converting the 841 // for any skew between the processes. Here we are converting the
831 // renderer's notion of before_unload_end_time to TimeTicks in the browser 842 // renderer's notion of before_unload_end_time to TimeTicks in the browser
832 // process. See comments in inter_process_time_ticks_converter.h for more. 843 // process. See comments in inter_process_time_ticks_converter.h for more.
833 InterProcessTimeTicksConverter converter( 844 InterProcessTimeTicksConverter converter(
(...skipping 17 matching lines...) Expand all
851 } else { 862 } else {
852 UMA_HISTOGRAM_TIMES( 863 UMA_HISTOGRAM_TIMES(
853 "InterProcessTimeTicks.BrowserAhead_RendererToBrowser", -skew); 864 "InterProcessTimeTicks.BrowserAhead_RendererToBrowser", -skew);
854 } 865 }
855 } 866 }
856 UMA_HISTOGRAM_BOOLEAN( 867 UMA_HISTOGRAM_BOOLEAN(
857 "InterProcessTimeTicks.IsSkewAdditive_RendererToBrowser", 868 "InterProcessTimeTicks.IsSkewAdditive_RendererToBrowser",
858 is_skew_additive); 869 is_skew_additive);
859 } 870 }
860 frame_tree_node_->render_manager()->OnBeforeUnloadACK( 871 frame_tree_node_->render_manager()->OnBeforeUnloadACK(
861 render_view_host_->unload_ack_is_for_cross_site_transition_, proceed, 872 unload_ack_is_for_cross_site_transition_, proceed,
862 before_unload_end_time); 873 before_unload_end_time);
863 874
864 // If canceled, notify the delegate to cancel its pending navigation entry. 875 // If canceled, notify the delegate to cancel its pending navigation entry.
865 if (!proceed) 876 if (!proceed)
866 render_view_host_->GetDelegate()->DidCancelLoading(); 877 render_view_host_->GetDelegate()->DidCancelLoading();
867 } 878 }
868 879
869 void RenderFrameHostImpl::OnSwapOutACK() { 880 bool RenderFrameHostImpl::IsWaitingForUnloadACK() const {
870 OnSwappedOut(false); 881 return render_view_host_->is_waiting_for_close_ack_ ||
871 TRACE_EVENT_ASYNC_END0("navigation", "RenderFrameHostImpl::SwapOut", this); 882 rfh_state_ == STATE_PENDING_SHUTDOWN ||
883 rfh_state_ == STATE_PENDING_SWAP_OUT;
872 } 884 }
873 885
874 void RenderFrameHostImpl::OnSwappedOut(bool timed_out) { 886 void RenderFrameHostImpl::OnSwapOutACK() {
875 // For now, we only need to update the RVH state machine for top-level swaps. 887 OnSwappedOut();
876 if (!GetParent()) 888 }
877 render_view_host_->OnSwappedOut(timed_out); 889
890 void RenderFrameHostImpl::OnSwappedOut() {
891 // Ignore spurious swap out ack.
892 if (rfh_state_ != STATE_PENDING_SWAP_OUT &&
893 rfh_state_ != STATE_PENDING_SHUTDOWN)
894 return;
895
896 TRACE_EVENT_ASYNC_END0("navigation", "RenderFrameHostImpl::SwapOut", this);
897 swapout_event_monitor_timeout_->Stop();
898
899 switch (rfh_state_) {
900 case STATE_PENDING_SWAP_OUT:
901 SetState(STATE_SWAPPED_OUT);
902 break;
903 case STATE_PENDING_SHUTDOWN:
904 DCHECK(!pending_shutdown_on_swap_out_.is_null());
905 pending_shutdown_on_swap_out_.Run();
906 break;
907 default:
908 NOTREACHED();
909 }
878 } 910 }
879 911
880 void RenderFrameHostImpl::OnContextMenu(const ContextMenuParams& params) { 912 void RenderFrameHostImpl::OnContextMenu(const ContextMenuParams& params) {
881 // Validate the URLs in |params|. If the renderer can't request the URLs 913 // Validate the URLs in |params|. If the renderer can't request the URLs
882 // directly, don't show them in the context menu. 914 // directly, don't show them in the context menu.
883 ContextMenuParams validated_params(params); 915 ContextMenuParams validated_params(params);
884 RenderProcessHost* process = GetProcess(); 916 RenderProcessHost* process = GetProcess();
885 917
886 // We don't validate |unfiltered_link_url| so that this field can be used 918 // We don't validate |unfiltered_link_url| so that this field can be used
887 // when users want to copy the original link URL. 919 // when users want to copy the original link URL.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 render_view_host_->StopHangMonitorTimeout(); 956 render_view_host_->StopHangMonitorTimeout();
925 delegate_->RunJavaScriptMessage(this, message, default_prompt, 957 delegate_->RunJavaScriptMessage(this, message, default_prompt,
926 frame_url, type, reply_msg); 958 frame_url, type, reply_msg);
927 } 959 }
928 960
929 void RenderFrameHostImpl::OnRunBeforeUnloadConfirm( 961 void RenderFrameHostImpl::OnRunBeforeUnloadConfirm(
930 const GURL& frame_url, 962 const GURL& frame_url,
931 const base::string16& message, 963 const base::string16& message,
932 bool is_reload, 964 bool is_reload,
933 IPC::Message* reply_msg) { 965 IPC::Message* reply_msg) {
934 // While a JS before unload dialog is showing, tabs in the same process 966 // While a JS beforeunload dialog is showing, tabs in the same process
935 // shouldn't process input events. 967 // shouldn't process input events.
936 GetProcess()->SetIgnoreInputEvents(true); 968 GetProcess()->SetIgnoreInputEvents(true);
937 render_view_host_->StopHangMonitorTimeout(); 969 render_view_host_->StopHangMonitorTimeout();
938 delegate_->RunBeforeUnloadConfirm(this, message, is_reload, reply_msg); 970 delegate_->RunBeforeUnloadConfirm(this, message, is_reload, reply_msg);
939 } 971 }
940 972
941 void RenderFrameHostImpl::OnRequestPlatformNotificationPermission( 973 void RenderFrameHostImpl::OnRequestPlatformNotificationPermission(
942 const GURL& origin, int request_id) { 974 const GURL& origin, int request_id) {
943 base::Callback<void(blink::WebNotificationPermission)> done_callback = 975 base::Callback<void(blink::WebNotificationPermission)> done_callback =
944 base::Bind( 976 base::Bind(
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 frame_tree_node()->render_manager()->OnBeginNavigation(params); 1059 frame_tree_node()->render_manager()->OnBeginNavigation(params);
1028 } 1060 }
1029 1061
1030 void RenderFrameHostImpl::OnAccessibilityEvents( 1062 void RenderFrameHostImpl::OnAccessibilityEvents(
1031 const std::vector<AccessibilityHostMsg_EventParams>& params) { 1063 const std::vector<AccessibilityHostMsg_EventParams>& params) {
1032 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( 1064 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>(
1033 render_view_host_->GetView()); 1065 render_view_host_->GetView());
1034 1066
1035 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); 1067 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode();
1036 if ((accessibility_mode != AccessibilityModeOff) && view && 1068 if ((accessibility_mode != AccessibilityModeOff) && view &&
1037 RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) { 1069 RenderFrameHostImpl::IsRFHStateActive(rfh_state())) {
1038 if (accessibility_mode & AccessibilityModeFlagPlatform) { 1070 if (accessibility_mode & AccessibilityModeFlagPlatform) {
1039 GetOrCreateBrowserAccessibilityManager(); 1071 GetOrCreateBrowserAccessibilityManager();
1040 if (browser_accessibility_manager_) 1072 if (browser_accessibility_manager_)
1041 browser_accessibility_manager_->OnAccessibilityEvents(params); 1073 browser_accessibility_manager_->OnAccessibilityEvents(params);
1042 } 1074 }
1043 1075
1044 if (browser_accessibility_manager_) { 1076 if (browser_accessibility_manager_) {
1045 // Get the frame routing ids from out-of-process iframes and 1077 // Get the frame routing ids from out-of-process iframes and
1046 // browser plugin instance ids from guests and update the mappings in 1078 // browser plugin instance ids from guests and update the mappings in
1047 // FrameAccessibility. 1079 // FrameAccessibility.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 << ax_tree_for_testing_->error(); 1130 << ax_tree_for_testing_->error();
1099 } 1131 }
1100 accessibility_testing_callback_.Run(param.event_type, param.id); 1132 accessibility_testing_callback_.Run(param.event_type, param.id);
1101 } 1133 }
1102 } 1134 }
1103 1135
1104 void RenderFrameHostImpl::OnAccessibilityLocationChanges( 1136 void RenderFrameHostImpl::OnAccessibilityLocationChanges(
1105 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { 1137 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) {
1106 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( 1138 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>(
1107 render_view_host_->GetView()); 1139 render_view_host_->GetView());
1108 if (view && 1140 if (view && RenderFrameHostImpl::IsRFHStateActive(rfh_state())) {
1109 RenderViewHostImpl::IsRVHStateActive(render_view_host_->rvh_state())) {
1110 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode(); 1141 AccessibilityMode accessibility_mode = delegate_->GetAccessibilityMode();
1111 if (accessibility_mode & AccessibilityModeFlagPlatform) { 1142 if (accessibility_mode & AccessibilityModeFlagPlatform) {
1112 if (!browser_accessibility_manager_) { 1143 if (!browser_accessibility_manager_) {
1113 browser_accessibility_manager_.reset( 1144 browser_accessibility_manager_.reset(
1114 view->CreateBrowserAccessibilityManager(this)); 1145 view->CreateBrowserAccessibilityManager(this));
1115 } 1146 }
1116 if (browser_accessibility_manager_) 1147 if (browser_accessibility_manager_)
1117 browser_accessibility_manager_->OnLocationChanges(params); 1148 browser_accessibility_manager_->OnLocationChanges(params);
1118 } 1149 }
1119 // TODO(aboxhall): send location change events to web contents observers too 1150 // TODO(aboxhall): send location change events to web contents observers too
(...skipping 18 matching lines...) Expand all
1138 } 1169 }
1139 1170
1140 void RenderFrameHostImpl::OnHidePopup() { 1171 void RenderFrameHostImpl::OnHidePopup() {
1141 RenderViewHostDelegateView* view = 1172 RenderViewHostDelegateView* view =
1142 render_view_host_->delegate_->GetDelegateView(); 1173 render_view_host_->delegate_->GetDelegateView();
1143 if (view) 1174 if (view)
1144 view->HidePopupMenu(); 1175 view->HidePopupMenu();
1145 } 1176 }
1146 #endif 1177 #endif
1147 1178
1179 void RenderFrameHostImpl::SetState(RenderFrameHostImplState rfh_state) {
1180 // We update the number of RenderFrameHosts in a SiteInstance when the swapped
1181 // out status of a RenderFrameHost gets flipped to/from active.
1182 if (!IsRFHStateActive(rfh_state_) && IsRFHStateActive(rfh_state))
1183 GetSiteInstance()->increment_active_frame_count();
1184 else if (IsRFHStateActive(rfh_state_) && !IsRFHStateActive(rfh_state))
1185 GetSiteInstance()->decrement_active_frame_count();
1186
1187 // The active and swapped out state of the RVH is determined by its main
1188 // frame, since subframes should have their own widgets.
1189 if (frame_tree_node_->IsMainFrame()) {
1190 render_view_host_->set_is_active(IsRFHStateActive(rfh_state));
1191 render_view_host_->set_is_swapped_out(rfh_state == STATE_SWAPPED_OUT);
1192 }
1193
1194 // Whenever we change the RFH state to and from active or swapped out state,
1195 // we should not be waiting for beforeunload or close acks. We clear them
1196 // here to be safe, since they can cause navigations to be ignored in
1197 // OnDidCommitProvisionalLoad.
1198 // TODO(creis): Move is_waiting_for_beforeunload_ack_ into the state machine.
1199 if (rfh_state == STATE_DEFAULT ||
1200 rfh_state == STATE_SWAPPED_OUT ||
1201 rfh_state_ == STATE_DEFAULT ||
1202 rfh_state_ == STATE_SWAPPED_OUT) {
1203 is_waiting_for_beforeunload_ack_ = false;
1204 render_view_host_->is_waiting_for_close_ack_ = false;
1205 }
1206 rfh_state_ = rfh_state;
1207 }
1208
1148 void RenderFrameHostImpl::SetPendingShutdown(const base::Closure& on_swap_out) { 1209 void RenderFrameHostImpl::SetPendingShutdown(const base::Closure& on_swap_out) {
1149 render_view_host_->SetPendingShutdown(on_swap_out); 1210 pending_shutdown_on_swap_out_ = on_swap_out;
1211 SetState(STATE_PENDING_SHUTDOWN);
1150 } 1212 }
1151 1213
1152 bool RenderFrameHostImpl::CanCommitURL(const GURL& url) { 1214 bool RenderFrameHostImpl::CanCommitURL(const GURL& url) {
1153 // TODO(creis): We should also check for WebUI pages here. Also, when the 1215 // TODO(creis): We should also check for WebUI pages here. Also, when the
1154 // out-of-process iframes implementation is ready, we should check for 1216 // out-of-process iframes implementation is ready, we should check for
1155 // cross-site URLs that are not allowed to commit in this process. 1217 // cross-site URLs that are not allowed to commit in this process.
1156 1218
1157 // Give the client a chance to disallow URLs from committing. 1219 // Give the client a chance to disallow URLs from committing.
1158 return GetContentClient()->browser()->CanCommitURL(GetProcess(), url); 1220 return GetContentClient()->browser()->CanCommitURL(GetProcess(), url);
1159 } 1221 }
(...skipping 18 matching lines...) Expand all
1178 // request. 1240 // request.
1179 if (navigations_suspended_) { 1241 if (navigations_suspended_) {
1180 // Shouldn't be possible to have a second navigation while suspended, since 1242 // Shouldn't be possible to have a second navigation while suspended, since
1181 // navigations will only be suspended during a cross-site request. If a 1243 // navigations will only be suspended during a cross-site request. If a
1182 // second navigation occurs, RenderFrameHostManager will cancel this pending 1244 // second navigation occurs, RenderFrameHostManager will cancel this pending
1183 // RFH and create a new pending RFH. 1245 // RFH and create a new pending RFH.
1184 DCHECK(!suspended_nav_params_.get()); 1246 DCHECK(!suspended_nav_params_.get());
1185 suspended_nav_params_.reset(new FrameMsg_Navigate_Params(params)); 1247 suspended_nav_params_.reset(new FrameMsg_Navigate_Params(params));
1186 } else { 1248 } else {
1187 // Get back to a clean state, in case we start a new navigation without 1249 // Get back to a clean state, in case we start a new navigation without
1188 // completing a RVH swap or unload handler. 1250 // completing a RFH swap or unload handler.
1189 render_view_host_->SetState(RenderViewHostImpl::STATE_DEFAULT); 1251 SetState(RenderFrameHostImpl::STATE_DEFAULT);
1190 1252
1191 Send(new FrameMsg_Navigate(routing_id_, params)); 1253 Send(new FrameMsg_Navigate(routing_id_, params));
1192 } 1254 }
1193 1255
1194 // Force the throbber to start. We do this because Blink's "started 1256 // Force the throbber to start. We do this because Blink's "started
1195 // loading" message will be received asynchronously from the UI of the 1257 // loading" message will be received asynchronously from the UI of the
1196 // browser. But we want to keep the throbber in sync with what's happening 1258 // browser. But we want to keep the throbber in sync with what's happening
1197 // in the UI. For example, we want to start throbbing immediately when the 1259 // in the UI. For example, we want to start throbbing immediately when the
1198 // user naivgates even if the renderer is delayed. There is also an issue 1260 // user naivgates even if the renderer is delayed. There is also an issue
1199 // with the throbber starting because the WebUI (which controls whether the 1261 // with the throbber starting because the WebUI (which controls whether the
(...skipping 22 matching lines...) Expand all
1222 void RenderFrameHostImpl::Stop() { 1284 void RenderFrameHostImpl::Stop() {
1223 Send(new FrameMsg_Stop(routing_id_)); 1285 Send(new FrameMsg_Stop(routing_id_));
1224 } 1286 }
1225 1287
1226 void RenderFrameHostImpl::DispatchBeforeUnload(bool for_cross_site_transition) { 1288 void RenderFrameHostImpl::DispatchBeforeUnload(bool for_cross_site_transition) {
1227 TRACE_EVENT_ASYNC_BEGIN0( 1289 TRACE_EVENT_ASYNC_BEGIN0(
1228 "navigation", "RenderFrameHostImpl::BeforeUnload", this); 1290 "navigation", "RenderFrameHostImpl::BeforeUnload", this);
1229 // TODO(creis): Support subframes. 1291 // TODO(creis): Support subframes.
1230 if (GetParent() || !IsRenderFrameLive()) { 1292 if (GetParent() || !IsRenderFrameLive()) {
1231 // We don't have a live renderer, so just skip running beforeunload. 1293 // We don't have a live renderer, so just skip running beforeunload.
1232 render_view_host_->is_waiting_for_beforeunload_ack_ = true; 1294 is_waiting_for_beforeunload_ack_ = true;
1233 render_view_host_->unload_ack_is_for_cross_site_transition_ = 1295 unload_ack_is_for_cross_site_transition_ = for_cross_site_transition;
1234 for_cross_site_transition;
1235 base::TimeTicks now = base::TimeTicks::Now(); 1296 base::TimeTicks now = base::TimeTicks::Now();
1236 OnBeforeUnloadACK(true, now, now); 1297 OnBeforeUnloadACK(true, now, now);
1237 return; 1298 return;
1238 } 1299 }
1239 1300
1240 // This may be called more than once (if the user clicks the tab close button 1301 // This may be called more than once (if the user clicks the tab close button
1241 // several times, or if she clicks the tab close button then the browser close 1302 // several times, or if she clicks the tab close button then the browser close
1242 // button), and we only send the message once. 1303 // button), and we only send the message once.
1243 if (render_view_host_->is_waiting_for_beforeunload_ack_) { 1304 if (is_waiting_for_beforeunload_ack_) {
1244 // Some of our close messages could be for the tab, others for cross-site 1305 // Some of our close messages could be for the tab, others for cross-site
1245 // transitions. We always want to think it's for closing the tab if any 1306 // transitions. We always want to think it's for closing the tab if any
1246 // of the messages were, since otherwise it might be impossible to close 1307 // of the messages were, since otherwise it might be impossible to close
1247 // (if there was a cross-site "close" request pending when the user clicked 1308 // (if there was a cross-site "close" request pending when the user clicked
1248 // the close button). We want to keep the "for cross site" flag only if 1309 // the close button). We want to keep the "for cross site" flag only if
1249 // both the old and the new ones are also for cross site. 1310 // both the old and the new ones are also for cross site.
1250 render_view_host_->unload_ack_is_for_cross_site_transition_ = 1311 unload_ack_is_for_cross_site_transition_ =
1251 render_view_host_->unload_ack_is_for_cross_site_transition_ && 1312 unload_ack_is_for_cross_site_transition_ && for_cross_site_transition;
1252 for_cross_site_transition;
1253 } else { 1313 } else {
1254 // Start the hang monitor in case the renderer hangs in the beforeunload 1314 // Start the hang monitor in case the renderer hangs in the beforeunload
1255 // handler. 1315 // handler.
1256 render_view_host_->is_waiting_for_beforeunload_ack_ = true; 1316 is_waiting_for_beforeunload_ack_ = true;
1257 render_view_host_->unload_ack_is_for_cross_site_transition_ = 1317 unload_ack_is_for_cross_site_transition_ = for_cross_site_transition;
1258 for_cross_site_transition;
1259 // Increment the in-flight event count, to ensure that input events won't 1318 // Increment the in-flight event count, to ensure that input events won't
1260 // cancel the timeout timer. 1319 // cancel the timeout timer.
1261 render_view_host_->increment_in_flight_event_count(); 1320 render_view_host_->increment_in_flight_event_count();
1262 render_view_host_->StartHangMonitorTimeout( 1321 render_view_host_->StartHangMonitorTimeout(
1263 TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS)); 1322 TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS));
1264 send_before_unload_start_time_ = base::TimeTicks::Now(); 1323 send_before_unload_start_time_ = base::TimeTicks::Now();
1265 Send(new FrameMsg_BeforeUnload(routing_id_)); 1324 Send(new FrameMsg_BeforeUnload(routing_id_));
1266 } 1325 }
1267 } 1326 }
1268 1327
1269 void RenderFrameHostImpl::DisownOpener() { 1328 void RenderFrameHostImpl::DisownOpener() {
1270 Send(new FrameMsg_DisownOpener(GetRoutingID())); 1329 Send(new FrameMsg_DisownOpener(GetRoutingID()));
1271 } 1330 }
1272 1331
1273 void RenderFrameHostImpl::ExtendSelectionAndDelete(size_t before, 1332 void RenderFrameHostImpl::ExtendSelectionAndDelete(size_t before,
1274 size_t after) { 1333 size_t after) {
1275 Send(new InputMsg_ExtendSelectionAndDelete(routing_id_, before, after)); 1334 Send(new InputMsg_ExtendSelectionAndDelete(routing_id_, before, after));
1276 } 1335 }
1277 1336
1278 void RenderFrameHostImpl::JavaScriptDialogClosed( 1337 void RenderFrameHostImpl::JavaScriptDialogClosed(
1279 IPC::Message* reply_msg, 1338 IPC::Message* reply_msg,
1280 bool success, 1339 bool success,
1281 const base::string16& user_input, 1340 const base::string16& user_input,
1282 bool dialog_was_suppressed) { 1341 bool dialog_was_suppressed) {
1283 GetProcess()->SetIgnoreInputEvents(false); 1342 GetProcess()->SetIgnoreInputEvents(false);
1284 bool is_waiting = render_view_host_->is_waiting_for_beforeunload_ack() || 1343 bool is_waiting = is_waiting_for_beforeunload_ack_ || IsWaitingForUnloadACK();
1285 render_view_host_->IsWaitingForUnloadACK();
1286 1344
1287 // If we are executing as part of (before)unload event handling, we don't 1345 // If we are executing as part of (before)unload event handling, we don't
1288 // want to use the regular hung_renderer_delay_ms_ if the user has agreed to 1346 // want to use the regular hung_renderer_delay_ms_ if the user has agreed to
1289 // leave the current page. In this case, use the regular timeout value used 1347 // leave the current page. In this case, use the regular timeout value used
1290 // during the (before)unload handling. 1348 // during the (before)unload handling.
1291 if (is_waiting) { 1349 if (is_waiting) {
1292 render_view_host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds( 1350 render_view_host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(
1293 success ? RenderViewHostImpl::kUnloadTimeoutMS 1351 success ? RenderViewHostImpl::kUnloadTimeoutMS
1294 : render_view_host_->hung_renderer_delay_ms_)); 1352 : render_view_host_->hung_renderer_delay_ms_));
1295 } 1353 }
1296 1354
1297 FrameHostMsg_RunJavaScriptMessage::WriteReplyParams(reply_msg, 1355 FrameHostMsg_RunJavaScriptMessage::WriteReplyParams(reply_msg,
1298 success, user_input); 1356 success, user_input);
1299 Send(reply_msg); 1357 Send(reply_msg);
1300 1358
1301 // If we are waiting for an unload or beforeunload ack and the user has 1359 // If we are waiting for an unload or beforeunload ack and the user has
1302 // suppressed messages, kill the tab immediately; a page that's spamming 1360 // suppressed messages, kill the tab immediately; a page that's spamming
1303 // alerts in onbeforeunload is presumably malicious, so there's no point in 1361 // alerts in onbeforeunload is presumably malicious, so there's no point in
1304 // continuing to run its script and dragging out the process. 1362 // continuing to run its script and dragging out the process.
1305 // This must be done after sending the reply since RenderView can't close 1363 // This must be done after sending the reply since RenderView can't close
1306 // correctly while waiting for a response. 1364 // correctly while waiting for a response.
1307 if (is_waiting && dialog_was_suppressed) 1365 if (is_waiting && dialog_was_suppressed)
1308 render_view_host_->delegate_->RendererUnresponsive( 1366 render_view_host_->delegate_->RendererUnresponsive(render_view_host_);
1309 render_view_host_,
1310 render_view_host_->is_waiting_for_beforeunload_ack(),
1311 render_view_host_->IsWaitingForUnloadACK());
1312 } 1367 }
1313 1368
1314 void RenderFrameHostImpl::NotificationClosed(int notification_id) { 1369 void RenderFrameHostImpl::NotificationClosed(int notification_id) {
1315 cancel_notification_callbacks_.erase(notification_id); 1370 cancel_notification_callbacks_.erase(notification_id);
1316 } 1371 }
1317 1372
1318 void RenderFrameHostImpl::PlatformNotificationPermissionRequestDone( 1373 void RenderFrameHostImpl::PlatformNotificationPermissionRequestDone(
1319 int request_id, blink::WebNotificationPermission permission) { 1374 int request_id, blink::WebNotificationPermission permission) {
1320 Send(new PlatformNotificationMsg_PermissionRequestComplete( 1375 Send(new PlatformNotificationMsg_PermissionRequestComplete(
1321 routing_id_, request_id, permission)); 1376 routing_id_, request_id, permission));
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1444 "RenderFrameHostImpl navigation suspended", this); 1499 "RenderFrameHostImpl navigation suspended", this);
1445 } else { 1500 } else {
1446 TRACE_EVENT_ASYNC_END0("navigation", 1501 TRACE_EVENT_ASYNC_END0("navigation",
1447 "RenderFrameHostImpl navigation suspended", this); 1502 "RenderFrameHostImpl navigation suspended", this);
1448 } 1503 }
1449 1504
1450 if (!suspend && suspended_nav_params_) { 1505 if (!suspend && suspended_nav_params_) {
1451 // There's navigation message params waiting to be sent. Now that we're not 1506 // There's navigation message params waiting to be sent. Now that we're not
1452 // suspended anymore, resume navigation by sending them. If we were swapped 1507 // suspended anymore, resume navigation by sending them. If we were swapped
1453 // out, we should also stop filtering out the IPC messages now. 1508 // out, we should also stop filtering out the IPC messages now.
1454 render_view_host_->SetState(RenderViewHostImpl::STATE_DEFAULT); 1509 SetState(RenderFrameHostImpl::STATE_DEFAULT);
1455 1510
1456 DCHECK(!proceed_time.is_null()); 1511 DCHECK(!proceed_time.is_null());
1457 suspended_nav_params_->browser_navigation_start = proceed_time; 1512 suspended_nav_params_->browser_navigation_start = proceed_time;
1458 Send(new FrameMsg_Navigate(routing_id_, *suspended_nav_params_)); 1513 Send(new FrameMsg_Navigate(routing_id_, *suspended_nav_params_));
1459 suspended_nav_params_.reset(); 1514 suspended_nav_params_.reset();
1460 } 1515 }
1461 } 1516 }
1462 1517
1463 void RenderFrameHostImpl::CancelSuspendedNavigations() { 1518 void RenderFrameHostImpl::CancelSuspendedNavigations() {
1464 // Clear any state if a pending navigation is canceled or preempted. 1519 // Clear any state if a pending navigation is canceled or preempted.
1465 if (suspended_nav_params_) 1520 if (suspended_nav_params_)
1466 suspended_nav_params_.reset(); 1521 suspended_nav_params_.reset();
1467 1522
1468 TRACE_EVENT_ASYNC_END0("navigation", 1523 TRACE_EVENT_ASYNC_END0("navigation",
1469 "RenderFrameHostImpl navigation suspended", this); 1524 "RenderFrameHostImpl navigation suspended", this);
1470 navigations_suspended_ = false; 1525 navigations_suspended_ = false;
1471 } 1526 }
1472 1527
1473 } // namespace content 1528 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.h ('k') | content/browser/frame_host/render_frame_host_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698