OLD | NEW |
---|---|
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 17 matching lines...) Expand all Loading... | |
28 #include "content/browser/cross_site_request_manager.h" | 28 #include "content/browser/cross_site_request_manager.h" |
29 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 29 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
30 #include "content/browser/frame_host/frame_tree.h" | 30 #include "content/browser/frame_host/frame_tree.h" |
31 #include "content/browser/gpu/compositor_util.h" | 31 #include "content/browser/gpu/compositor_util.h" |
32 #include "content/browser/gpu/gpu_data_manager_impl.h" | 32 #include "content/browser/gpu/gpu_data_manager_impl.h" |
33 #include "content/browser/gpu/gpu_process_host.h" | 33 #include "content/browser/gpu/gpu_process_host.h" |
34 #include "content/browser/gpu/gpu_surface_tracker.h" | 34 #include "content/browser/gpu/gpu_surface_tracker.h" |
35 #include "content/browser/host_zoom_map_impl.h" | 35 #include "content/browser/host_zoom_map_impl.h" |
36 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 36 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
37 #include "content/browser/renderer_host/dip_util.h" | 37 #include "content/browser/renderer_host/dip_util.h" |
38 #include "content/browser/renderer_host/input/timeout_monitor.h" | |
38 #include "content/browser/renderer_host/media/audio_renderer_host.h" | 39 #include "content/browser/renderer_host/media/audio_renderer_host.h" |
39 #include "content/browser/renderer_host/render_process_host_impl.h" | 40 #include "content/browser/renderer_host/render_process_host_impl.h" |
40 #include "content/browser/renderer_host/render_view_host_delegate.h" | 41 #include "content/browser/renderer_host/render_view_host_delegate.h" |
41 #include "content/common/accessibility_messages.h" | 42 #include "content/common/accessibility_messages.h" |
42 #include "content/common/browser_plugin/browser_plugin_messages.h" | 43 #include "content/common/browser_plugin/browser_plugin_messages.h" |
43 #include "content/common/content_switches_internal.h" | 44 #include "content/common/content_switches_internal.h" |
44 #include "content/common/desktop_notification_messages.h" | 45 #include "content/common/desktop_notification_messages.h" |
45 #include "content/common/drag_messages.h" | 46 #include "content/common/drag_messages.h" |
46 #include "content/common/input_messages.h" | 47 #include "content/common/input_messages.h" |
47 #include "content/common/inter_process_time_ticks_converter.h" | 48 #include "content/common/inter_process_time_ticks_converter.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 } | 144 } |
144 } | 145 } |
145 #endif | 146 #endif |
146 | 147 |
147 } // namespace | 148 } // namespace |
148 | 149 |
149 /////////////////////////////////////////////////////////////////////////////// | 150 /////////////////////////////////////////////////////////////////////////////// |
150 // RenderViewHost, public: | 151 // RenderViewHost, public: |
151 | 152 |
152 // static | 153 // static |
154 bool RenderViewHostImpl::IsRVHStateActive(RenderViewHostImplState rvh_state) { | |
155 if (rvh_state == STATE_LIVE || | |
156 rvh_state == STATE_WAITING_FOR_UNLOAD_ACK || | |
157 rvh_state == STATE_WAITING_FOR_COMMIT || | |
158 rvh_state == STATE_WAITING_FOR_CLOSE) | |
159 return true; | |
160 return false; | |
161 } | |
162 | |
163 // static | |
153 RenderViewHost* RenderViewHost::FromID(int render_process_id, | 164 RenderViewHost* RenderViewHost::FromID(int render_process_id, |
154 int render_view_id) { | 165 int render_view_id) { |
155 return RenderViewHostImpl::FromID(render_process_id, render_view_id); | 166 return RenderViewHostImpl::FromID(render_process_id, render_view_id); |
156 } | 167 } |
157 | 168 |
158 // static | 169 // static |
159 RenderViewHost* RenderViewHost::From(RenderWidgetHost* rwh) { | 170 RenderViewHost* RenderViewHost::From(RenderWidgetHost* rwh) { |
160 DCHECK(rwh->IsRenderView()); | 171 DCHECK(rwh->IsRenderView()); |
161 return static_cast<RenderViewHostImpl*>(RenderWidgetHostImpl::From(rwh)); | 172 return static_cast<RenderViewHostImpl*>(RenderWidgetHostImpl::From(rwh)); |
162 } | 173 } |
(...skipping 16 matching lines...) Expand all Loading... | |
179 RenderViewHostDelegate* delegate, | 190 RenderViewHostDelegate* delegate, |
180 RenderWidgetHostDelegate* widget_delegate, | 191 RenderWidgetHostDelegate* widget_delegate, |
181 int routing_id, | 192 int routing_id, |
182 int main_frame_routing_id, | 193 int main_frame_routing_id, |
183 bool swapped_out, | 194 bool swapped_out, |
184 bool hidden) | 195 bool hidden) |
185 : RenderWidgetHostImpl(widget_delegate, | 196 : RenderWidgetHostImpl(widget_delegate, |
186 instance->GetProcess(), | 197 instance->GetProcess(), |
187 routing_id, | 198 routing_id, |
188 hidden), | 199 hidden), |
200 frames_ref_count_(0), | |
189 delegate_(delegate), | 201 delegate_(delegate), |
190 instance_(static_cast<SiteInstanceImpl*>(instance)), | 202 instance_(static_cast<SiteInstanceImpl*>(instance)), |
191 waiting_for_drag_context_response_(false), | 203 waiting_for_drag_context_response_(false), |
192 enabled_bindings_(0), | 204 enabled_bindings_(0), |
193 navigations_suspended_(false), | 205 navigations_suspended_(false), |
194 has_accessed_initial_document_(false), | 206 has_accessed_initial_document_(false), |
195 is_swapped_out_(swapped_out), | |
196 main_frame_id_(-1), | 207 main_frame_id_(-1), |
197 main_frame_routing_id_(main_frame_routing_id), | 208 main_frame_routing_id_(main_frame_routing_id), |
198 run_modal_reply_msg_(NULL), | 209 run_modal_reply_msg_(NULL), |
199 run_modal_opener_id_(MSG_ROUTING_NONE), | 210 run_modal_opener_id_(MSG_ROUTING_NONE), |
200 is_waiting_for_beforeunload_ack_(false), | 211 is_waiting_for_beforeunload_ack_(false), |
201 is_waiting_for_unload_ack_(false), | |
202 has_timed_out_on_unload_(false), | |
203 unload_ack_is_for_cross_site_transition_(false), | 212 unload_ack_is_for_cross_site_transition_(false), |
204 are_javascript_messages_suppressed_(false), | 213 are_javascript_messages_suppressed_(false), |
205 sudden_termination_allowed_(false), | 214 sudden_termination_allowed_(false), |
206 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), | 215 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), |
207 virtual_keyboard_requested_(false) { | 216 virtual_keyboard_requested_(false), |
217 weak_factory_(this) { | |
208 DCHECK(instance_.get()); | 218 DCHECK(instance_.get()); |
209 CHECK(delegate_); // http://crbug.com/82827 | 219 CHECK(delegate_); // http://crbug.com/82827 |
210 | 220 |
211 GetProcess()->EnableSendQueue(); | 221 GetProcess()->EnableSendQueue(); |
212 | 222 |
213 if (!swapped_out) | 223 if (swapped_out) { |
224 rvh_state_ = STATE_SWAPPED_OUT; | |
225 } else { | |
226 rvh_state_ = STATE_LIVE; | |
214 instance_->increment_active_view_count(); | 227 instance_->increment_active_view_count(); |
228 } | |
215 | 229 |
216 if (ResourceDispatcherHostImpl::Get()) { | 230 if (ResourceDispatcherHostImpl::Get()) { |
217 BrowserThread::PostTask( | 231 BrowserThread::PostTask( |
218 BrowserThread::IO, FROM_HERE, | 232 BrowserThread::IO, FROM_HERE, |
219 base::Bind(&ResourceDispatcherHostImpl::OnRenderViewHostCreated, | 233 base::Bind(&ResourceDispatcherHostImpl::OnRenderViewHostCreated, |
220 base::Unretained(ResourceDispatcherHostImpl::Get()), | 234 base::Unretained(ResourceDispatcherHostImpl::Get()), |
221 GetProcess()->GetID(), GetRoutingID())); | 235 GetProcess()->GetID(), GetRoutingID())); |
222 } | 236 } |
223 | 237 |
224 #if defined(OS_ANDROID) | 238 #if defined(OS_ANDROID) |
225 media_player_manager_.reset(BrowserMediaPlayerManager::Create(this)); | 239 media_player_manager_.reset(BrowserMediaPlayerManager::Create(this)); |
226 #endif | 240 #endif |
241 | |
242 unload_event_monitor_timeout_.reset(new TimeoutMonitor(base::Bind( | |
243 &RenderViewHostImpl::OnSwappedOut, weak_factory_.GetWeakPtr(), true))); | |
227 } | 244 } |
228 | 245 |
229 RenderViewHostImpl::~RenderViewHostImpl() { | 246 RenderViewHostImpl::~RenderViewHostImpl() { |
230 if (ResourceDispatcherHostImpl::Get()) { | 247 if (ResourceDispatcherHostImpl::Get()) { |
231 BrowserThread::PostTask( | 248 BrowserThread::PostTask( |
232 BrowserThread::IO, FROM_HERE, | 249 BrowserThread::IO, FROM_HERE, |
233 base::Bind(&ResourceDispatcherHostImpl::OnRenderViewHostDeleted, | 250 base::Bind(&ResourceDispatcherHostImpl::OnRenderViewHostDeleted, |
234 base::Unretained(ResourceDispatcherHostImpl::Get()), | 251 base::Unretained(ResourceDispatcherHostImpl::Get()), |
235 GetProcess()->GetID(), GetRoutingID())); | 252 GetProcess()->GetID(), GetRoutingID())); |
236 } | 253 } |
237 | 254 |
238 delegate_->RenderViewDeleted(this); | 255 delegate_->RenderViewDeleted(this); |
239 | 256 |
240 // Be sure to clean up any leftover state from cross-site requests. | 257 // Be sure to clean up any leftover state from cross-site requests. |
241 CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest( | 258 CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest( |
242 GetProcess()->GetID(), GetRoutingID(), false); | 259 GetProcess()->GetID(), GetRoutingID(), false); |
243 | 260 |
244 // If this was swapped out, it already decremented the active view | 261 // If this was swapped out, it already decremented the active view |
245 // count of the SiteInstance it belongs to. | 262 // count of the SiteInstance it belongs to. |
246 if (!is_swapped_out_) | 263 if (IsRVHStateActive(rvh_state_)) |
247 instance_->decrement_active_view_count(); | 264 instance_->decrement_active_view_count(); |
248 } | 265 } |
249 | 266 |
250 RenderViewHostDelegate* RenderViewHostImpl::GetDelegate() const { | 267 RenderViewHostDelegate* RenderViewHostImpl::GetDelegate() const { |
251 return delegate_; | 268 return delegate_; |
252 } | 269 } |
253 | 270 |
254 SiteInstance* RenderViewHostImpl::GetSiteInstance() const { | 271 SiteInstance* RenderViewHostImpl::GetSiteInstance() const { |
255 return instance_.get(); | 272 return instance_.get(); |
256 } | 273 } |
(...skipping 30 matching lines...) Expand all Loading... | |
287 delegate_->GetRendererPrefs(GetProcess()->GetBrowserContext()); | 304 delegate_->GetRendererPrefs(GetProcess()->GetBrowserContext()); |
288 params.web_preferences = delegate_->GetWebkitPrefs(); | 305 params.web_preferences = delegate_->GetWebkitPrefs(); |
289 params.view_id = GetRoutingID(); | 306 params.view_id = GetRoutingID(); |
290 params.main_frame_routing_id = main_frame_routing_id_; | 307 params.main_frame_routing_id = main_frame_routing_id_; |
291 params.surface_id = surface_id(); | 308 params.surface_id = surface_id(); |
292 params.session_storage_namespace_id = | 309 params.session_storage_namespace_id = |
293 delegate_->GetSessionStorageNamespace(instance_)->id(); | 310 delegate_->GetSessionStorageNamespace(instance_)->id(); |
294 params.frame_name = frame_name; | 311 params.frame_name = frame_name; |
295 // Ensure the RenderView sets its opener correctly. | 312 // Ensure the RenderView sets its opener correctly. |
296 params.opener_route_id = opener_route_id; | 313 params.opener_route_id = opener_route_id; |
297 params.swapped_out = is_swapped_out_; | 314 params.swapped_out = !IsRVHStateActive(rvh_state_); |
298 params.hidden = is_hidden(); | 315 params.hidden = is_hidden(); |
299 params.next_page_id = next_page_id; | 316 params.next_page_id = next_page_id; |
300 GetWebScreenInfo(¶ms.screen_info); | 317 GetWebScreenInfo(¶ms.screen_info); |
301 params.accessibility_mode = accessibility_mode(); | 318 params.accessibility_mode = accessibility_mode(); |
302 params.allow_partial_swap = !GetProcess()->IsGuest(); | 319 params.allow_partial_swap = !GetProcess()->IsGuest(); |
303 | 320 |
304 Send(new ViewMsg_New(params)); | 321 Send(new ViewMsg_New(params)); |
305 | 322 |
306 // If it's enabled, tell the renderer to set up the Javascript bindings for | 323 // If it's enabled, tell the renderer to set up the Javascript bindings for |
307 // sending messages back to the browser. | 324 // sending messages back to the browser. |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
586 if (navigations_suspended_) { | 603 if (navigations_suspended_) { |
587 // Shouldn't be possible to have a second navigation while suspended, since | 604 // Shouldn't be possible to have a second navigation while suspended, since |
588 // navigations will only be suspended during a cross-site request. If a | 605 // navigations will only be suspended during a cross-site request. If a |
589 // second navigation occurs, WebContentsImpl will cancel this pending RVH | 606 // second navigation occurs, WebContentsImpl will cancel this pending RVH |
590 // create a new pending RVH. | 607 // create a new pending RVH. |
591 DCHECK(!suspended_nav_params_.get()); | 608 DCHECK(!suspended_nav_params_.get()); |
592 suspended_nav_params_.reset(new ViewMsg_Navigate_Params(params)); | 609 suspended_nav_params_.reset(new ViewMsg_Navigate_Params(params)); |
593 } else { | 610 } else { |
594 // Get back to a clean state, in case we start a new navigation without | 611 // Get back to a clean state, in case we start a new navigation without |
595 // completing a RVH swap or unload handler. | 612 // completing a RVH swap or unload handler. |
596 SetSwappedOut(false); | 613 SetState(STATE_LIVE); |
597 | 614 |
598 Send(new ViewMsg_Navigate(GetRoutingID(), params)); | 615 Send(new ViewMsg_Navigate(GetRoutingID(), params)); |
599 } | 616 } |
600 | 617 |
601 // Force the throbber to start. We do this because WebKit's "started | 618 // Force the throbber to start. We do this because WebKit's "started |
602 // loading" message will be received asynchronously from the UI of the | 619 // loading" message will be received asynchronously from the UI of the |
603 // browser. But we want to keep the throbber in sync with what's happening | 620 // browser. But we want to keep the throbber in sync with what's happening |
604 // in the UI. For example, we want to start throbbing immediately when the | 621 // in the UI. For example, we want to start throbbing immediately when the |
605 // user naivgates even if the renderer is delayed. There is also an issue | 622 // user naivgates even if the renderer is delayed. There is also an issue |
606 // with the throbber starting because the WebUI (which controls whether the | 623 // with the throbber starting because the WebUI (which controls whether the |
(...skipping 22 matching lines...) Expand all Loading... | |
629 bool suspend, | 646 bool suspend, |
630 const base::TimeTicks& proceed_time) { | 647 const base::TimeTicks& proceed_time) { |
631 // This should only be called to toggle the state. | 648 // This should only be called to toggle the state. |
632 DCHECK(navigations_suspended_ != suspend); | 649 DCHECK(navigations_suspended_ != suspend); |
633 | 650 |
634 navigations_suspended_ = suspend; | 651 navigations_suspended_ = suspend; |
635 if (!suspend && suspended_nav_params_) { | 652 if (!suspend && suspended_nav_params_) { |
636 // There's navigation message params waiting to be sent. Now that we're not | 653 // There's navigation message params waiting to be sent. Now that we're not |
637 // suspended anymore, resume navigation by sending them. If we were swapped | 654 // suspended anymore, resume navigation by sending them. If we were swapped |
638 // out, we should also stop filtering out the IPC messages now. | 655 // out, we should also stop filtering out the IPC messages now. |
639 SetSwappedOut(false); | 656 SetState(STATE_LIVE); |
640 | 657 |
641 DCHECK(!proceed_time.is_null()); | 658 DCHECK(!proceed_time.is_null()); |
642 suspended_nav_params_->browser_navigation_start = proceed_time; | 659 suspended_nav_params_->browser_navigation_start = proceed_time; |
643 Send(new ViewMsg_Navigate(GetRoutingID(), *suspended_nav_params_.get())); | 660 Send(new ViewMsg_Navigate(GetRoutingID(), *suspended_nav_params_.get())); |
644 suspended_nav_params_.reset(); | 661 suspended_nav_params_.reset(); |
645 } | 662 } |
646 } | 663 } |
647 | 664 |
648 void RenderViewHostImpl::CancelSuspendedNavigations() { | 665 void RenderViewHostImpl::CancelSuspendedNavigations() { |
649 // Clear any state if a pending navigation is canceled or pre-empted. | 666 // Clear any state if a pending navigation is canceled or pre-empted. |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
710 manager->OnCrossSiteResponse(this, global_request_id, is_transfer, | 727 manager->OnCrossSiteResponse(this, global_request_id, is_transfer, |
711 transfer_url_chain, referrer, page_transition, | 728 transfer_url_chain, referrer, page_transition, |
712 frame_id, should_replace_current_entry); | 729 frame_id, should_replace_current_entry); |
713 } | 730 } |
714 | 731 |
715 void RenderViewHostImpl::SuppressDialogsUntilSwapOut() { | 732 void RenderViewHostImpl::SuppressDialogsUntilSwapOut() { |
716 Send(new ViewMsg_SuppressDialogsUntilSwapOut(GetRoutingID())); | 733 Send(new ViewMsg_SuppressDialogsUntilSwapOut(GetRoutingID())); |
717 } | 734 } |
718 | 735 |
719 void RenderViewHostImpl::SwapOut() { | 736 void RenderViewHostImpl::SwapOut() { |
720 // This will be set back to false in OnSwapOutACK, just before we replace | 737 SetState(STATE_WAITING_FOR_UNLOAD_ACK); |
721 // this RVH with the pending RVH. | 738 unload_event_monitor_timeout_->Start( |
722 is_waiting_for_unload_ack_ = true; | 739 base::TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); |
723 // Start the hang monitor in case the renderer hangs in the unload handler. | |
724 // Increment the in-flight event count, to ensure that input events won't | |
725 // cancel the timeout timer. | |
726 increment_in_flight_event_count(); | |
727 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); | |
728 | 740 |
729 if (IsRenderViewLive()) { | 741 if (IsRenderViewLive()) { |
730 Send(new ViewMsg_SwapOut(GetRoutingID())); | 742 Send(new ViewMsg_SwapOut(GetRoutingID())); |
731 } else { | |
732 // This RenderViewHost doesn't have a live renderer, so just skip the unload | |
733 // event. | |
734 OnSwappedOut(true); | |
735 } | 743 } |
744 delegate_->SwappedOut(this); | |
736 } | 745 } |
737 | 746 |
738 void RenderViewHostImpl::OnSwapOutACK() { | 747 void RenderViewHostImpl::OnSwapOutACK() { |
739 OnSwappedOut(false); | 748 OnSwappedOut(false); |
740 } | 749 } |
741 | 750 |
742 void RenderViewHostImpl::OnSwappedOut(bool timed_out) { | 751 void RenderViewHostImpl::OnSwappedOut(bool timed_out) { |
743 // Stop the hang monitor now that the unload handler has finished. | 752 // Ignore spurious swap out ack. |
744 decrement_in_flight_event_count(); | 753 if (!IsWaitingForUnloadACK()) |
745 StopHangMonitorTimeout(); | 754 return; |
746 is_waiting_for_unload_ack_ = false; | 755 unload_event_monitor_timeout_->Stop(); |
747 has_timed_out_on_unload_ = timed_out; | 756 if (timed_out) { |
748 delegate_->SwappedOut(this); | |
749 } | |
750 | |
751 void RenderViewHostImpl::WasSwappedOut() { | |
752 // Don't bother reporting hung state anymore. | |
753 StopHangMonitorTimeout(); | |
754 | |
755 // If we have timed out on running the unload handler, we consider | |
756 // the process hung and we should terminate it if there are no other tabs | |
757 // using the process. If there are other views using this process, the | |
758 // unresponsive renderer timeout will catch it. | |
759 bool hung = has_timed_out_on_unload_; | |
760 | |
761 // Now that we're no longer the active RVH in the tab, start filtering out | |
762 // most IPC messages. Usually the renderer will have stopped sending | |
763 // messages as of OnSwapOutACK. However, we may have timed out waiting | |
764 // for that message, and additional IPC messages may keep streaming in. | |
765 // We filter them out, as long as that won't cause problems (e.g., we | |
766 // still allow synchronous messages through). | |
767 SetSwappedOut(true); | |
768 | |
769 // If we are not running the renderer in process and no other tab is using | |
770 // the hung process, consider it eligible to be killed, assuming it is a real | |
771 // process (unit tests don't have real processes). | |
772 if (hung) { | |
773 base::ProcessHandle process_handle = GetProcess()->GetHandle(); | 757 base::ProcessHandle process_handle = GetProcess()->GetHandle(); |
774 int views = 0; | 758 int views = 0; |
775 | 759 |
776 // Count the number of active widget hosts for the process, which | 760 // Count the number of active widget hosts for the process, which |
777 // is equivalent to views using the process as of this writing. | 761 // is equivalent to views using the process as of this writing. |
778 scoped_ptr<RenderWidgetHostIterator> widgets( | 762 scoped_ptr<RenderWidgetHostIterator> widgets( |
779 RenderWidgetHost::GetRenderWidgetHosts()); | 763 RenderWidgetHost::GetRenderWidgetHosts()); |
780 while (RenderWidgetHost* widget = widgets->GetNextHost()) { | 764 while (RenderWidgetHost* widget = widgets->GetNextHost()) { |
781 if (widget->GetProcess()->GetID() == GetProcess()->GetID()) | 765 if (widget->GetProcess()->GetID() == GetProcess()->GetID()) |
782 ++views; | 766 ++views; |
(...skipping 16 matching lines...) Expand all Loading... | |
799 | 783 |
800 // Log a histogram point to help us diagnose how many of those kills | 784 // Log a histogram point to help us diagnose how many of those kills |
801 // we have performed. 1 is the enum value for RendererType Normal for | 785 // we have performed. 1 is the enum value for RendererType Normal for |
802 // the histogram. | 786 // the histogram. |
803 UMA_HISTOGRAM_PERCENTAGE( | 787 UMA_HISTOGRAM_PERCENTAGE( |
804 "BrowserRenderProcessHost.ChildKillsUnresponsive", 1); | 788 "BrowserRenderProcessHost.ChildKillsUnresponsive", 1); |
805 } | 789 } |
806 } | 790 } |
807 } | 791 } |
808 | 792 |
809 // Inform the renderer that it can exit if no one else is using it. | 793 switch (rvh_state_) { |
794 case STATE_WAITING_FOR_UNLOAD_ACK: | |
795 SetState(STATE_WAITING_FOR_COMMIT); | |
796 break; | |
797 case STATE_PENDING_SWAP_OUT: | |
798 SetState(STATE_SWAPPED_OUT); | |
799 break; | |
800 case STATE_PENDING_SHUTDOWN: | |
801 DCHECK(!pending_shutdown_on_swap_out_.is_null()); | |
802 pending_shutdown_on_swap_out_.Run(); | |
803 break; | |
804 default: | |
805 NOTREACHED(); | |
806 } | |
807 } | |
808 | |
809 void RenderViewHostImpl::WasSwappedOut( | |
810 const base::Closure& pending_delete_on_swap_out) { | |
810 Send(new ViewMsg_WasSwappedOut(GetRoutingID())); | 811 Send(new ViewMsg_WasSwappedOut(GetRoutingID())); |
812 if (rvh_state_ == STATE_WAITING_FOR_UNLOAD_ACK) { | |
813 if (instance_->active_view_count()) | |
814 SetState(STATE_PENDING_SWAP_OUT); | |
815 else | |
816 SetPendingShutdown(pending_delete_on_swap_out); | |
817 } else if (rvh_state_ == STATE_WAITING_FOR_COMMIT) { | |
818 SetState(STATE_SWAPPED_OUT); | |
819 } else if (rvh_state_ == STATE_LIVE) { | |
820 // When the RenderView is not live, the RenderFrameHostManager will call | |
821 // Commit directly, without calling SwapOut on the old RVH. This will cause | |
nasko
2014/01/29 22:49:53
nit: Did you mean "call CommitPending"? Or somethi
clamy
2014/01/30 12:36:54
Done.
| |
822 // WasSwappedOut to be called directly on the live old RVH. | |
823 DCHECK(!IsRenderViewLive()); | |
824 SetState(STATE_SWAPPED_OUT); | |
825 } else { | |
826 NOTREACHED(); | |
827 } | |
828 } | |
829 | |
830 void RenderViewHostImpl::SetPendingShutdown(const base::Closure& on_swap_out) { | |
831 pending_shutdown_on_swap_out_ = on_swap_out; | |
832 SetState(STATE_PENDING_SHUTDOWN); | |
811 } | 833 } |
812 | 834 |
813 void RenderViewHostImpl::ClosePage() { | 835 void RenderViewHostImpl::ClosePage() { |
814 // Start the hang monitor in case the renderer hangs in the unload handler. | 836 SetState(STATE_WAITING_FOR_CLOSE); |
815 is_waiting_for_unload_ack_ = true; | |
816 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); | 837 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); |
817 | 838 |
818 if (IsRenderViewLive()) { | 839 if (IsRenderViewLive()) { |
819 // Since we are sending an IPC message to the renderer, increase the event | 840 // Since we are sending an IPC message to the renderer, increase the event |
820 // count to prevent the hang monitor timeout from being stopped by input | 841 // count to prevent the hang monitor timeout from being stopped by input |
821 // event acknowledgements. | 842 // event acknowledgements. |
822 increment_in_flight_event_count(); | 843 increment_in_flight_event_count(); |
823 | 844 |
824 // TODO(creis): Should this be moved to Shutdown? It may not be called for | 845 // TODO(creis): Should this be moved to Shutdown? It may not be called for |
825 // RenderViewHosts that have been swapped out. | 846 // RenderViewHosts that have been swapped out. |
826 NotificationService::current()->Notify( | 847 NotificationService::current()->Notify( |
827 NOTIFICATION_RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW, | 848 NOTIFICATION_RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW, |
828 Source<RenderViewHost>(this), | 849 Source<RenderViewHost>(this), |
829 NotificationService::NoDetails()); | 850 NotificationService::NoDetails()); |
830 | 851 |
831 Send(new ViewMsg_ClosePage(GetRoutingID())); | 852 Send(new ViewMsg_ClosePage(GetRoutingID())); |
832 } else { | 853 } else { |
833 // This RenderViewHost doesn't have a live renderer, so just skip the unload | 854 // This RenderViewHost doesn't have a live renderer, so just skip the unload |
834 // event and close the page. | 855 // event and close the page. |
835 ClosePageIgnoringUnloadEvents(); | 856 ClosePageIgnoringUnloadEvents(); |
836 } | 857 } |
837 } | 858 } |
838 | 859 |
839 void RenderViewHostImpl::ClosePageIgnoringUnloadEvents() { | 860 void RenderViewHostImpl::ClosePageIgnoringUnloadEvents() { |
840 StopHangMonitorTimeout(); | 861 StopHangMonitorTimeout(); |
841 is_waiting_for_beforeunload_ack_ = false; | 862 is_waiting_for_beforeunload_ack_ = false; |
842 is_waiting_for_unload_ack_ = false; | |
843 | 863 |
844 sudden_termination_allowed_ = true; | 864 sudden_termination_allowed_ = true; |
845 delegate_->Close(this); | 865 delegate_->Close(this); |
846 } | 866 } |
847 | 867 |
848 bool RenderViewHostImpl::HasPendingCrossSiteRequest() { | 868 bool RenderViewHostImpl::HasPendingCrossSiteRequest() { |
849 return CrossSiteRequestManager::GetInstance()->HasPendingCrossSiteRequest( | 869 return CrossSiteRequestManager::GetInstance()->HasPendingCrossSiteRequest( |
850 GetProcess()->GetID(), GetRoutingID()); | 870 GetProcess()->GetID(), GetRoutingID()); |
851 } | 871 } |
852 | 872 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1005 Send(new ViewMsg_ScriptEvalRequest(GetRoutingID(), frame_xpath, jscript, | 1025 Send(new ViewMsg_ScriptEvalRequest(GetRoutingID(), frame_xpath, jscript, |
1006 key, true)); | 1026 key, true)); |
1007 javascript_callbacks_.insert(std::make_pair(key, callback)); | 1027 javascript_callbacks_.insert(std::make_pair(key, callback)); |
1008 } | 1028 } |
1009 | 1029 |
1010 void RenderViewHostImpl::JavaScriptDialogClosed( | 1030 void RenderViewHostImpl::JavaScriptDialogClosed( |
1011 IPC::Message* reply_msg, | 1031 IPC::Message* reply_msg, |
1012 bool success, | 1032 bool success, |
1013 const base::string16& user_input) { | 1033 const base::string16& user_input) { |
1014 GetProcess()->SetIgnoreInputEvents(false); | 1034 GetProcess()->SetIgnoreInputEvents(false); |
1015 bool is_waiting = | 1035 bool is_waiting = is_waiting_for_beforeunload_ack_ || IsWaitingForUnloadACK(); |
1016 is_waiting_for_beforeunload_ack_ || is_waiting_for_unload_ack_; | |
1017 | 1036 |
1018 // If we are executing as part of (before)unload event handling, we don't | 1037 // If we are executing as part of (before)unload event handling, we don't |
1019 // want to use the regular hung_renderer_delay_ms_ if the user has agreed to | 1038 // want to use the regular hung_renderer_delay_ms_ if the user has agreed to |
1020 // leave the current page. In this case, use the regular timeout value used | 1039 // leave the current page. In this case, use the regular timeout value used |
1021 // during the (before)unload handling. | 1040 // during the (before)unload handling. |
1022 if (is_waiting) { | 1041 if (is_waiting) { |
1023 StartHangMonitorTimeout(TimeDelta::FromMilliseconds( | 1042 StartHangMonitorTimeout(TimeDelta::FromMilliseconds( |
1024 success ? kUnloadTimeoutMS : hung_renderer_delay_ms_)); | 1043 success ? kUnloadTimeoutMS : hung_renderer_delay_ms_)); |
1025 } | 1044 } |
1026 | 1045 |
1027 ViewHostMsg_RunJavaScriptMessage::WriteReplyParams(reply_msg, | 1046 ViewHostMsg_RunJavaScriptMessage::WriteReplyParams(reply_msg, |
1028 success, user_input); | 1047 success, user_input); |
1029 Send(reply_msg); | 1048 Send(reply_msg); |
1030 | 1049 |
1031 // If we are waiting for an unload or beforeunload ack and the user has | 1050 // If we are waiting for an unload or beforeunload ack and the user has |
1032 // suppressed messages, kill the tab immediately; a page that's spamming | 1051 // suppressed messages, kill the tab immediately; a page that's spamming |
1033 // alerts in onbeforeunload is presumably malicious, so there's no point in | 1052 // alerts in onbeforeunload is presumably malicious, so there's no point in |
1034 // continuing to run its script and dragging out the process. | 1053 // continuing to run its script and dragging out the process. |
1035 // This must be done after sending the reply since RenderView can't close | 1054 // This must be done after sending the reply since RenderView can't close |
1036 // correctly while waiting for a response. | 1055 // correctly while waiting for a response. |
1037 if (is_waiting && are_javascript_messages_suppressed_) | 1056 if (is_waiting && are_javascript_messages_suppressed_) |
1038 delegate_->RendererUnresponsive( | 1057 delegate_->RendererUnresponsive( |
1039 this, is_waiting_for_beforeunload_ack_, is_waiting_for_unload_ack_); | 1058 this, is_waiting_for_beforeunload_ack_, IsWaitingForUnloadACK()); |
1040 } | 1059 } |
1041 | 1060 |
1042 void RenderViewHostImpl::DragSourceEndedAt( | 1061 void RenderViewHostImpl::DragSourceEndedAt( |
1043 int client_x, int client_y, int screen_x, int screen_y, | 1062 int client_x, int client_y, int screen_x, int screen_y, |
1044 WebDragOperation operation) { | 1063 WebDragOperation operation) { |
1045 Send(new DragMsg_SourceEndedOrMoved( | 1064 Send(new DragMsg_SourceEndedOrMoved( |
1046 GetRoutingID(), | 1065 GetRoutingID(), |
1047 gfx::Point(client_x, client_y), | 1066 gfx::Point(client_x, client_y), |
1048 gfx::Point(screen_x, screen_y), | 1067 gfx::Point(screen_x, screen_y), |
1049 true, operation)); | 1068 true, operation)); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1185 | 1204 |
1186 /////////////////////////////////////////////////////////////////////////////// | 1205 /////////////////////////////////////////////////////////////////////////////// |
1187 // RenderViewHostImpl, IPC message handlers: | 1206 // RenderViewHostImpl, IPC message handlers: |
1188 | 1207 |
1189 bool RenderViewHostImpl::OnMessageReceived(const IPC::Message& msg) { | 1208 bool RenderViewHostImpl::OnMessageReceived(const IPC::Message& msg) { |
1190 if (!BrowserMessageFilter::CheckCanDispatchOnUI(msg, this)) | 1209 if (!BrowserMessageFilter::CheckCanDispatchOnUI(msg, this)) |
1191 return true; | 1210 return true; |
1192 | 1211 |
1193 // Filter out most IPC messages if this renderer is swapped out. | 1212 // Filter out most IPC messages if this renderer is swapped out. |
1194 // We still want to handle certain ACKs to keep our state consistent. | 1213 // We still want to handle certain ACKs to keep our state consistent. |
1195 if (is_swapped_out_) { | 1214 if (rvh_state_ == STATE_SWAPPED_OUT) { |
1196 if (!SwappedOutMessages::CanHandleWhileSwappedOut(msg)) { | 1215 if (!SwappedOutMessages::CanHandleWhileSwappedOut(msg)) { |
1197 // If this is a synchronous message and we decided not to handle it, | 1216 // If this is a synchronous message and we decided not to handle it, |
1198 // we must send an error reply, or else the renderer will be stuck | 1217 // we must send an error reply, or else the renderer will be stuck |
1199 // and won't respond to future requests. | 1218 // and won't respond to future requests. |
1200 if (msg.is_sync()) { | 1219 if (msg.is_sync()) { |
1201 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); | 1220 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); |
1202 reply->set_reply_error(); | 1221 reply->set_reply_error(); |
1203 Send(reply); | 1222 Send(reply); |
1204 } | 1223 } |
1205 // Don't continue looking for someone to handle it. | 1224 // Don't continue looking for someone to handle it. |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1353 } | 1372 } |
1354 | 1373 |
1355 void RenderViewHostImpl::CreateNewFullscreenWidget(int route_id) { | 1374 void RenderViewHostImpl::CreateNewFullscreenWidget(int route_id) { |
1356 delegate_->CreateNewFullscreenWidget(GetProcess()->GetID(), route_id); | 1375 delegate_->CreateNewFullscreenWidget(GetProcess()->GetID(), route_id); |
1357 } | 1376 } |
1358 | 1377 |
1359 void RenderViewHostImpl::OnShowView(int route_id, | 1378 void RenderViewHostImpl::OnShowView(int route_id, |
1360 WindowOpenDisposition disposition, | 1379 WindowOpenDisposition disposition, |
1361 const gfx::Rect& initial_pos, | 1380 const gfx::Rect& initial_pos, |
1362 bool user_gesture) { | 1381 bool user_gesture) { |
1363 if (!is_swapped_out_) { | 1382 if (IsRVHStateActive(rvh_state_)) { |
1364 delegate_->ShowCreatedWindow( | 1383 delegate_->ShowCreatedWindow( |
1365 route_id, disposition, initial_pos, user_gesture); | 1384 route_id, disposition, initial_pos, user_gesture); |
1366 } | 1385 } |
1367 Send(new ViewMsg_Move_ACK(route_id)); | 1386 Send(new ViewMsg_Move_ACK(route_id)); |
1368 } | 1387 } |
1369 | 1388 |
1370 void RenderViewHostImpl::OnShowWidget(int route_id, | 1389 void RenderViewHostImpl::OnShowWidget(int route_id, |
1371 const gfx::Rect& initial_pos) { | 1390 const gfx::Rect& initial_pos) { |
1372 if (!is_swapped_out_) | 1391 if (IsRVHStateActive(rvh_state_)) |
1373 delegate_->ShowCreatedWidget(route_id, initial_pos); | 1392 delegate_->ShowCreatedWidget(route_id, initial_pos); |
1374 Send(new ViewMsg_Move_ACK(route_id)); | 1393 Send(new ViewMsg_Move_ACK(route_id)); |
1375 } | 1394 } |
1376 | 1395 |
1377 void RenderViewHostImpl::OnShowFullscreenWidget(int route_id) { | 1396 void RenderViewHostImpl::OnShowFullscreenWidget(int route_id) { |
1378 if (!is_swapped_out_) | 1397 if (IsRVHStateActive(rvh_state_)) |
1379 delegate_->ShowCreatedFullscreenWidget(route_id); | 1398 delegate_->ShowCreatedFullscreenWidget(route_id); |
1380 Send(new ViewMsg_Move_ACK(route_id)); | 1399 Send(new ViewMsg_Move_ACK(route_id)); |
1381 } | 1400 } |
1382 | 1401 |
1383 void RenderViewHostImpl::OnRunModal(int opener_id, IPC::Message* reply_msg) { | 1402 void RenderViewHostImpl::OnRunModal(int opener_id, IPC::Message* reply_msg) { |
1384 DCHECK(!run_modal_reply_msg_); | 1403 DCHECK(!run_modal_reply_msg_); |
1385 run_modal_reply_msg_ = reply_msg; | 1404 run_modal_reply_msg_ = reply_msg; |
1386 run_modal_opener_id_ = opener_id; | 1405 run_modal_opener_id_ = opener_id; |
1387 | 1406 |
1388 RecordAction(base::UserMetricsAction("ShowModalDialog")); | 1407 RecordAction(base::UserMetricsAction("ShowModalDialog")); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1464 OnShouldCloseACK(true, send_should_close_start_time_, | 1483 OnShouldCloseACK(true, send_should_close_start_time_, |
1465 base::TimeTicks::Now()); | 1484 base::TimeTicks::Now()); |
1466 return; | 1485 return; |
1467 } | 1486 } |
1468 | 1487 |
1469 // If we're waiting for an unload ack from this renderer and we receive a | 1488 // If we're waiting for an unload ack from this renderer and we receive a |
1470 // Navigate message, then the renderer was navigating before it received the | 1489 // Navigate message, then the renderer was navigating before it received the |
1471 // unload request. It will either respond to the unload request soon or our | 1490 // unload request. It will either respond to the unload request soon or our |
1472 // timer will expire. Either way, we should ignore this message, because we | 1491 // timer will expire. Either way, we should ignore this message, because we |
1473 // have already committed to closing this renderer. | 1492 // have already committed to closing this renderer. |
1474 if (is_waiting_for_unload_ack_) | 1493 if (IsWaitingForUnloadACK()) |
1475 return; | 1494 return; |
1476 | 1495 |
1477 // Cache the main frame id, so we can use it for creating the frame tree | 1496 // Cache the main frame id, so we can use it for creating the frame tree |
1478 // root node when needed. | 1497 // root node when needed. |
1479 if (PageTransitionIsMainFrame(validated_params.transition)) { | 1498 if (PageTransitionIsMainFrame(validated_params.transition)) { |
1480 if (main_frame_id_ == -1) { | 1499 if (main_frame_id_ == -1) { |
1481 main_frame_id_ = validated_params.frame_id; | 1500 main_frame_id_ = validated_params.frame_id; |
1482 } else { | 1501 } else { |
1483 // TODO(nasko): We plan to remove the usage of frame_id in navigation | 1502 // TODO(nasko): We plan to remove the usage of frame_id in navigation |
1484 // and move to routing ids. This is in place to ensure that a | 1503 // and move to routing ids. This is in place to ensure that a |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1551 delegate_->UpdateTitle(this, page_id, title, | 1570 delegate_->UpdateTitle(this, page_id, title, |
1552 WebTextDirectionToChromeTextDirection( | 1571 WebTextDirectionToChromeTextDirection( |
1553 title_direction)); | 1572 title_direction)); |
1554 } | 1573 } |
1555 | 1574 |
1556 void RenderViewHostImpl::OnUpdateEncoding(const std::string& encoding_name) { | 1575 void RenderViewHostImpl::OnUpdateEncoding(const std::string& encoding_name) { |
1557 delegate_->UpdateEncoding(this, encoding_name); | 1576 delegate_->UpdateEncoding(this, encoding_name); |
1558 } | 1577 } |
1559 | 1578 |
1560 void RenderViewHostImpl::OnUpdateTargetURL(int32 page_id, const GURL& url) { | 1579 void RenderViewHostImpl::OnUpdateTargetURL(int32 page_id, const GURL& url) { |
1561 if (!is_swapped_out_) | 1580 if (IsRVHStateActive(rvh_state_)) |
1562 delegate_->UpdateTargetURL(page_id, url); | 1581 delegate_->UpdateTargetURL(page_id, url); |
1563 | 1582 |
1564 // Send a notification back to the renderer that we are ready to | 1583 // Send a notification back to the renderer that we are ready to |
1565 // receive more target urls. | 1584 // receive more target urls. |
1566 Send(new ViewMsg_UpdateTargetURL_ACK(GetRoutingID())); | 1585 Send(new ViewMsg_UpdateTargetURL_ACK(GetRoutingID())); |
1567 } | 1586 } |
1568 | 1587 |
1569 void RenderViewHostImpl::OnUpdateInspectorSetting( | 1588 void RenderViewHostImpl::OnUpdateInspectorSetting( |
1570 const std::string& key, const std::string& value) { | 1589 const std::string& key, const std::string& value) { |
1571 GetContentClient()->browser()->UpdateInspectorSetting( | 1590 GetContentClient()->browser()->UpdateInspectorSetting( |
1572 this, key, value); | 1591 this, key, value); |
1573 } | 1592 } |
1574 | 1593 |
1575 void RenderViewHostImpl::OnClose() { | 1594 void RenderViewHostImpl::OnClose() { |
1576 // If the renderer is telling us to close, it has already run the unload | 1595 // If the renderer is telling us to close, it has already run the unload |
1577 // events, and we can take the fast path. | 1596 // events, and we can take the fast path. |
1578 ClosePageIgnoringUnloadEvents(); | 1597 ClosePageIgnoringUnloadEvents(); |
1579 } | 1598 } |
1580 | 1599 |
1581 void RenderViewHostImpl::OnRequestMove(const gfx::Rect& pos) { | 1600 void RenderViewHostImpl::OnRequestMove(const gfx::Rect& pos) { |
1582 if (!is_swapped_out_) | 1601 if (IsRVHStateActive(rvh_state_)) |
1583 delegate_->RequestMove(pos); | 1602 delegate_->RequestMove(pos); |
1584 Send(new ViewMsg_Move_ACK(GetRoutingID())); | 1603 Send(new ViewMsg_Move_ACK(GetRoutingID())); |
1585 } | 1604 } |
1586 | 1605 |
1587 void RenderViewHostImpl::OnDidStartLoading() { | 1606 void RenderViewHostImpl::OnDidStartLoading() { |
1588 delegate_->DidStartLoading(this); | 1607 delegate_->DidStartLoading(this); |
1589 } | 1608 } |
1590 | 1609 |
1591 void RenderViewHostImpl::OnDidStopLoading() { | 1610 void RenderViewHostImpl::OnDidStopLoading() { |
1592 delegate_->DidStopLoading(this); | 1611 delegate_->DidStopLoading(this); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1825 | 1844 |
1826 void RenderViewHostImpl::OnShouldCloseACK( | 1845 void RenderViewHostImpl::OnShouldCloseACK( |
1827 bool proceed, | 1846 bool proceed, |
1828 const base::TimeTicks& renderer_before_unload_start_time, | 1847 const base::TimeTicks& renderer_before_unload_start_time, |
1829 const base::TimeTicks& renderer_before_unload_end_time) { | 1848 const base::TimeTicks& renderer_before_unload_end_time) { |
1830 decrement_in_flight_event_count(); | 1849 decrement_in_flight_event_count(); |
1831 StopHangMonitorTimeout(); | 1850 StopHangMonitorTimeout(); |
1832 // If this renderer navigated while the beforeunload request was in flight, we | 1851 // If this renderer navigated while the beforeunload request was in flight, we |
1833 // may have cleared this state in OnNavigate, in which case we can ignore | 1852 // may have cleared this state in OnNavigate, in which case we can ignore |
1834 // this message. | 1853 // this message. |
1835 if (!is_waiting_for_beforeunload_ack_ || is_swapped_out_) | 1854 if (!is_waiting_for_beforeunload_ack_ || rvh_state_ != STATE_LIVE) |
1836 return; | 1855 return; |
1837 | 1856 |
1838 is_waiting_for_beforeunload_ack_ = false; | 1857 is_waiting_for_beforeunload_ack_ = false; |
1839 | 1858 |
1840 RenderViewHostDelegate::RendererManagement* management_delegate = | 1859 RenderViewHostDelegate::RendererManagement* management_delegate = |
1841 delegate_->GetRendererManagementDelegate(); | 1860 delegate_->GetRendererManagementDelegate(); |
1842 if (management_delegate) { | 1861 if (management_delegate) { |
1843 base::TimeTicks before_unload_end_time; | 1862 base::TimeTicks before_unload_end_time; |
1844 if (!send_should_close_start_time_.is_null() && | 1863 if (!send_should_close_start_time_.is_null() && |
1845 !renderer_before_unload_start_time.is_null() && | 1864 !renderer_before_unload_start_time.is_null() && |
(...skipping 22 matching lines...) Expand all Loading... | |
1868 delegate_->DidCancelLoading(); | 1887 delegate_->DidCancelLoading(); |
1869 } | 1888 } |
1870 | 1889 |
1871 void RenderViewHostImpl::OnClosePageACK() { | 1890 void RenderViewHostImpl::OnClosePageACK() { |
1872 decrement_in_flight_event_count(); | 1891 decrement_in_flight_event_count(); |
1873 ClosePageIgnoringUnloadEvents(); | 1892 ClosePageIgnoringUnloadEvents(); |
1874 } | 1893 } |
1875 | 1894 |
1876 void RenderViewHostImpl::NotifyRendererUnresponsive() { | 1895 void RenderViewHostImpl::NotifyRendererUnresponsive() { |
1877 delegate_->RendererUnresponsive( | 1896 delegate_->RendererUnresponsive( |
1878 this, is_waiting_for_beforeunload_ack_, is_waiting_for_unload_ack_); | 1897 this, is_waiting_for_beforeunload_ack_, IsWaitingForUnloadACK()); |
1879 } | 1898 } |
1880 | 1899 |
1881 void RenderViewHostImpl::NotifyRendererResponsive() { | 1900 void RenderViewHostImpl::NotifyRendererResponsive() { |
1882 delegate_->RendererResponsive(this); | 1901 delegate_->RendererResponsive(this); |
1883 } | 1902 } |
1884 | 1903 |
1885 void RenderViewHostImpl::RequestToLockMouse(bool user_gesture, | 1904 void RenderViewHostImpl::RequestToLockMouse(bool user_gesture, |
1886 bool last_unlocked_by_target) { | 1905 bool last_unlocked_by_target) { |
1887 delegate_->RequestToLockMouse(user_gesture, last_unlocked_by_target); | 1906 delegate_->RequestToLockMouse(user_gesture, last_unlocked_by_target); |
1888 } | 1907 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1973 #endif | 1992 #endif |
1974 | 1993 |
1975 void RenderViewHostImpl::SendOrientationChangeEvent(int orientation) { | 1994 void RenderViewHostImpl::SendOrientationChangeEvent(int orientation) { |
1976 Send(new ViewMsg_OrientationChangeEvent(GetRoutingID(), orientation)); | 1995 Send(new ViewMsg_OrientationChangeEvent(GetRoutingID(), orientation)); |
1977 } | 1996 } |
1978 | 1997 |
1979 void RenderViewHostImpl::ToggleSpeechInput() { | 1998 void RenderViewHostImpl::ToggleSpeechInput() { |
1980 Send(new InputTagSpeechMsg_ToggleSpeechInput(GetRoutingID())); | 1999 Send(new InputTagSpeechMsg_ToggleSpeechInput(GetRoutingID())); |
1981 } | 2000 } |
1982 | 2001 |
2002 bool RenderViewHostImpl::IsWaitingForUnloadACK() const { | |
2003 return rvh_state_ == STATE_WAITING_FOR_UNLOAD_ACK || | |
2004 rvh_state_ == STATE_WAITING_FOR_CLOSE || | |
2005 rvh_state_ == STATE_PENDING_SHUTDOWN || | |
2006 rvh_state_ == STATE_PENDING_SWAP_OUT; | |
2007 } | |
2008 | |
1983 bool RenderViewHostImpl::CanCommitURL(const GURL& url) { | 2009 bool RenderViewHostImpl::CanCommitURL(const GURL& url) { |
1984 // TODO(creis): We should also check for WebUI pages here. Also, when the | 2010 // TODO(creis): We should also check for WebUI pages here. Also, when the |
1985 // out-of-process iframes implementation is ready, we should check for | 2011 // out-of-process iframes implementation is ready, we should check for |
1986 // cross-site URLs that are not allowed to commit in this process. | 2012 // cross-site URLs that are not allowed to commit in this process. |
1987 | 2013 |
1988 // Give the client a chance to disallow URLs from committing. | 2014 // Give the client a chance to disallow URLs from committing. |
1989 return GetContentClient()->browser()->CanCommitURL(GetProcess(), url); | 2015 return GetContentClient()->browser()->CanCommitURL(GetProcess(), url); |
1990 } | 2016 } |
1991 | 2017 |
1992 void RenderViewHostImpl::ExitFullscreen() { | 2018 void RenderViewHostImpl::ExitFullscreen() { |
1993 RejectMouseLockOrUnlockIfNecessary(); | 2019 RejectMouseLockOrUnlockIfNecessary(); |
1994 // Notify delegate_ and renderer of fullscreen state change. | 2020 // Notify delegate_ and renderer of fullscreen state change. |
1995 OnToggleFullscreen(false); | 2021 OnToggleFullscreen(false); |
1996 } | 2022 } |
1997 | 2023 |
1998 WebPreferences RenderViewHostImpl::GetWebkitPreferences() { | 2024 WebPreferences RenderViewHostImpl::GetWebkitPreferences() { |
1999 return delegate_->GetWebkitPrefs(); | 2025 return delegate_->GetWebkitPrefs(); |
2000 } | 2026 } |
2001 | 2027 |
2002 void RenderViewHostImpl::DisownOpener() { | 2028 void RenderViewHostImpl::DisownOpener() { |
2003 // This should only be called when swapped out. | 2029 // This should only be called when swapped out. |
2004 DCHECK(is_swapped_out_); | 2030 DCHECK(rvh_state_ == STATE_SWAPPED_OUT); |
2005 | 2031 |
2006 Send(new ViewMsg_DisownOpener(GetRoutingID())); | 2032 Send(new ViewMsg_DisownOpener(GetRoutingID())); |
2007 } | 2033 } |
2008 | 2034 |
2009 void RenderViewHostImpl::SetAccessibilityCallbackForTesting( | 2035 void RenderViewHostImpl::SetAccessibilityCallbackForTesting( |
2010 const base::Callback<void(ui::AXEvent)>& callback) { | 2036 const base::Callback<void(ui::AXEvent)>& callback) { |
2011 accessibility_testing_callback_ = callback; | 2037 accessibility_testing_callback_ = callback; |
2012 } | 2038 } |
2013 | 2039 |
2014 void RenderViewHostImpl::UpdateWebkitPreferences(const WebPreferences& prefs) { | 2040 void RenderViewHostImpl::UpdateWebkitPreferences(const WebPreferences& prefs) { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2085 const gfx::Point& location, const blink::WebPluginAction& action) { | 2111 const gfx::Point& location, const blink::WebPluginAction& action) { |
2086 Send(new ViewMsg_PluginActionAt(GetRoutingID(), location, action)); | 2112 Send(new ViewMsg_PluginActionAt(GetRoutingID(), location, action)); |
2087 } | 2113 } |
2088 | 2114 |
2089 void RenderViewHostImpl::NotifyMoveOrResizeStarted() { | 2115 void RenderViewHostImpl::NotifyMoveOrResizeStarted() { |
2090 Send(new ViewMsg_MoveOrResizeStarted(GetRoutingID())); | 2116 Send(new ViewMsg_MoveOrResizeStarted(GetRoutingID())); |
2091 } | 2117 } |
2092 | 2118 |
2093 void RenderViewHostImpl::OnAccessibilityEvents( | 2119 void RenderViewHostImpl::OnAccessibilityEvents( |
2094 const std::vector<AccessibilityHostMsg_EventParams>& params) { | 2120 const std::vector<AccessibilityHostMsg_EventParams>& params) { |
2095 if (view_ && !is_swapped_out_) { | 2121 if (view_ && IsRVHStateActive(rvh_state_)) { |
2096 view_->CreateBrowserAccessibilityManagerIfNeeded(); | 2122 view_->CreateBrowserAccessibilityManagerIfNeeded(); |
2097 BrowserAccessibilityManager* manager = | 2123 BrowserAccessibilityManager* manager = |
2098 view_->GetBrowserAccessibilityManager(); | 2124 view_->GetBrowserAccessibilityManager(); |
2099 if (manager) | 2125 if (manager) |
2100 manager->OnAccessibilityEvents(params); | 2126 manager->OnAccessibilityEvents(params); |
2101 } | 2127 } |
2102 | 2128 |
2103 // Always send an ACK or the renderer can be in a bad state. | 2129 // Always send an ACK or the renderer can be in a bad state. |
2104 Send(new AccessibilityMsg_Events_ACK(GetRoutingID())); | 2130 Send(new AccessibilityMsg_Events_ACK(GetRoutingID())); |
2105 | 2131 |
(...skipping 11 matching lines...) Expand all Loading... | |
2117 if (!ax_tree_) | 2143 if (!ax_tree_) |
2118 ax_tree_.reset(new ui::AXTree(update)); | 2144 ax_tree_.reset(new ui::AXTree(update)); |
2119 else | 2145 else |
2120 CHECK(ax_tree_->Unserialize(update)) << ax_tree_->error(); | 2146 CHECK(ax_tree_->Unserialize(update)) << ax_tree_->error(); |
2121 accessibility_testing_callback_.Run(param.event_type); | 2147 accessibility_testing_callback_.Run(param.event_type); |
2122 } | 2148 } |
2123 } | 2149 } |
2124 | 2150 |
2125 void RenderViewHostImpl::OnAccessibilityLocationChanges( | 2151 void RenderViewHostImpl::OnAccessibilityLocationChanges( |
2126 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { | 2152 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { |
2127 if (view_ && !is_swapped_out_) { | 2153 if (view_ && IsRVHStateActive(rvh_state_)) { |
2128 view_->CreateBrowserAccessibilityManagerIfNeeded(); | 2154 view_->CreateBrowserAccessibilityManagerIfNeeded(); |
2129 BrowserAccessibilityManager* manager = | 2155 BrowserAccessibilityManager* manager = |
2130 view_->GetBrowserAccessibilityManager(); | 2156 view_->GetBrowserAccessibilityManager(); |
2131 if (manager) | 2157 if (manager) |
2132 manager->OnLocationChanges(params); | 2158 manager->OnLocationChanges(params); |
2133 } | 2159 } |
2134 } | 2160 } |
2135 | 2161 |
2136 void RenderViewHostImpl::OnScriptEvalResponse(int id, | 2162 void RenderViewHostImpl::OnScriptEvalResponse(int id, |
2137 const base::ListValue& result) { | 2163 const base::ListValue& result) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2222 params.item_height, | 2248 params.item_height, |
2223 params.item_font_size, | 2249 params.item_font_size, |
2224 params.selected_item, | 2250 params.selected_item, |
2225 params.popup_items, | 2251 params.popup_items, |
2226 params.right_aligned, | 2252 params.right_aligned, |
2227 params.allow_multiple_selection); | 2253 params.allow_multiple_selection); |
2228 } | 2254 } |
2229 } | 2255 } |
2230 #endif | 2256 #endif |
2231 | 2257 |
2232 void RenderViewHostImpl::SetSwappedOut(bool is_swapped_out) { | 2258 void RenderViewHostImpl::SetState(RenderViewHostImplState rvh_state) { |
2233 // We update the number of RenderViews in a SiteInstance when the | 2259 // We update the number of RenderViews in a SiteInstance when the |
2234 // swapped out status of this RenderView gets flipped. | 2260 // swapped out status of this RenderView gets flipped to/from live. |
2235 if (is_swapped_out_ && !is_swapped_out) | 2261 if (!IsRVHStateActive(rvh_state_) && IsRVHStateActive(rvh_state)) |
2236 instance_->increment_active_view_count(); | 2262 instance_->increment_active_view_count(); |
2237 else if (!is_swapped_out_ && is_swapped_out) | 2263 else if (IsRVHStateActive(rvh_state_) && !IsRVHStateActive(rvh_state)) |
2238 instance_->decrement_active_view_count(); | 2264 instance_->decrement_active_view_count(); |
2239 | 2265 |
2240 is_swapped_out_ = is_swapped_out; | 2266 // Whenever we change the RVH state to and from live or swapped out state, we |
2267 // should not be waiting for beforeunload or unload acks. We clear them here | |
2268 // to be safe, since they can cause navigations to be ignored in OnNavigate. | |
2269 if (rvh_state == STATE_LIVE || | |
2270 rvh_state == STATE_SWAPPED_OUT || | |
2271 rvh_state_ == STATE_LIVE || | |
2272 rvh_state_ == STATE_SWAPPED_OUT) { | |
2273 is_waiting_for_beforeunload_ack_ = false; | |
2274 } | |
2275 rvh_state_ = rvh_state; | |
2241 | 2276 |
2242 // Whenever we change swap out state, we should not be waiting for | |
2243 // beforeunload or unload acks. We clear them here to be safe, since they | |
2244 // can cause navigations to be ignored in OnNavigate. | |
2245 is_waiting_for_beforeunload_ack_ = false; | |
2246 is_waiting_for_unload_ack_ = false; | |
2247 has_timed_out_on_unload_ = false; | |
2248 } | 2277 } |
2249 | 2278 |
2250 bool RenderViewHostImpl::CanAccessFilesOfPageState( | 2279 bool RenderViewHostImpl::CanAccessFilesOfPageState( |
2251 const PageState& state) const { | 2280 const PageState& state) const { |
2252 ChildProcessSecurityPolicyImpl* policy = | 2281 ChildProcessSecurityPolicyImpl* policy = |
2253 ChildProcessSecurityPolicyImpl::GetInstance(); | 2282 ChildProcessSecurityPolicyImpl::GetInstance(); |
2254 | 2283 |
2255 const std::vector<base::FilePath>& file_paths = state.GetReferencedFiles(); | 2284 const std::vector<base::FilePath>& file_paths = state.GetReferencedFiles(); |
2256 for (std::vector<base::FilePath>::const_iterator file = file_paths.begin(); | 2285 for (std::vector<base::FilePath>::const_iterator file = file_paths.begin(); |
2257 file != file_paths.end(); ++file) { | 2286 file != file_paths.end(); ++file) { |
2258 if (!policy->CanReadFile(GetProcess()->GetID(), *file)) | 2287 if (!policy->CanReadFile(GetProcess()->GetID(), *file)) |
2259 return false; | 2288 return false; |
2260 } | 2289 } |
2261 return true; | 2290 return true; |
2262 } | 2291 } |
2263 | 2292 |
2264 void RenderViewHostImpl::AttachToFrameTree() { | 2293 void RenderViewHostImpl::AttachToFrameTree() { |
2265 FrameTree* frame_tree = delegate_->GetFrameTree(); | 2294 FrameTree* frame_tree = delegate_->GetFrameTree(); |
2266 | 2295 |
2267 frame_tree->ResetForMainFrameSwap(); | 2296 frame_tree->ResetForMainFrameSwap(); |
2268 if (main_frame_id() != FrameTreeNode::kInvalidFrameId) { | 2297 if (main_frame_id() != FrameTreeNode::kInvalidFrameId) { |
2269 frame_tree->OnFirstNavigationAfterSwap(main_frame_id()); | 2298 frame_tree->OnFirstNavigationAfterSwap(main_frame_id()); |
2270 } | 2299 } |
2271 } | 2300 } |
2272 | 2301 |
2273 } // namespace content | 2302 } // namespace content |
OLD | NEW |