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 18 matching lines...) Expand all Loading... |
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/cross_site_transferring_request.h" | 37 #include "content/browser/renderer_host/cross_site_transferring_request.h" |
38 #include "content/browser/renderer_host/dip_util.h" | 38 #include "content/browser/renderer_host/dip_util.h" |
| 39 #include "content/browser/renderer_host/input/timeout_monitor.h" |
39 #include "content/browser/renderer_host/media/audio_renderer_host.h" | 40 #include "content/browser/renderer_host/media/audio_renderer_host.h" |
40 #include "content/browser/renderer_host/render_process_host_impl.h" | 41 #include "content/browser/renderer_host/render_process_host_impl.h" |
41 #include "content/browser/renderer_host/render_view_host_delegate.h" | 42 #include "content/browser/renderer_host/render_view_host_delegate.h" |
42 #include "content/common/accessibility_messages.h" | 43 #include "content/common/accessibility_messages.h" |
43 #include "content/common/browser_plugin/browser_plugin_messages.h" | 44 #include "content/common/browser_plugin/browser_plugin_messages.h" |
44 #include "content/common/content_switches_internal.h" | 45 #include "content/common/content_switches_internal.h" |
45 #include "content/common/desktop_notification_messages.h" | 46 #include "content/common/desktop_notification_messages.h" |
46 #include "content/common/drag_messages.h" | 47 #include "content/common/drag_messages.h" |
47 #include "content/common/frame_messages.h" | 48 #include "content/common/frame_messages.h" |
48 #include "content/common/input_messages.h" | 49 #include "content/common/input_messages.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 } | 145 } |
145 } | 146 } |
146 #endif | 147 #endif |
147 | 148 |
148 } // namespace | 149 } // namespace |
149 | 150 |
150 /////////////////////////////////////////////////////////////////////////////// | 151 /////////////////////////////////////////////////////////////////////////////// |
151 // RenderViewHost, public: | 152 // RenderViewHost, public: |
152 | 153 |
153 // static | 154 // static |
| 155 bool RenderViewHostImpl::IsRVHStateActive(RenderViewHostImplState rvh_state) { |
| 156 if (rvh_state == STATE_DEFAULT || |
| 157 rvh_state == STATE_WAITING_FOR_UNLOAD_ACK || |
| 158 rvh_state == STATE_WAITING_FOR_COMMIT || |
| 159 rvh_state == STATE_WAITING_FOR_CLOSE) |
| 160 return true; |
| 161 return false; |
| 162 } |
| 163 |
| 164 // static |
154 RenderViewHost* RenderViewHost::FromID(int render_process_id, | 165 RenderViewHost* RenderViewHost::FromID(int render_process_id, |
155 int render_view_id) { | 166 int render_view_id) { |
156 return RenderViewHostImpl::FromID(render_process_id, render_view_id); | 167 return RenderViewHostImpl::FromID(render_process_id, render_view_id); |
157 } | 168 } |
158 | 169 |
159 // static | 170 // static |
160 RenderViewHost* RenderViewHost::From(RenderWidgetHost* rwh) { | 171 RenderViewHost* RenderViewHost::From(RenderWidgetHost* rwh) { |
161 DCHECK(rwh->IsRenderView()); | 172 DCHECK(rwh->IsRenderView()); |
162 return static_cast<RenderViewHostImpl*>(RenderWidgetHostImpl::From(rwh)); | 173 return static_cast<RenderViewHostImpl*>(RenderWidgetHostImpl::From(rwh)); |
163 } | 174 } |
(...skipping 16 matching lines...) Expand all Loading... |
180 RenderViewHostDelegate* delegate, | 191 RenderViewHostDelegate* delegate, |
181 RenderWidgetHostDelegate* widget_delegate, | 192 RenderWidgetHostDelegate* widget_delegate, |
182 int routing_id, | 193 int routing_id, |
183 int main_frame_routing_id, | 194 int main_frame_routing_id, |
184 bool swapped_out, | 195 bool swapped_out, |
185 bool hidden) | 196 bool hidden) |
186 : RenderWidgetHostImpl(widget_delegate, | 197 : RenderWidgetHostImpl(widget_delegate, |
187 instance->GetProcess(), | 198 instance->GetProcess(), |
188 routing_id, | 199 routing_id, |
189 hidden), | 200 hidden), |
| 201 frames_ref_count_(0), |
190 delegate_(delegate), | 202 delegate_(delegate), |
191 instance_(static_cast<SiteInstanceImpl*>(instance)), | 203 instance_(static_cast<SiteInstanceImpl*>(instance)), |
192 waiting_for_drag_context_response_(false), | 204 waiting_for_drag_context_response_(false), |
193 enabled_bindings_(0), | 205 enabled_bindings_(0), |
194 navigations_suspended_(false), | 206 navigations_suspended_(false), |
195 has_accessed_initial_document_(false), | 207 has_accessed_initial_document_(false), |
196 is_swapped_out_(swapped_out), | |
197 main_frame_routing_id_(main_frame_routing_id), | 208 main_frame_routing_id_(main_frame_routing_id), |
198 is_waiting_for_beforeunload_ack_(false), | 209 is_waiting_for_beforeunload_ack_(false), |
199 is_waiting_for_unload_ack_(false), | |
200 has_timed_out_on_unload_(false), | |
201 unload_ack_is_for_cross_site_transition_(false), | 210 unload_ack_is_for_cross_site_transition_(false), |
202 are_javascript_messages_suppressed_(false), | 211 are_javascript_messages_suppressed_(false), |
203 sudden_termination_allowed_(false), | 212 sudden_termination_allowed_(false), |
204 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), | 213 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), |
205 virtual_keyboard_requested_(false) { | 214 virtual_keyboard_requested_(false), |
| 215 weak_factory_(this) { |
206 DCHECK(instance_.get()); | 216 DCHECK(instance_.get()); |
207 CHECK(delegate_); // http://crbug.com/82827 | 217 CHECK(delegate_); // http://crbug.com/82827 |
208 | 218 |
209 GetProcess()->EnableSendQueue(); | 219 GetProcess()->EnableSendQueue(); |
210 | 220 |
211 if (!swapped_out) | 221 if (swapped_out) { |
| 222 rvh_state_ = STATE_SWAPPED_OUT; |
| 223 } else { |
| 224 rvh_state_ = STATE_DEFAULT; |
212 instance_->increment_active_view_count(); | 225 instance_->increment_active_view_count(); |
| 226 } |
213 | 227 |
214 if (ResourceDispatcherHostImpl::Get()) { | 228 if (ResourceDispatcherHostImpl::Get()) { |
215 BrowserThread::PostTask( | 229 BrowserThread::PostTask( |
216 BrowserThread::IO, FROM_HERE, | 230 BrowserThread::IO, FROM_HERE, |
217 base::Bind(&ResourceDispatcherHostImpl::OnRenderViewHostCreated, | 231 base::Bind(&ResourceDispatcherHostImpl::OnRenderViewHostCreated, |
218 base::Unretained(ResourceDispatcherHostImpl::Get()), | 232 base::Unretained(ResourceDispatcherHostImpl::Get()), |
219 GetProcess()->GetID(), GetRoutingID())); | 233 GetProcess()->GetID(), GetRoutingID())); |
220 } | 234 } |
221 | 235 |
222 #if defined(OS_ANDROID) | 236 #if defined(OS_ANDROID) |
223 media_player_manager_.reset(BrowserMediaPlayerManager::Create(this)); | 237 media_player_manager_.reset(BrowserMediaPlayerManager::Create(this)); |
224 #endif | 238 #endif |
| 239 |
| 240 unload_event_monitor_timeout_.reset(new TimeoutMonitor(base::Bind( |
| 241 &RenderViewHostImpl::OnSwappedOut, weak_factory_.GetWeakPtr(), true))); |
225 } | 242 } |
226 | 243 |
227 RenderViewHostImpl::~RenderViewHostImpl() { | 244 RenderViewHostImpl::~RenderViewHostImpl() { |
228 if (ResourceDispatcherHostImpl::Get()) { | 245 if (ResourceDispatcherHostImpl::Get()) { |
229 BrowserThread::PostTask( | 246 BrowserThread::PostTask( |
230 BrowserThread::IO, FROM_HERE, | 247 BrowserThread::IO, FROM_HERE, |
231 base::Bind(&ResourceDispatcherHostImpl::OnRenderViewHostDeleted, | 248 base::Bind(&ResourceDispatcherHostImpl::OnRenderViewHostDeleted, |
232 base::Unretained(ResourceDispatcherHostImpl::Get()), | 249 base::Unretained(ResourceDispatcherHostImpl::Get()), |
233 GetProcess()->GetID(), GetRoutingID())); | 250 GetProcess()->GetID(), GetRoutingID())); |
234 } | 251 } |
235 | 252 |
236 delegate_->RenderViewDeleted(this); | 253 delegate_->RenderViewDeleted(this); |
237 | 254 |
238 // Be sure to clean up any leftover state from cross-site requests. | 255 // Be sure to clean up any leftover state from cross-site requests. |
239 CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest( | 256 CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest( |
240 GetProcess()->GetID(), GetRoutingID(), false); | 257 GetProcess()->GetID(), GetRoutingID(), false); |
241 | 258 |
242 // If this was swapped out, it already decremented the active view | 259 // If this was swapped out, it already decremented the active view |
243 // count of the SiteInstance it belongs to. | 260 // count of the SiteInstance it belongs to. |
244 if (!is_swapped_out_) | 261 if (IsRVHStateActive(rvh_state_)) |
245 instance_->decrement_active_view_count(); | 262 instance_->decrement_active_view_count(); |
246 } | 263 } |
247 | 264 |
248 RenderViewHostDelegate* RenderViewHostImpl::GetDelegate() const { | 265 RenderViewHostDelegate* RenderViewHostImpl::GetDelegate() const { |
249 return delegate_; | 266 return delegate_; |
250 } | 267 } |
251 | 268 |
252 SiteInstance* RenderViewHostImpl::GetSiteInstance() const { | 269 SiteInstance* RenderViewHostImpl::GetSiteInstance() const { |
253 return instance_.get(); | 270 return instance_.get(); |
254 } | 271 } |
(...skipping 30 matching lines...) Expand all Loading... |
285 delegate_->GetRendererPrefs(GetProcess()->GetBrowserContext()); | 302 delegate_->GetRendererPrefs(GetProcess()->GetBrowserContext()); |
286 params.web_preferences = delegate_->GetWebkitPrefs(); | 303 params.web_preferences = delegate_->GetWebkitPrefs(); |
287 params.view_id = GetRoutingID(); | 304 params.view_id = GetRoutingID(); |
288 params.main_frame_routing_id = main_frame_routing_id_; | 305 params.main_frame_routing_id = main_frame_routing_id_; |
289 params.surface_id = surface_id(); | 306 params.surface_id = surface_id(); |
290 params.session_storage_namespace_id = | 307 params.session_storage_namespace_id = |
291 delegate_->GetSessionStorageNamespace(instance_)->id(); | 308 delegate_->GetSessionStorageNamespace(instance_)->id(); |
292 params.frame_name = frame_name; | 309 params.frame_name = frame_name; |
293 // Ensure the RenderView sets its opener correctly. | 310 // Ensure the RenderView sets its opener correctly. |
294 params.opener_route_id = opener_route_id; | 311 params.opener_route_id = opener_route_id; |
295 params.swapped_out = is_swapped_out_; | 312 params.swapped_out = !IsRVHStateActive(rvh_state_); |
296 params.hidden = is_hidden(); | 313 params.hidden = is_hidden(); |
297 params.next_page_id = next_page_id; | 314 params.next_page_id = next_page_id; |
298 GetWebScreenInfo(¶ms.screen_info); | 315 GetWebScreenInfo(¶ms.screen_info); |
299 params.accessibility_mode = accessibility_mode(); | 316 params.accessibility_mode = accessibility_mode(); |
300 | 317 |
301 Send(new ViewMsg_New(params)); | 318 Send(new ViewMsg_New(params)); |
302 | 319 |
303 // If it's enabled, tell the renderer to set up the Javascript bindings for | 320 // If it's enabled, tell the renderer to set up the Javascript bindings for |
304 // sending messages back to the browser. | 321 // sending messages back to the browser. |
305 if (GetProcess()->IsGuest()) | 322 if (GetProcess()->IsGuest()) |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 if (navigations_suspended_) { | 586 if (navigations_suspended_) { |
570 // Shouldn't be possible to have a second navigation while suspended, since | 587 // Shouldn't be possible to have a second navigation while suspended, since |
571 // navigations will only be suspended during a cross-site request. If a | 588 // navigations will only be suspended during a cross-site request. If a |
572 // second navigation occurs, WebContentsImpl will cancel this pending RVH | 589 // second navigation occurs, WebContentsImpl will cancel this pending RVH |
573 // create a new pending RVH. | 590 // create a new pending RVH. |
574 DCHECK(!suspended_nav_params_.get()); | 591 DCHECK(!suspended_nav_params_.get()); |
575 suspended_nav_params_.reset(new ViewMsg_Navigate_Params(params)); | 592 suspended_nav_params_.reset(new ViewMsg_Navigate_Params(params)); |
576 } else { | 593 } else { |
577 // Get back to a clean state, in case we start a new navigation without | 594 // Get back to a clean state, in case we start a new navigation without |
578 // completing a RVH swap or unload handler. | 595 // completing a RVH swap or unload handler. |
579 SetSwappedOut(false); | 596 SetState(STATE_DEFAULT); |
580 | 597 |
581 Send(new ViewMsg_Navigate(GetRoutingID(), params)); | 598 Send(new ViewMsg_Navigate(GetRoutingID(), params)); |
582 } | 599 } |
583 | 600 |
584 // Force the throbber to start. We do this because WebKit's "started | 601 // Force the throbber to start. We do this because WebKit's "started |
585 // loading" message will be received asynchronously from the UI of the | 602 // loading" message will be received asynchronously from the UI of the |
586 // browser. But we want to keep the throbber in sync with what's happening | 603 // browser. But we want to keep the throbber in sync with what's happening |
587 // in the UI. For example, we want to start throbbing immediately when the | 604 // in the UI. For example, we want to start throbbing immediately when the |
588 // user naivgates even if the renderer is delayed. There is also an issue | 605 // user naivgates even if the renderer is delayed. There is also an issue |
589 // with the throbber starting because the WebUI (which controls whether the | 606 // with the throbber starting because the WebUI (which controls whether the |
(...skipping 25 matching lines...) Expand all Loading... |
615 bool suspend, | 632 bool suspend, |
616 const base::TimeTicks& proceed_time) { | 633 const base::TimeTicks& proceed_time) { |
617 // This should only be called to toggle the state. | 634 // This should only be called to toggle the state. |
618 DCHECK(navigations_suspended_ != suspend); | 635 DCHECK(navigations_suspended_ != suspend); |
619 | 636 |
620 navigations_suspended_ = suspend; | 637 navigations_suspended_ = suspend; |
621 if (!suspend && suspended_nav_params_) { | 638 if (!suspend && suspended_nav_params_) { |
622 // There's navigation message params waiting to be sent. Now that we're not | 639 // There's navigation message params waiting to be sent. Now that we're not |
623 // suspended anymore, resume navigation by sending them. If we were swapped | 640 // suspended anymore, resume navigation by sending them. If we were swapped |
624 // out, we should also stop filtering out the IPC messages now. | 641 // out, we should also stop filtering out the IPC messages now. |
625 SetSwappedOut(false); | 642 SetState(STATE_DEFAULT); |
626 | 643 |
627 DCHECK(!proceed_time.is_null()); | 644 DCHECK(!proceed_time.is_null()); |
628 suspended_nav_params_->browser_navigation_start = proceed_time; | 645 suspended_nav_params_->browser_navigation_start = proceed_time; |
629 Send(new ViewMsg_Navigate(GetRoutingID(), *suspended_nav_params_.get())); | 646 Send(new ViewMsg_Navigate(GetRoutingID(), *suspended_nav_params_.get())); |
630 suspended_nav_params_.reset(); | 647 suspended_nav_params_.reset(); |
631 } | 648 } |
632 } | 649 } |
633 | 650 |
634 void RenderViewHostImpl::CancelSuspendedNavigations() { | 651 void RenderViewHostImpl::CancelSuspendedNavigations() { |
635 // Clear any state if a pending navigation is canceled or pre-empted. | 652 // Clear any state if a pending navigation is canceled or pre-empted. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 cross_site_transferring_request.Pass(), | 715 cross_site_transferring_request.Pass(), |
699 transfer_url_chain, referrer, page_transition, | 716 transfer_url_chain, referrer, page_transition, |
700 frame_id, should_replace_current_entry); | 717 frame_id, should_replace_current_entry); |
701 } | 718 } |
702 | 719 |
703 void RenderViewHostImpl::SuppressDialogsUntilSwapOut() { | 720 void RenderViewHostImpl::SuppressDialogsUntilSwapOut() { |
704 Send(new ViewMsg_SuppressDialogsUntilSwapOut(GetRoutingID())); | 721 Send(new ViewMsg_SuppressDialogsUntilSwapOut(GetRoutingID())); |
705 } | 722 } |
706 | 723 |
707 void RenderViewHostImpl::SwapOut() { | 724 void RenderViewHostImpl::SwapOut() { |
708 // This will be set back to false in OnSwapOutACK, just before we replace | 725 SetState(STATE_WAITING_FOR_UNLOAD_ACK); |
709 // this RVH with the pending RVH. | 726 unload_event_monitor_timeout_->Start( |
710 is_waiting_for_unload_ack_ = true; | 727 base::TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); |
711 // Start the hang monitor in case the renderer hangs in the unload handler. | |
712 // Increment the in-flight event count, to ensure that input events won't | |
713 // cancel the timeout timer. | |
714 increment_in_flight_event_count(); | |
715 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); | |
716 | 728 |
717 if (IsRenderViewLive()) { | 729 if (IsRenderViewLive()) { |
718 Send(new ViewMsg_SwapOut(GetRoutingID())); | 730 Send(new ViewMsg_SwapOut(GetRoutingID())); |
719 } else { | |
720 // This RenderViewHost doesn't have a live renderer, so just skip the unload | |
721 // event. | |
722 OnSwappedOut(true); | |
723 } | 731 } |
| 732 delegate_->SwappedOut(this); |
724 } | 733 } |
725 | 734 |
726 void RenderViewHostImpl::OnSwapOutACK() { | 735 void RenderViewHostImpl::OnSwapOutACK() { |
727 OnSwappedOut(false); | 736 OnSwappedOut(false); |
728 } | 737 } |
729 | 738 |
730 void RenderViewHostImpl::OnSwappedOut(bool timed_out) { | 739 void RenderViewHostImpl::OnSwappedOut(bool timed_out) { |
731 // Stop the hang monitor now that the unload handler has finished. | 740 // Ignore spurious swap out ack. |
732 decrement_in_flight_event_count(); | 741 if (!IsWaitingForUnloadACK()) |
733 StopHangMonitorTimeout(); | 742 return; |
734 is_waiting_for_unload_ack_ = false; | 743 unload_event_monitor_timeout_->Stop(); |
735 has_timed_out_on_unload_ = timed_out; | 744 if (timed_out) { |
736 delegate_->SwappedOut(this); | |
737 } | |
738 | |
739 void RenderViewHostImpl::WasSwappedOut() { | |
740 // Don't bother reporting hung state anymore. | |
741 StopHangMonitorTimeout(); | |
742 | |
743 // If we have timed out on running the unload handler, we consider | |
744 // the process hung and we should terminate it if there are no other tabs | |
745 // using the process. If there are other views using this process, the | |
746 // unresponsive renderer timeout will catch it. | |
747 bool hung = has_timed_out_on_unload_; | |
748 | |
749 // Now that we're no longer the active RVH in the tab, start filtering out | |
750 // most IPC messages. Usually the renderer will have stopped sending | |
751 // messages as of OnSwapOutACK. However, we may have timed out waiting | |
752 // for that message, and additional IPC messages may keep streaming in. | |
753 // We filter them out, as long as that won't cause problems (e.g., we | |
754 // still allow synchronous messages through). | |
755 SetSwappedOut(true); | |
756 | |
757 // If we are not running the renderer in process and no other tab is using | |
758 // the hung process, consider it eligible to be killed, assuming it is a real | |
759 // process (unit tests don't have real processes). | |
760 if (hung) { | |
761 base::ProcessHandle process_handle = GetProcess()->GetHandle(); | 745 base::ProcessHandle process_handle = GetProcess()->GetHandle(); |
762 int views = 0; | 746 int views = 0; |
763 | 747 |
764 // Count the number of active widget hosts for the process, which | 748 // Count the number of active widget hosts for the process, which |
765 // is equivalent to views using the process as of this writing. | 749 // is equivalent to views using the process as of this writing. |
766 scoped_ptr<RenderWidgetHostIterator> widgets( | 750 scoped_ptr<RenderWidgetHostIterator> widgets( |
767 RenderWidgetHost::GetRenderWidgetHosts()); | 751 RenderWidgetHost::GetRenderWidgetHosts()); |
768 while (RenderWidgetHost* widget = widgets->GetNextHost()) { | 752 while (RenderWidgetHost* widget = widgets->GetNextHost()) { |
769 if (widget->GetProcess()->GetID() == GetProcess()->GetID()) | 753 if (widget->GetProcess()->GetID() == GetProcess()->GetID()) |
770 ++views; | 754 ++views; |
(...skipping 16 matching lines...) Expand all Loading... |
787 | 771 |
788 // Log a histogram point to help us diagnose how many of those kills | 772 // Log a histogram point to help us diagnose how many of those kills |
789 // we have performed. 1 is the enum value for RendererType Normal for | 773 // we have performed. 1 is the enum value for RendererType Normal for |
790 // the histogram. | 774 // the histogram. |
791 UMA_HISTOGRAM_PERCENTAGE( | 775 UMA_HISTOGRAM_PERCENTAGE( |
792 "BrowserRenderProcessHost.ChildKillsUnresponsive", 1); | 776 "BrowserRenderProcessHost.ChildKillsUnresponsive", 1); |
793 } | 777 } |
794 } | 778 } |
795 } | 779 } |
796 | 780 |
797 // Inform the renderer that it can exit if no one else is using it. | 781 switch (rvh_state_) { |
| 782 case STATE_WAITING_FOR_UNLOAD_ACK: |
| 783 SetState(STATE_WAITING_FOR_COMMIT); |
| 784 break; |
| 785 case STATE_PENDING_SWAP_OUT: |
| 786 SetState(STATE_SWAPPED_OUT); |
| 787 break; |
| 788 case STATE_PENDING_SHUTDOWN: |
| 789 DCHECK(!pending_shutdown_on_swap_out_.is_null()); |
| 790 pending_shutdown_on_swap_out_.Run(); |
| 791 break; |
| 792 default: |
| 793 NOTREACHED(); |
| 794 } |
| 795 } |
| 796 |
| 797 void RenderViewHostImpl::WasSwappedOut( |
| 798 const base::Closure& pending_delete_on_swap_out) { |
798 Send(new ViewMsg_WasSwappedOut(GetRoutingID())); | 799 Send(new ViewMsg_WasSwappedOut(GetRoutingID())); |
| 800 if (rvh_state_ == STATE_WAITING_FOR_UNLOAD_ACK) { |
| 801 SetState(STATE_PENDING_SWAP_OUT); |
| 802 if (!instance_->active_view_count()) |
| 803 SetPendingShutdown(pending_delete_on_swap_out); |
| 804 } else if (rvh_state_ == STATE_WAITING_FOR_COMMIT) { |
| 805 SetState(STATE_SWAPPED_OUT); |
| 806 } else if (rvh_state_ == STATE_DEFAULT) { |
| 807 // When the RenderView is not live, the RenderFrameHostManager will call |
| 808 // CommitPending directly, without calling SwapOut on the old RVH. This will |
| 809 // cause WasSwappedOut to be called directly on the live old RVH. |
| 810 DCHECK(!IsRenderViewLive()); |
| 811 SetState(STATE_SWAPPED_OUT); |
| 812 } else { |
| 813 NOTREACHED(); |
| 814 } |
| 815 } |
| 816 |
| 817 void RenderViewHostImpl::SetPendingShutdown(const base::Closure& on_swap_out) { |
| 818 pending_shutdown_on_swap_out_ = on_swap_out; |
| 819 SetState(STATE_PENDING_SHUTDOWN); |
799 } | 820 } |
800 | 821 |
801 void RenderViewHostImpl::ClosePage() { | 822 void RenderViewHostImpl::ClosePage() { |
802 // Start the hang monitor in case the renderer hangs in the unload handler. | 823 SetState(STATE_WAITING_FOR_CLOSE); |
803 is_waiting_for_unload_ack_ = true; | |
804 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); | 824 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); |
805 | 825 |
806 if (IsRenderViewLive()) { | 826 if (IsRenderViewLive()) { |
807 // Since we are sending an IPC message to the renderer, increase the event | 827 // Since we are sending an IPC message to the renderer, increase the event |
808 // count to prevent the hang monitor timeout from being stopped by input | 828 // count to prevent the hang monitor timeout from being stopped by input |
809 // event acknowledgements. | 829 // event acknowledgements. |
810 increment_in_flight_event_count(); | 830 increment_in_flight_event_count(); |
811 | 831 |
812 // TODO(creis): Should this be moved to Shutdown? It may not be called for | 832 // TODO(creis): Should this be moved to Shutdown? It may not be called for |
813 // RenderViewHosts that have been swapped out. | 833 // RenderViewHosts that have been swapped out. |
814 NotificationService::current()->Notify( | 834 NotificationService::current()->Notify( |
815 NOTIFICATION_RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW, | 835 NOTIFICATION_RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW, |
816 Source<RenderViewHost>(this), | 836 Source<RenderViewHost>(this), |
817 NotificationService::NoDetails()); | 837 NotificationService::NoDetails()); |
818 | 838 |
819 Send(new ViewMsg_ClosePage(GetRoutingID())); | 839 Send(new ViewMsg_ClosePage(GetRoutingID())); |
820 } else { | 840 } else { |
821 // This RenderViewHost doesn't have a live renderer, so just skip the unload | 841 // This RenderViewHost doesn't have a live renderer, so just skip the unload |
822 // event and close the page. | 842 // event and close the page. |
823 ClosePageIgnoringUnloadEvents(); | 843 ClosePageIgnoringUnloadEvents(); |
824 } | 844 } |
825 } | 845 } |
826 | 846 |
827 void RenderViewHostImpl::ClosePageIgnoringUnloadEvents() { | 847 void RenderViewHostImpl::ClosePageIgnoringUnloadEvents() { |
828 StopHangMonitorTimeout(); | 848 StopHangMonitorTimeout(); |
829 is_waiting_for_beforeunload_ack_ = false; | 849 is_waiting_for_beforeunload_ack_ = false; |
830 is_waiting_for_unload_ack_ = false; | |
831 | 850 |
832 sudden_termination_allowed_ = true; | 851 sudden_termination_allowed_ = true; |
833 delegate_->Close(this); | 852 delegate_->Close(this); |
834 } | 853 } |
835 | 854 |
836 bool RenderViewHostImpl::HasPendingCrossSiteRequest() { | 855 bool RenderViewHostImpl::HasPendingCrossSiteRequest() { |
837 return CrossSiteRequestManager::GetInstance()->HasPendingCrossSiteRequest( | 856 return CrossSiteRequestManager::GetInstance()->HasPendingCrossSiteRequest( |
838 GetProcess()->GetID(), GetRoutingID()); | 857 GetProcess()->GetID(), GetRoutingID()); |
839 } | 858 } |
840 | 859 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 Send(new ViewMsg_ScriptEvalRequest(GetRoutingID(), frame_xpath, jscript, | 1012 Send(new ViewMsg_ScriptEvalRequest(GetRoutingID(), frame_xpath, jscript, |
994 key, true)); | 1013 key, true)); |
995 javascript_callbacks_.insert(std::make_pair(key, callback)); | 1014 javascript_callbacks_.insert(std::make_pair(key, callback)); |
996 } | 1015 } |
997 | 1016 |
998 void RenderViewHostImpl::JavaScriptDialogClosed( | 1017 void RenderViewHostImpl::JavaScriptDialogClosed( |
999 IPC::Message* reply_msg, | 1018 IPC::Message* reply_msg, |
1000 bool success, | 1019 bool success, |
1001 const base::string16& user_input) { | 1020 const base::string16& user_input) { |
1002 GetProcess()->SetIgnoreInputEvents(false); | 1021 GetProcess()->SetIgnoreInputEvents(false); |
1003 bool is_waiting = | 1022 bool is_waiting = is_waiting_for_beforeunload_ack_ || IsWaitingForUnloadACK(); |
1004 is_waiting_for_beforeunload_ack_ || is_waiting_for_unload_ack_; | |
1005 | 1023 |
1006 // If we are executing as part of (before)unload event handling, we don't | 1024 // If we are executing as part of (before)unload event handling, we don't |
1007 // want to use the regular hung_renderer_delay_ms_ if the user has agreed to | 1025 // want to use the regular hung_renderer_delay_ms_ if the user has agreed to |
1008 // leave the current page. In this case, use the regular timeout value used | 1026 // leave the current page. In this case, use the regular timeout value used |
1009 // during the (before)unload handling. | 1027 // during the (before)unload handling. |
1010 if (is_waiting) { | 1028 if (is_waiting) { |
1011 StartHangMonitorTimeout(TimeDelta::FromMilliseconds( | 1029 StartHangMonitorTimeout(TimeDelta::FromMilliseconds( |
1012 success ? kUnloadTimeoutMS : hung_renderer_delay_ms_)); | 1030 success ? kUnloadTimeoutMS : hung_renderer_delay_ms_)); |
1013 } | 1031 } |
1014 | 1032 |
1015 ViewHostMsg_RunJavaScriptMessage::WriteReplyParams(reply_msg, | 1033 ViewHostMsg_RunJavaScriptMessage::WriteReplyParams(reply_msg, |
1016 success, user_input); | 1034 success, user_input); |
1017 Send(reply_msg); | 1035 Send(reply_msg); |
1018 | 1036 |
1019 // If we are waiting for an unload or beforeunload ack and the user has | 1037 // If we are waiting for an unload or beforeunload ack and the user has |
1020 // suppressed messages, kill the tab immediately; a page that's spamming | 1038 // suppressed messages, kill the tab immediately; a page that's spamming |
1021 // alerts in onbeforeunload is presumably malicious, so there's no point in | 1039 // alerts in onbeforeunload is presumably malicious, so there's no point in |
1022 // continuing to run its script and dragging out the process. | 1040 // continuing to run its script and dragging out the process. |
1023 // This must be done after sending the reply since RenderView can't close | 1041 // This must be done after sending the reply since RenderView can't close |
1024 // correctly while waiting for a response. | 1042 // correctly while waiting for a response. |
1025 if (is_waiting && are_javascript_messages_suppressed_) | 1043 if (is_waiting && are_javascript_messages_suppressed_) |
1026 delegate_->RendererUnresponsive( | 1044 delegate_->RendererUnresponsive( |
1027 this, is_waiting_for_beforeunload_ack_, is_waiting_for_unload_ack_); | 1045 this, is_waiting_for_beforeunload_ack_, IsWaitingForUnloadACK()); |
1028 } | 1046 } |
1029 | 1047 |
1030 void RenderViewHostImpl::DragSourceEndedAt( | 1048 void RenderViewHostImpl::DragSourceEndedAt( |
1031 int client_x, int client_y, int screen_x, int screen_y, | 1049 int client_x, int client_y, int screen_x, int screen_y, |
1032 WebDragOperation operation) { | 1050 WebDragOperation operation) { |
1033 Send(new DragMsg_SourceEndedOrMoved( | 1051 Send(new DragMsg_SourceEndedOrMoved( |
1034 GetRoutingID(), | 1052 GetRoutingID(), |
1035 gfx::Point(client_x, client_y), | 1053 gfx::Point(client_x, client_y), |
1036 gfx::Point(screen_x, screen_y), | 1054 gfx::Point(screen_x, screen_y), |
1037 true, operation)); | 1055 true, operation)); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1173 | 1191 |
1174 /////////////////////////////////////////////////////////////////////////////// | 1192 /////////////////////////////////////////////////////////////////////////////// |
1175 // RenderViewHostImpl, IPC message handlers: | 1193 // RenderViewHostImpl, IPC message handlers: |
1176 | 1194 |
1177 bool RenderViewHostImpl::OnMessageReceived(const IPC::Message& msg) { | 1195 bool RenderViewHostImpl::OnMessageReceived(const IPC::Message& msg) { |
1178 if (!BrowserMessageFilter::CheckCanDispatchOnUI(msg, this)) | 1196 if (!BrowserMessageFilter::CheckCanDispatchOnUI(msg, this)) |
1179 return true; | 1197 return true; |
1180 | 1198 |
1181 // Filter out most IPC messages if this renderer is swapped out. | 1199 // Filter out most IPC messages if this renderer is swapped out. |
1182 // We still want to handle certain ACKs to keep our state consistent. | 1200 // We still want to handle certain ACKs to keep our state consistent. |
1183 if (is_swapped_out_) { | 1201 if (IsSwappedOut()) { |
1184 if (!SwappedOutMessages::CanHandleWhileSwappedOut(msg)) { | 1202 if (!SwappedOutMessages::CanHandleWhileSwappedOut(msg)) { |
1185 // If this is a synchronous message and we decided not to handle it, | 1203 // If this is a synchronous message and we decided not to handle it, |
1186 // we must send an error reply, or else the renderer will be stuck | 1204 // we must send an error reply, or else the renderer will be stuck |
1187 // and won't respond to future requests. | 1205 // and won't respond to future requests. |
1188 if (msg.is_sync()) { | 1206 if (msg.is_sync()) { |
1189 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); | 1207 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); |
1190 reply->set_reply_error(); | 1208 reply->set_reply_error(); |
1191 Send(reply); | 1209 Send(reply); |
1192 } | 1210 } |
1193 // Don't continue looking for someone to handle it. | 1211 // Don't continue looking for someone to handle it. |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1315 } | 1333 } |
1316 | 1334 |
1317 void RenderViewHostImpl::CreateNewFullscreenWidget(int route_id) { | 1335 void RenderViewHostImpl::CreateNewFullscreenWidget(int route_id) { |
1318 delegate_->CreateNewFullscreenWidget(GetProcess()->GetID(), route_id); | 1336 delegate_->CreateNewFullscreenWidget(GetProcess()->GetID(), route_id); |
1319 } | 1337 } |
1320 | 1338 |
1321 void RenderViewHostImpl::OnShowView(int route_id, | 1339 void RenderViewHostImpl::OnShowView(int route_id, |
1322 WindowOpenDisposition disposition, | 1340 WindowOpenDisposition disposition, |
1323 const gfx::Rect& initial_pos, | 1341 const gfx::Rect& initial_pos, |
1324 bool user_gesture) { | 1342 bool user_gesture) { |
1325 if (!is_swapped_out_) { | 1343 if (IsRVHStateActive(rvh_state_)) { |
1326 delegate_->ShowCreatedWindow( | 1344 delegate_->ShowCreatedWindow( |
1327 route_id, disposition, initial_pos, user_gesture); | 1345 route_id, disposition, initial_pos, user_gesture); |
1328 } | 1346 } |
1329 Send(new ViewMsg_Move_ACK(route_id)); | 1347 Send(new ViewMsg_Move_ACK(route_id)); |
1330 } | 1348 } |
1331 | 1349 |
1332 void RenderViewHostImpl::OnShowWidget(int route_id, | 1350 void RenderViewHostImpl::OnShowWidget(int route_id, |
1333 const gfx::Rect& initial_pos) { | 1351 const gfx::Rect& initial_pos) { |
1334 if (!is_swapped_out_) | 1352 if (IsRVHStateActive(rvh_state_)) |
1335 delegate_->ShowCreatedWidget(route_id, initial_pos); | 1353 delegate_->ShowCreatedWidget(route_id, initial_pos); |
1336 Send(new ViewMsg_Move_ACK(route_id)); | 1354 Send(new ViewMsg_Move_ACK(route_id)); |
1337 } | 1355 } |
1338 | 1356 |
1339 void RenderViewHostImpl::OnShowFullscreenWidget(int route_id) { | 1357 void RenderViewHostImpl::OnShowFullscreenWidget(int route_id) { |
1340 if (!is_swapped_out_) | 1358 if (IsRVHStateActive(rvh_state_)) |
1341 delegate_->ShowCreatedFullscreenWidget(route_id); | 1359 delegate_->ShowCreatedFullscreenWidget(route_id); |
1342 Send(new ViewMsg_Move_ACK(route_id)); | 1360 Send(new ViewMsg_Move_ACK(route_id)); |
1343 } | 1361 } |
1344 | 1362 |
1345 void RenderViewHostImpl::OnRenderViewReady() { | 1363 void RenderViewHostImpl::OnRenderViewReady() { |
1346 render_view_termination_status_ = base::TERMINATION_STATUS_STILL_RUNNING; | 1364 render_view_termination_status_ = base::TERMINATION_STATUS_STILL_RUNNING; |
1347 SendScreenRects(); | 1365 SendScreenRects(); |
1348 WasResized(); | 1366 WasResized(); |
1349 delegate_->RenderViewReady(this); | 1367 delegate_->RenderViewReady(this); |
1350 } | 1368 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1402 delegate_->UpdateTitle(this, page_id, title, | 1420 delegate_->UpdateTitle(this, page_id, title, |
1403 WebTextDirectionToChromeTextDirection( | 1421 WebTextDirectionToChromeTextDirection( |
1404 title_direction)); | 1422 title_direction)); |
1405 } | 1423 } |
1406 | 1424 |
1407 void RenderViewHostImpl::OnUpdateEncoding(const std::string& encoding_name) { | 1425 void RenderViewHostImpl::OnUpdateEncoding(const std::string& encoding_name) { |
1408 delegate_->UpdateEncoding(this, encoding_name); | 1426 delegate_->UpdateEncoding(this, encoding_name); |
1409 } | 1427 } |
1410 | 1428 |
1411 void RenderViewHostImpl::OnUpdateTargetURL(int32 page_id, const GURL& url) { | 1429 void RenderViewHostImpl::OnUpdateTargetURL(int32 page_id, const GURL& url) { |
1412 if (!is_swapped_out_) | 1430 if (IsRVHStateActive(rvh_state_)) |
1413 delegate_->UpdateTargetURL(page_id, url); | 1431 delegate_->UpdateTargetURL(page_id, url); |
1414 | 1432 |
1415 // Send a notification back to the renderer that we are ready to | 1433 // Send a notification back to the renderer that we are ready to |
1416 // receive more target urls. | 1434 // receive more target urls. |
1417 Send(new ViewMsg_UpdateTargetURL_ACK(GetRoutingID())); | 1435 Send(new ViewMsg_UpdateTargetURL_ACK(GetRoutingID())); |
1418 } | 1436 } |
1419 | 1437 |
1420 void RenderViewHostImpl::OnUpdateInspectorSetting( | 1438 void RenderViewHostImpl::OnUpdateInspectorSetting( |
1421 const std::string& key, const std::string& value) { | 1439 const std::string& key, const std::string& value) { |
1422 GetContentClient()->browser()->UpdateInspectorSetting( | 1440 GetContentClient()->browser()->UpdateInspectorSetting( |
1423 this, key, value); | 1441 this, key, value); |
1424 } | 1442 } |
1425 | 1443 |
1426 void RenderViewHostImpl::OnClose() { | 1444 void RenderViewHostImpl::OnClose() { |
1427 // If the renderer is telling us to close, it has already run the unload | 1445 // If the renderer is telling us to close, it has already run the unload |
1428 // events, and we can take the fast path. | 1446 // events, and we can take the fast path. |
1429 ClosePageIgnoringUnloadEvents(); | 1447 ClosePageIgnoringUnloadEvents(); |
1430 } | 1448 } |
1431 | 1449 |
1432 void RenderViewHostImpl::OnRequestMove(const gfx::Rect& pos) { | 1450 void RenderViewHostImpl::OnRequestMove(const gfx::Rect& pos) { |
1433 if (!is_swapped_out_) | 1451 if (IsRVHStateActive(rvh_state_)) |
1434 delegate_->RequestMove(pos); | 1452 delegate_->RequestMove(pos); |
1435 Send(new ViewMsg_Move_ACK(GetRoutingID())); | 1453 Send(new ViewMsg_Move_ACK(GetRoutingID())); |
1436 } | 1454 } |
1437 | 1455 |
1438 void RenderViewHostImpl::OnDidChangeLoadProgress(double load_progress) { | 1456 void RenderViewHostImpl::OnDidChangeLoadProgress(double load_progress) { |
1439 delegate_->DidChangeLoadProgress(load_progress); | 1457 delegate_->DidChangeLoadProgress(load_progress); |
1440 } | 1458 } |
1441 | 1459 |
1442 void RenderViewHostImpl::OnDidDisownOpener() { | 1460 void RenderViewHostImpl::OnDidDisownOpener() { |
1443 delegate_->DidDisownOpener(this); | 1461 delegate_->DidDisownOpener(this); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1652 | 1670 |
1653 void RenderViewHostImpl::OnShouldCloseACK( | 1671 void RenderViewHostImpl::OnShouldCloseACK( |
1654 bool proceed, | 1672 bool proceed, |
1655 const base::TimeTicks& renderer_before_unload_start_time, | 1673 const base::TimeTicks& renderer_before_unload_start_time, |
1656 const base::TimeTicks& renderer_before_unload_end_time) { | 1674 const base::TimeTicks& renderer_before_unload_end_time) { |
1657 decrement_in_flight_event_count(); | 1675 decrement_in_flight_event_count(); |
1658 StopHangMonitorTimeout(); | 1676 StopHangMonitorTimeout(); |
1659 // If this renderer navigated while the beforeunload request was in flight, we | 1677 // If this renderer navigated while the beforeunload request was in flight, we |
1660 // may have cleared this state in OnNavigate, in which case we can ignore | 1678 // may have cleared this state in OnNavigate, in which case we can ignore |
1661 // this message. | 1679 // this message. |
1662 if (!is_waiting_for_beforeunload_ack_ || is_swapped_out_) | 1680 if (!is_waiting_for_beforeunload_ack_ || rvh_state_ != STATE_DEFAULT) |
1663 return; | 1681 return; |
1664 | 1682 |
1665 is_waiting_for_beforeunload_ack_ = false; | 1683 is_waiting_for_beforeunload_ack_ = false; |
1666 | 1684 |
1667 RenderViewHostDelegate::RendererManagement* management_delegate = | 1685 RenderViewHostDelegate::RendererManagement* management_delegate = |
1668 delegate_->GetRendererManagementDelegate(); | 1686 delegate_->GetRendererManagementDelegate(); |
1669 if (management_delegate) { | 1687 if (management_delegate) { |
1670 base::TimeTicks before_unload_end_time; | 1688 base::TimeTicks before_unload_end_time; |
1671 if (!send_should_close_start_time_.is_null() && | 1689 if (!send_should_close_start_time_.is_null() && |
1672 !renderer_before_unload_start_time.is_null() && | 1690 !renderer_before_unload_start_time.is_null() && |
(...skipping 22 matching lines...) Expand all Loading... |
1695 delegate_->DidCancelLoading(); | 1713 delegate_->DidCancelLoading(); |
1696 } | 1714 } |
1697 | 1715 |
1698 void RenderViewHostImpl::OnClosePageACK() { | 1716 void RenderViewHostImpl::OnClosePageACK() { |
1699 decrement_in_flight_event_count(); | 1717 decrement_in_flight_event_count(); |
1700 ClosePageIgnoringUnloadEvents(); | 1718 ClosePageIgnoringUnloadEvents(); |
1701 } | 1719 } |
1702 | 1720 |
1703 void RenderViewHostImpl::NotifyRendererUnresponsive() { | 1721 void RenderViewHostImpl::NotifyRendererUnresponsive() { |
1704 delegate_->RendererUnresponsive( | 1722 delegate_->RendererUnresponsive( |
1705 this, is_waiting_for_beforeunload_ack_, is_waiting_for_unload_ack_); | 1723 this, is_waiting_for_beforeunload_ack_, IsWaitingForUnloadACK()); |
1706 } | 1724 } |
1707 | 1725 |
1708 void RenderViewHostImpl::NotifyRendererResponsive() { | 1726 void RenderViewHostImpl::NotifyRendererResponsive() { |
1709 delegate_->RendererResponsive(this); | 1727 delegate_->RendererResponsive(this); |
1710 } | 1728 } |
1711 | 1729 |
1712 void RenderViewHostImpl::RequestToLockMouse(bool user_gesture, | 1730 void RenderViewHostImpl::RequestToLockMouse(bool user_gesture, |
1713 bool last_unlocked_by_target) { | 1731 bool last_unlocked_by_target) { |
1714 delegate_->RequestToLockMouse(user_gesture, last_unlocked_by_target); | 1732 delegate_->RequestToLockMouse(user_gesture, last_unlocked_by_target); |
1715 } | 1733 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1800 #endif | 1818 #endif |
1801 | 1819 |
1802 void RenderViewHostImpl::SendOrientationChangeEvent(int orientation) { | 1820 void RenderViewHostImpl::SendOrientationChangeEvent(int orientation) { |
1803 Send(new ViewMsg_OrientationChangeEvent(GetRoutingID(), orientation)); | 1821 Send(new ViewMsg_OrientationChangeEvent(GetRoutingID(), orientation)); |
1804 } | 1822 } |
1805 | 1823 |
1806 void RenderViewHostImpl::ToggleSpeechInput() { | 1824 void RenderViewHostImpl::ToggleSpeechInput() { |
1807 Send(new InputTagSpeechMsg_ToggleSpeechInput(GetRoutingID())); | 1825 Send(new InputTagSpeechMsg_ToggleSpeechInput(GetRoutingID())); |
1808 } | 1826 } |
1809 | 1827 |
| 1828 bool RenderViewHostImpl::IsWaitingForUnloadACK() const { |
| 1829 return rvh_state_ == STATE_WAITING_FOR_UNLOAD_ACK || |
| 1830 rvh_state_ == STATE_WAITING_FOR_CLOSE || |
| 1831 rvh_state_ == STATE_PENDING_SHUTDOWN || |
| 1832 rvh_state_ == STATE_PENDING_SWAP_OUT; |
| 1833 } |
| 1834 |
1810 void RenderViewHostImpl::ExitFullscreen() { | 1835 void RenderViewHostImpl::ExitFullscreen() { |
1811 RejectMouseLockOrUnlockIfNecessary(); | 1836 RejectMouseLockOrUnlockIfNecessary(); |
1812 // Notify delegate_ and renderer of fullscreen state change. | 1837 // Notify delegate_ and renderer of fullscreen state change. |
1813 OnToggleFullscreen(false); | 1838 OnToggleFullscreen(false); |
1814 } | 1839 } |
1815 | 1840 |
1816 WebPreferences RenderViewHostImpl::GetWebkitPreferences() { | 1841 WebPreferences RenderViewHostImpl::GetWebkitPreferences() { |
1817 return delegate_->GetWebkitPrefs(); | 1842 return delegate_->GetWebkitPrefs(); |
1818 } | 1843 } |
1819 | 1844 |
1820 void RenderViewHostImpl::DisownOpener() { | 1845 void RenderViewHostImpl::DisownOpener() { |
1821 // This should only be called when swapped out. | 1846 // This should only be called when swapped out. |
1822 DCHECK(is_swapped_out_); | 1847 DCHECK(IsSwappedOut()); |
1823 | 1848 |
1824 Send(new ViewMsg_DisownOpener(GetRoutingID())); | 1849 Send(new ViewMsg_DisownOpener(GetRoutingID())); |
1825 } | 1850 } |
1826 | 1851 |
1827 void RenderViewHostImpl::SetAccessibilityCallbackForTesting( | 1852 void RenderViewHostImpl::SetAccessibilityCallbackForTesting( |
1828 const base::Callback<void(ui::AXEvent)>& callback) { | 1853 const base::Callback<void(ui::AXEvent)>& callback) { |
1829 accessibility_testing_callback_ = callback; | 1854 accessibility_testing_callback_ = callback; |
1830 } | 1855 } |
1831 | 1856 |
1832 void RenderViewHostImpl::UpdateWebkitPreferences(const WebPreferences& prefs) { | 1857 void RenderViewHostImpl::UpdateWebkitPreferences(const WebPreferences& prefs) { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1894 Send(new ViewMsg_PluginActionAt(GetRoutingID(), location, action)); | 1919 Send(new ViewMsg_PluginActionAt(GetRoutingID(), location, action)); |
1895 } | 1920 } |
1896 | 1921 |
1897 void RenderViewHostImpl::NotifyMoveOrResizeStarted() { | 1922 void RenderViewHostImpl::NotifyMoveOrResizeStarted() { |
1898 Send(new ViewMsg_MoveOrResizeStarted(GetRoutingID())); | 1923 Send(new ViewMsg_MoveOrResizeStarted(GetRoutingID())); |
1899 } | 1924 } |
1900 | 1925 |
1901 void RenderViewHostImpl::OnAccessibilityEvents( | 1926 void RenderViewHostImpl::OnAccessibilityEvents( |
1902 const std::vector<AccessibilityHostMsg_EventParams>& params) { | 1927 const std::vector<AccessibilityHostMsg_EventParams>& params) { |
1903 if ((accessibility_mode() & AccessibilityModeFlagPlatform) && view_ && | 1928 if ((accessibility_mode() & AccessibilityModeFlagPlatform) && view_ && |
1904 !is_swapped_out_) { | 1929 IsRVHStateActive(rvh_state_)) { |
1905 view_->CreateBrowserAccessibilityManagerIfNeeded(); | 1930 view_->CreateBrowserAccessibilityManagerIfNeeded(); |
1906 BrowserAccessibilityManager* manager = | 1931 BrowserAccessibilityManager* manager = |
1907 view_->GetBrowserAccessibilityManager(); | 1932 view_->GetBrowserAccessibilityManager(); |
1908 if (manager) | 1933 if (manager) |
1909 manager->OnAccessibilityEvents(params); | 1934 manager->OnAccessibilityEvents(params); |
1910 } | 1935 } |
1911 | 1936 |
1912 // Always send an ACK or the renderer can be in a bad state. | 1937 // Always send an ACK or the renderer can be in a bad state. |
1913 Send(new AccessibilityMsg_Events_ACK(GetRoutingID())); | 1938 Send(new AccessibilityMsg_Events_ACK(GetRoutingID())); |
1914 | 1939 |
(...skipping 11 matching lines...) Expand all Loading... |
1926 if (!ax_tree_) | 1951 if (!ax_tree_) |
1927 ax_tree_.reset(new ui::AXTree(update)); | 1952 ax_tree_.reset(new ui::AXTree(update)); |
1928 else | 1953 else |
1929 CHECK(ax_tree_->Unserialize(update)) << ax_tree_->error(); | 1954 CHECK(ax_tree_->Unserialize(update)) << ax_tree_->error(); |
1930 accessibility_testing_callback_.Run(param.event_type); | 1955 accessibility_testing_callback_.Run(param.event_type); |
1931 } | 1956 } |
1932 } | 1957 } |
1933 | 1958 |
1934 void RenderViewHostImpl::OnAccessibilityLocationChanges( | 1959 void RenderViewHostImpl::OnAccessibilityLocationChanges( |
1935 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { | 1960 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { |
1936 if (view_ && !is_swapped_out_) { | 1961 if (view_ && IsRVHStateActive(rvh_state_)) { |
1937 view_->CreateBrowserAccessibilityManagerIfNeeded(); | 1962 view_->CreateBrowserAccessibilityManagerIfNeeded(); |
1938 BrowserAccessibilityManager* manager = | 1963 BrowserAccessibilityManager* manager = |
1939 view_->GetBrowserAccessibilityManager(); | 1964 view_->GetBrowserAccessibilityManager(); |
1940 if (manager) | 1965 if (manager) |
1941 manager->OnLocationChanges(params); | 1966 manager->OnLocationChanges(params); |
1942 } | 1967 } |
1943 } | 1968 } |
1944 | 1969 |
1945 void RenderViewHostImpl::OnScriptEvalResponse(int id, | 1970 void RenderViewHostImpl::OnScriptEvalResponse(int id, |
1946 const base::ListValue& result) { | 1971 const base::ListValue& result) { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2022 params.item_height, | 2047 params.item_height, |
2023 params.item_font_size, | 2048 params.item_font_size, |
2024 params.selected_item, | 2049 params.selected_item, |
2025 params.popup_items, | 2050 params.popup_items, |
2026 params.right_aligned, | 2051 params.right_aligned, |
2027 params.allow_multiple_selection); | 2052 params.allow_multiple_selection); |
2028 } | 2053 } |
2029 } | 2054 } |
2030 #endif | 2055 #endif |
2031 | 2056 |
2032 void RenderViewHostImpl::SetSwappedOut(bool is_swapped_out) { | 2057 void RenderViewHostImpl::SetState(RenderViewHostImplState rvh_state) { |
2033 // We update the number of RenderViews in a SiteInstance when the | 2058 // We update the number of RenderViews in a SiteInstance when the |
2034 // swapped out status of this RenderView gets flipped. | 2059 // swapped out status of this RenderView gets flipped to/from live. |
2035 if (is_swapped_out_ && !is_swapped_out) | 2060 if (!IsRVHStateActive(rvh_state_) && IsRVHStateActive(rvh_state)) |
2036 instance_->increment_active_view_count(); | 2061 instance_->increment_active_view_count(); |
2037 else if (!is_swapped_out_ && is_swapped_out) | 2062 else if (IsRVHStateActive(rvh_state_) && !IsRVHStateActive(rvh_state)) |
2038 instance_->decrement_active_view_count(); | 2063 instance_->decrement_active_view_count(); |
2039 | 2064 |
2040 is_swapped_out_ = is_swapped_out; | 2065 // Whenever we change the RVH state to and from live or swapped out state, we |
| 2066 // should not be waiting for beforeunload or unload acks. We clear them here |
| 2067 // to be safe, since they can cause navigations to be ignored in OnNavigate. |
| 2068 if (rvh_state == STATE_DEFAULT || |
| 2069 rvh_state == STATE_SWAPPED_OUT || |
| 2070 rvh_state_ == STATE_DEFAULT || |
| 2071 rvh_state_ == STATE_SWAPPED_OUT) { |
| 2072 is_waiting_for_beforeunload_ack_ = false; |
| 2073 } |
| 2074 rvh_state_ = rvh_state; |
2041 | 2075 |
2042 // Whenever we change swap out state, we should not be waiting for | |
2043 // beforeunload or unload acks. We clear them here to be safe, since they | |
2044 // can cause navigations to be ignored in OnNavigate. | |
2045 is_waiting_for_beforeunload_ack_ = false; | |
2046 is_waiting_for_unload_ack_ = false; | |
2047 has_timed_out_on_unload_ = false; | |
2048 } | 2076 } |
2049 | 2077 |
2050 bool RenderViewHostImpl::CanAccessFilesOfPageState( | 2078 bool RenderViewHostImpl::CanAccessFilesOfPageState( |
2051 const PageState& state) const { | 2079 const PageState& state) const { |
2052 ChildProcessSecurityPolicyImpl* policy = | 2080 ChildProcessSecurityPolicyImpl* policy = |
2053 ChildProcessSecurityPolicyImpl::GetInstance(); | 2081 ChildProcessSecurityPolicyImpl::GetInstance(); |
2054 | 2082 |
2055 const std::vector<base::FilePath>& file_paths = state.GetReferencedFiles(); | 2083 const std::vector<base::FilePath>& file_paths = state.GetReferencedFiles(); |
2056 for (std::vector<base::FilePath>::const_iterator file = file_paths.begin(); | 2084 for (std::vector<base::FilePath>::const_iterator file = file_paths.begin(); |
2057 file != file_paths.end(); ++file) { | 2085 file != file_paths.end(); ++file) { |
2058 if (!policy->CanReadFile(GetProcess()->GetID(), *file)) | 2086 if (!policy->CanReadFile(GetProcess()->GetID(), *file)) |
2059 return false; | 2087 return false; |
2060 } | 2088 } |
2061 return true; | 2089 return true; |
2062 } | 2090 } |
2063 | 2091 |
2064 void RenderViewHostImpl::AttachToFrameTree() { | 2092 void RenderViewHostImpl::AttachToFrameTree() { |
2065 FrameTree* frame_tree = delegate_->GetFrameTree(); | 2093 FrameTree* frame_tree = delegate_->GetFrameTree(); |
2066 | 2094 |
2067 frame_tree->ResetForMainFrameSwap(); | 2095 frame_tree->ResetForMainFrameSwap(); |
2068 } | 2096 } |
2069 | 2097 |
2070 } // namespace content | 2098 } // namespace content |
OLD | NEW |