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

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

Issue 15682009: Eliminate SwapOut message parameters, keeping state in RVHM instead. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move pending_nav_params_ to RVHM Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 RenderWidgetHostDelegate* widget_delegate, 160 RenderWidgetHostDelegate* widget_delegate,
161 int routing_id, 161 int routing_id,
162 int main_frame_routing_id, 162 int main_frame_routing_id,
163 bool swapped_out, 163 bool swapped_out,
164 SessionStorageNamespace* session_storage) 164 SessionStorageNamespace* session_storage)
165 : RenderWidgetHostImpl(widget_delegate, instance->GetProcess(), routing_id), 165 : RenderWidgetHostImpl(widget_delegate, instance->GetProcess(), routing_id),
166 delegate_(delegate), 166 delegate_(delegate),
167 instance_(static_cast<SiteInstanceImpl*>(instance)), 167 instance_(static_cast<SiteInstanceImpl*>(instance)),
168 waiting_for_drag_context_response_(false), 168 waiting_for_drag_context_response_(false),
169 enabled_bindings_(0), 169 enabled_bindings_(0),
170 pending_request_id_(-1),
171 navigations_suspended_(false), 170 navigations_suspended_(false),
172 suspended_nav_params_(NULL), 171 suspended_nav_params_(NULL),
173 has_accessed_initial_document_(false), 172 has_accessed_initial_document_(false),
174 is_swapped_out_(swapped_out), 173 is_swapped_out_(swapped_out),
175 is_subframe_(false), 174 is_subframe_(false),
176 main_frame_id_(-1), 175 main_frame_id_(-1),
177 run_modal_reply_msg_(NULL), 176 run_modal_reply_msg_(NULL),
178 run_modal_opener_id_(MSG_ROUTING_NONE), 177 run_modal_opener_id_(MSG_ROUTING_NONE),
179 is_waiting_for_beforeunload_ack_(false), 178 is_waiting_for_beforeunload_ack_(false),
180 is_waiting_for_unload_ack_(false), 179 is_waiting_for_unload_ack_(false),
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 unload_ack_is_for_cross_site_transition_ = for_cross_site_transition; 420 unload_ack_is_for_cross_site_transition_ = for_cross_site_transition;
422 // Increment the in-flight event count, to ensure that input events won't 421 // Increment the in-flight event count, to ensure that input events won't
423 // cancel the timeout timer. 422 // cancel the timeout timer.
424 increment_in_flight_event_count(); 423 increment_in_flight_event_count();
425 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); 424 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS));
426 send_should_close_start_time_ = base::TimeTicks::Now(); 425 send_should_close_start_time_ = base::TimeTicks::Now();
427 Send(new ViewMsg_ShouldClose(GetRoutingID())); 426 Send(new ViewMsg_ShouldClose(GetRoutingID()));
428 } 427 }
429 } 428 }
430 429
431 void RenderViewHostImpl::SwapOut(int new_render_process_host_id, 430 void RenderViewHostImpl::SwapOut() {
432 int new_request_id) {
433 // This will be set back to false in OnSwapOutACK, just before we replace 431 // This will be set back to false in OnSwapOutACK, just before we replace
434 // this RVH with the pending RVH. 432 // this RVH with the pending RVH.
435 is_waiting_for_unload_ack_ = true; 433 is_waiting_for_unload_ack_ = true;
436 // Start the hang monitor in case the renderer hangs in the unload handler. 434 // Start the hang monitor in case the renderer hangs in the unload handler.
437 // Increment the in-flight event count, to ensure that input events won't 435 // Increment the in-flight event count, to ensure that input events won't
438 // cancel the timeout timer. 436 // cancel the timeout timer.
439 increment_in_flight_event_count(); 437 increment_in_flight_event_count();
440 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); 438 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS));
441 439
442 ViewMsg_SwapOut_Params params;
443 params.closing_process_id = GetProcess()->GetID();
444 params.closing_route_id = GetRoutingID();
445 params.new_render_process_host_id = new_render_process_host_id;
446 params.new_request_id = new_request_id;
447 if (IsRenderViewLive()) { 440 if (IsRenderViewLive()) {
448 Send(new ViewMsg_SwapOut(GetRoutingID(), params)); 441 Send(new ViewMsg_SwapOut(GetRoutingID()));
449 } else { 442 } else {
450 // This RenderViewHost doesn't have a live renderer, so just skip the unload 443 // This RenderViewHost doesn't have a live renderer, so just skip the unload
451 // event. We must notify the ResourceDispatcherHost on the IO thread, 444 // event.
452 // which we will do through the RenderProcessHost's widget helper. 445 OnSwappedOut(true);
453 GetProcess()->SimulateSwapOutACK(params);
454 } 446 }
455 } 447 }
456 448
457 void RenderViewHostImpl::OnSwapOutACK(bool timed_out) { 449 void RenderViewHostImpl::OnSwapOutACK() {
450 OnSwappedOut(false);
451 }
452
453 void RenderViewHostImpl::OnSwappedOut(bool timed_out) {
458 // Stop the hang monitor now that the unload handler has finished. 454 // Stop the hang monitor now that the unload handler has finished.
459 decrement_in_flight_event_count(); 455 decrement_in_flight_event_count();
460 StopHangMonitorTimeout(); 456 StopHangMonitorTimeout();
461 is_waiting_for_unload_ack_ = false; 457 is_waiting_for_unload_ack_ = false;
462 has_timed_out_on_unload_ = timed_out; 458 has_timed_out_on_unload_ = timed_out;
463 delegate_->SwappedOut(this); 459 delegate_->SwappedOut(this);
464 } 460 }
465 461
466 void RenderViewHostImpl::WasSwappedOut() { 462 void RenderViewHostImpl::WasSwappedOut() {
467 // Don't bother reporting hung state anymore. 463 // Don't bother reporting hung state anymore.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 547
552 void RenderViewHostImpl::ClosePageIgnoringUnloadEvents() { 548 void RenderViewHostImpl::ClosePageIgnoringUnloadEvents() {
553 StopHangMonitorTimeout(); 549 StopHangMonitorTimeout();
554 is_waiting_for_beforeunload_ack_ = false; 550 is_waiting_for_beforeunload_ack_ = false;
555 is_waiting_for_unload_ack_ = false; 551 is_waiting_for_unload_ack_ = false;
556 552
557 sudden_termination_allowed_ = true; 553 sudden_termination_allowed_ = true;
558 delegate_->Close(this); 554 delegate_->Close(this);
559 } 555 }
560 556
561 void RenderViewHostImpl::SetHasPendingCrossSiteRequest(bool has_pending_request, 557 bool RenderViewHostImpl::HasPendingCrossSiteRequest() {
562 int request_id) { 558 return CrossSiteRequestManager::GetInstance()->HasPendingCrossSiteRequest(
559 GetProcess()->GetID(), GetRoutingID());
560 }
561
562 void RenderViewHostImpl::SetHasPendingCrossSiteRequest(
563 bool has_pending_request) {
563 CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest( 564 CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest(
564 GetProcess()->GetID(), GetRoutingID(), has_pending_request); 565 GetProcess()->GetID(), GetRoutingID(), has_pending_request);
565 pending_request_id_ = request_id;
566 }
567
568 int RenderViewHostImpl::GetPendingRequestId() {
569 return pending_request_id_;
570 } 566 }
571 567
572 #if defined(OS_ANDROID) 568 #if defined(OS_ANDROID)
573 void RenderViewHostImpl::ActivateNearestFindResult(int request_id, 569 void RenderViewHostImpl::ActivateNearestFindResult(int request_id,
574 float x, 570 float x,
575 float y) { 571 float y) {
576 Send(new InputMsg_ActivateNearestFindResult(GetRoutingID(), 572 Send(new InputMsg_ActivateNearestFindResult(GetRoutingID(),
577 request_id, x, y)); 573 request_id, x, y));
578 } 574 }
579 575
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunBeforeUnloadConfirm, 972 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunBeforeUnloadConfirm,
977 OnRunBeforeUnloadConfirm) 973 OnRunBeforeUnloadConfirm)
978 IPC_MESSAGE_HANDLER(DragHostMsg_StartDragging, OnStartDragging) 974 IPC_MESSAGE_HANDLER(DragHostMsg_StartDragging, OnStartDragging)
979 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) 975 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor)
980 IPC_MESSAGE_HANDLER(DragHostMsg_TargetDrop_ACK, OnTargetDropACK) 976 IPC_MESSAGE_HANDLER(DragHostMsg_TargetDrop_ACK, OnTargetDropACK)
981 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) 977 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus)
982 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged) 978 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged)
983 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole) 979 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole)
984 IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnShouldCloseACK) 980 IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnShouldCloseACK)
985 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK) 981 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK)
982 IPC_MESSAGE_HANDLER(ViewHostMsg_SwapOut_ACK, OnSwapOutACK)
986 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnSelectionChanged) 983 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnSelectionChanged)
987 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionBoundsChanged, 984 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionBoundsChanged,
988 OnSelectionBoundsChanged) 985 OnSelectionBoundsChanged)
989 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) 986 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse)
990 IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL) 987 IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL)
991 IPC_MESSAGE_HANDLER(ViewHostMsg_MediaNotification, OnMediaNotification) 988 IPC_MESSAGE_HANDLER(ViewHostMsg_MediaNotification, OnMediaNotification)
992 IPC_MESSAGE_HANDLER(ViewHostMsg_GetWindowSnapshot, OnGetWindowSnapshot) 989 IPC_MESSAGE_HANDLER(ViewHostMsg_GetWindowSnapshot, OnGetWindowSnapshot)
993 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_RequestPermission, 990 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_RequestPermission,
994 OnRequestDesktopNotificationPermission) 991 OnRequestDesktopNotificationPermission)
995 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Show, 992 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Show,
(...skipping 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2101 const std::vector<base::FilePath>& file_paths = state.GetReferencedFiles(); 2098 const std::vector<base::FilePath>& file_paths = state.GetReferencedFiles();
2102 for (std::vector<base::FilePath>::const_iterator file = file_paths.begin(); 2099 for (std::vector<base::FilePath>::const_iterator file = file_paths.begin();
2103 file != file_paths.end(); ++file) { 2100 file != file_paths.end(); ++file) {
2104 if (!policy->CanReadFile(GetProcess()->GetID(), *file)) 2101 if (!policy->CanReadFile(GetProcess()->GetID(), *file))
2105 return false; 2102 return false;
2106 } 2103 }
2107 return true; 2104 return true;
2108 } 2105 }
2109 2106
2110 } // namespace content 2107 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698