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

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: Rebase to get Android build fix 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 RenderWidgetHostDelegate* widget_delegate, 161 RenderWidgetHostDelegate* widget_delegate,
162 int routing_id, 162 int routing_id,
163 int main_frame_routing_id, 163 int main_frame_routing_id,
164 bool swapped_out, 164 bool swapped_out,
165 SessionStorageNamespace* session_storage) 165 SessionStorageNamespace* session_storage)
166 : RenderWidgetHostImpl(widget_delegate, instance->GetProcess(), routing_id), 166 : RenderWidgetHostImpl(widget_delegate, instance->GetProcess(), routing_id),
167 delegate_(delegate), 167 delegate_(delegate),
168 instance_(static_cast<SiteInstanceImpl*>(instance)), 168 instance_(static_cast<SiteInstanceImpl*>(instance)),
169 waiting_for_drag_context_response_(false), 169 waiting_for_drag_context_response_(false),
170 enabled_bindings_(0), 170 enabled_bindings_(0),
171 pending_request_id_(-1),
172 navigations_suspended_(false), 171 navigations_suspended_(false),
173 suspended_nav_params_(NULL), 172 suspended_nav_params_(NULL),
174 has_accessed_initial_document_(false), 173 has_accessed_initial_document_(false),
175 is_swapped_out_(swapped_out), 174 is_swapped_out_(swapped_out),
176 is_subframe_(false), 175 is_subframe_(false),
177 main_frame_id_(-1), 176 main_frame_id_(-1),
178 run_modal_reply_msg_(NULL), 177 run_modal_reply_msg_(NULL),
179 run_modal_opener_id_(MSG_ROUTING_NONE), 178 run_modal_opener_id_(MSG_ROUTING_NONE),
180 is_waiting_for_beforeunload_ack_(false), 179 is_waiting_for_beforeunload_ack_(false),
181 is_waiting_for_unload_ack_(false), 180 is_waiting_for_unload_ack_(false),
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 unload_ack_is_for_cross_site_transition_ = for_cross_site_transition; 423 unload_ack_is_for_cross_site_transition_ = for_cross_site_transition;
425 // Increment the in-flight event count, to ensure that input events won't 424 // Increment the in-flight event count, to ensure that input events won't
426 // cancel the timeout timer. 425 // cancel the timeout timer.
427 increment_in_flight_event_count(); 426 increment_in_flight_event_count();
428 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); 427 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS));
429 send_should_close_start_time_ = base::TimeTicks::Now(); 428 send_should_close_start_time_ = base::TimeTicks::Now();
430 Send(new ViewMsg_ShouldClose(GetRoutingID())); 429 Send(new ViewMsg_ShouldClose(GetRoutingID()));
431 } 430 }
432 } 431 }
433 432
434 void RenderViewHostImpl::SwapOut(int new_render_process_host_id, 433 void RenderViewHostImpl::SwapOut() {
435 int new_request_id) {
436 // This will be set back to false in OnSwapOutACK, just before we replace 434 // This will be set back to false in OnSwapOutACK, just before we replace
437 // this RVH with the pending RVH. 435 // this RVH with the pending RVH.
438 is_waiting_for_unload_ack_ = true; 436 is_waiting_for_unload_ack_ = true;
439 // Start the hang monitor in case the renderer hangs in the unload handler. 437 // Start the hang monitor in case the renderer hangs in the unload handler.
440 // Increment the in-flight event count, to ensure that input events won't 438 // Increment the in-flight event count, to ensure that input events won't
441 // cancel the timeout timer. 439 // cancel the timeout timer.
442 increment_in_flight_event_count(); 440 increment_in_flight_event_count();
443 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); 441 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS));
444 442
445 ViewMsg_SwapOut_Params params;
446 params.closing_process_id = GetProcess()->GetID();
447 params.closing_route_id = GetRoutingID();
448 params.new_render_process_host_id = new_render_process_host_id;
449 params.new_request_id = new_request_id;
450 if (IsRenderViewLive()) { 443 if (IsRenderViewLive()) {
451 Send(new ViewMsg_SwapOut(GetRoutingID(), params)); 444 Send(new ViewMsg_SwapOut(GetRoutingID()));
452 } else { 445 } else {
453 // This RenderViewHost doesn't have a live renderer, so just skip the unload 446 // This RenderViewHost doesn't have a live renderer, so just skip the unload
454 // event. We must notify the ResourceDispatcherHost on the IO thread, 447 // event.
455 // which we will do through the RenderProcessHost's widget helper. 448 OnSwappedOut(true);
456 GetProcess()->SimulateSwapOutACK(params);
457 } 449 }
458 } 450 }
459 451
460 void RenderViewHostImpl::OnSwapOutACK(bool timed_out) { 452 void RenderViewHostImpl::OnSwapOutACK() {
453 OnSwappedOut(false);
454 }
455
456 void RenderViewHostImpl::OnSwappedOut(bool timed_out) {
461 // Stop the hang monitor now that the unload handler has finished. 457 // Stop the hang monitor now that the unload handler has finished.
462 decrement_in_flight_event_count(); 458 decrement_in_flight_event_count();
463 StopHangMonitorTimeout(); 459 StopHangMonitorTimeout();
464 is_waiting_for_unload_ack_ = false; 460 is_waiting_for_unload_ack_ = false;
465 has_timed_out_on_unload_ = timed_out; 461 has_timed_out_on_unload_ = timed_out;
466 delegate_->SwappedOut(this); 462 delegate_->SwappedOut(this);
467 } 463 }
468 464
469 void RenderViewHostImpl::WasSwappedOut() { 465 void RenderViewHostImpl::WasSwappedOut() {
470 // Don't bother reporting hung state anymore. 466 // Don't bother reporting hung state anymore.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 550
555 void RenderViewHostImpl::ClosePageIgnoringUnloadEvents() { 551 void RenderViewHostImpl::ClosePageIgnoringUnloadEvents() {
556 StopHangMonitorTimeout(); 552 StopHangMonitorTimeout();
557 is_waiting_for_beforeunload_ack_ = false; 553 is_waiting_for_beforeunload_ack_ = false;
558 is_waiting_for_unload_ack_ = false; 554 is_waiting_for_unload_ack_ = false;
559 555
560 sudden_termination_allowed_ = true; 556 sudden_termination_allowed_ = true;
561 delegate_->Close(this); 557 delegate_->Close(this);
562 } 558 }
563 559
564 void RenderViewHostImpl::SetHasPendingCrossSiteRequest(bool has_pending_request, 560 bool RenderViewHostImpl::HasPendingCrossSiteRequest() {
565 int request_id) { 561 return CrossSiteRequestManager::GetInstance()->HasPendingCrossSiteRequest(
562 GetProcess()->GetID(), GetRoutingID());
563 }
564
565 void RenderViewHostImpl::SetHasPendingCrossSiteRequest(
566 bool has_pending_request) {
566 CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest( 567 CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest(
567 GetProcess()->GetID(), GetRoutingID(), has_pending_request); 568 GetProcess()->GetID(), GetRoutingID(), has_pending_request);
568 pending_request_id_ = request_id;
569 }
570
571 int RenderViewHostImpl::GetPendingRequestId() {
572 return pending_request_id_;
573 } 569 }
574 570
575 #if defined(OS_ANDROID) 571 #if defined(OS_ANDROID)
576 void RenderViewHostImpl::ActivateNearestFindResult(int request_id, 572 void RenderViewHostImpl::ActivateNearestFindResult(int request_id,
577 float x, 573 float x,
578 float y) { 574 float y) {
579 Send(new InputMsg_ActivateNearestFindResult(GetRoutingID(), 575 Send(new InputMsg_ActivateNearestFindResult(GetRoutingID(),
580 request_id, x, y)); 576 request_id, x, y));
581 } 577 }
582 578
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunBeforeUnloadConfirm, 975 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunBeforeUnloadConfirm,
980 OnRunBeforeUnloadConfirm) 976 OnRunBeforeUnloadConfirm)
981 IPC_MESSAGE_HANDLER(DragHostMsg_StartDragging, OnStartDragging) 977 IPC_MESSAGE_HANDLER(DragHostMsg_StartDragging, OnStartDragging)
982 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) 978 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor)
983 IPC_MESSAGE_HANDLER(DragHostMsg_TargetDrop_ACK, OnTargetDropACK) 979 IPC_MESSAGE_HANDLER(DragHostMsg_TargetDrop_ACK, OnTargetDropACK)
984 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) 980 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus)
985 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged) 981 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged)
986 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole) 982 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole)
987 IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnShouldCloseACK) 983 IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnShouldCloseACK)
988 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK) 984 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK)
985 IPC_MESSAGE_HANDLER(ViewHostMsg_SwapOut_ACK, OnSwapOutACK)
989 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnSelectionChanged) 986 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnSelectionChanged)
990 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionBoundsChanged, 987 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionBoundsChanged,
991 OnSelectionBoundsChanged) 988 OnSelectionBoundsChanged)
992 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) 989 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse)
993 IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL) 990 IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL)
994 IPC_MESSAGE_HANDLER(ViewHostMsg_MediaNotification, OnMediaNotification) 991 IPC_MESSAGE_HANDLER(ViewHostMsg_MediaNotification, OnMediaNotification)
995 IPC_MESSAGE_HANDLER(ViewHostMsg_GetWindowSnapshot, OnGetWindowSnapshot) 992 IPC_MESSAGE_HANDLER(ViewHostMsg_GetWindowSnapshot, OnGetWindowSnapshot)
996 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_RequestPermission, 993 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_RequestPermission,
997 OnRequestDesktopNotificationPermission) 994 OnRequestDesktopNotificationPermission)
998 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Show, 995 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Show,
(...skipping 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2104 const std::vector<base::FilePath>& file_paths = state.GetReferencedFiles(); 2101 const std::vector<base::FilePath>& file_paths = state.GetReferencedFiles();
2105 for (std::vector<base::FilePath>::const_iterator file = file_paths.begin(); 2102 for (std::vector<base::FilePath>::const_iterator file = file_paths.begin();
2106 file != file_paths.end(); ++file) { 2103 file != file_paths.end(); ++file) {
2107 if (!policy->CanReadFile(GetProcess()->GetID(), *file)) 2104 if (!policy->CanReadFile(GetProcess()->GetID(), *file))
2108 return false; 2105 return false;
2109 } 2106 }
2110 return true; 2107 return true;
2111 } 2108 }
2112 2109
2113 } // namespace content 2110 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_view_host_impl.h ('k') | content/browser/renderer_host/render_view_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698