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

Unified Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 1799163002: Remove swapped out state from RenderFrameHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/frame_host/render_frame_host_impl.cc
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc
index 10615f42110f563377626bbb59613d51d09357ba..ecd65fa80fe3de571b9521792da109c4e4c88527 100644
--- a/content/browser/frame_host/render_frame_host_impl.cc
+++ b/content/browser/frame_host/render_frame_host_impl.cc
@@ -195,6 +195,7 @@ RenderFrameHostImpl::RenderFrameHostImpl(SiteInstance* site_instance,
frame_tree_node_(frame_tree_node),
render_widget_host_(nullptr),
routing_id_(routing_id),
+ rfh_state_(STATE_DEFAULT),
render_frame_created_(false),
navigations_suspended_(false),
is_waiting_for_beforeunload_ack_(false),
@@ -209,7 +210,6 @@ RenderFrameHostImpl::RenderFrameHostImpl(SiteInstance* site_instance,
pending_web_ui_type_(WebUI::kNoWebUI),
should_reuse_web_ui_(false),
weak_ptr_factory_(this) {
- bool is_swapped_out = !!(flags & CREATE_RF_SWAPPED_OUT);
bool hidden = !!(flags & CREATE_RF_HIDDEN);
frame_tree_->AddRenderViewHostRef(render_view_host_);
GetProcess()->AddRoute(routing_id_, this);
@@ -217,13 +217,7 @@ RenderFrameHostImpl::RenderFrameHostImpl(SiteInstance* site_instance,
RenderFrameHostID(GetProcess()->GetID(), routing_id_),
this));
site_instance_->AddObserver(this);
-
- if (is_swapped_out) {
- rfh_state_ = STATE_SWAPPED_OUT;
- } else {
- rfh_state_ = STATE_DEFAULT;
- GetSiteInstance()->IncrementActiveFrameCount();
- }
+ GetSiteInstance()->IncrementActiveFrameCount();
// New child frames should inherit the nav_entry_id of their parent.
if (frame_tree_node_->parent()) {
@@ -472,23 +466,6 @@ bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) {
if (!render_frame_created_)
return false;
- // Filter out most IPC messages if this frame is swapped out.
Charlie Reis 2016/03/14 20:12:57 I am so excited about removing this. :)
nasko 2016/03/14 21:32:30 Same here :).
- // We still want to handle certain ACKs to keep our state consistent.
- if (is_swapped_out()) {
- if (!SwappedOutMessages::CanHandleWhileSwappedOut(msg)) {
- // If this is a synchronous message and we decided not to handle it,
- // we must send an error reply, or else the renderer will be stuck
- // and won't respond to future requests.
- if (msg.is_sync()) {
- IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg);
- reply->set_reply_error();
- Send(reply);
- }
- // Don't continue looking for someone to handle it.
- return true;
- }
- }
-
// This message map is for handling internal IPC messages which should not
// be dispatched to other objects.
bool handled = true;
@@ -1321,11 +1298,7 @@ void RenderFrameHostImpl::OnRenderProcessGone(int status, int exit_code) {
// Reset frame tree state associated with this process. This must happen
// before RenderViewTerminated because observers expect the subframes of any
// affected frames to be cleared first.
- // Note: When a RenderFrameHost is swapped out there is a different one
- // which is the current host. In this case, the FrameTreeNode state must
- // not be reset.
- if (!is_swapped_out())
- frame_tree_node_->ResetForNewProcess();
+ frame_tree_node_->ResetForNewProcess();
// Reset state for the current RenderFrameHost once the FrameTreeNode has been
// reset.
@@ -1367,8 +1340,7 @@ void RenderFrameHostImpl::OnSwappedOut() {
return;
}
- // If this RFH wasn't pending deletion, then it is now swapped out.
- SetState(RenderFrameHostImpl::STATE_SWAPPED_OUT);
+ CHECK(false);
Charlie Reis 2016/03/14 20:12:57 Might be clearer if we CHECK the return value of D
nasko 2016/03/14 21:32:30 Good idea. Done, but keeping a variable around to
}
void RenderFrameHostImpl::OnContextMenu(const ContextMenuParams& params) {
@@ -1893,33 +1865,24 @@ void RenderFrameHostImpl::RegisterMojoServices() {
}
void RenderFrameHostImpl::SetState(RenderFrameHostImplState rfh_state) {
- // Only main frames should be swapped out and retained inside a proxy host.
- if (rfh_state == STATE_SWAPPED_OUT)
- CHECK(!GetParent());
-
- // We update the number of RenderFrameHosts in a SiteInstance when the swapped
- // out status of a RenderFrameHost gets flipped to/from active.
+ // We update the number of RenderFrameHosts in a SiteInstance when the status
+ // of a RenderFrameHost gets flipped to/from active.
Charlie Reis 2016/03/14 20:12:57 Is it even possible for the state to go from inact
nasko 2016/03/14 21:32:30 Done.
if (!IsRFHStateActive(rfh_state_) && IsRFHStateActive(rfh_state))
GetSiteInstance()->IncrementActiveFrameCount();
else if (IsRFHStateActive(rfh_state_) && !IsRFHStateActive(rfh_state))
GetSiteInstance()->DecrementActiveFrameCount();
- // The active and swapped out state of the RVH is determined by its main
- // frame, since subframes should have their own widgets.
- if (frame_tree_node_->IsMainFrame()) {
+ // The active state of the RVH is determined by its main frame, since
+ // subframes should have their own widgets.
+ if (frame_tree_node_->IsMainFrame())
render_view_host_->set_is_active(IsRFHStateActive(rfh_state));
- render_view_host_->set_is_swapped_out(rfh_state == STATE_SWAPPED_OUT);
- }
- // Whenever we change the RFH state to and from active or swapped out state,
- // we should not be waiting for beforeunload or close acks. We clear them
- // here to be safe, since they can cause navigations to be ignored in
+ // Whenever we change the RFH state to and from active state, we should not be
+ // waiting for beforeunload or close acks. We clear them here to be safe,
+ // since they can cause navigations to be ignored in
// OnDidCommitProvisionalLoad.
// TODO(creis): Move is_waiting_for_beforeunload_ack_ into the state machine.
- if (rfh_state == STATE_DEFAULT ||
- rfh_state == STATE_SWAPPED_OUT ||
- rfh_state_ == STATE_DEFAULT ||
- rfh_state_ == STATE_SWAPPED_OUT) {
+ if (rfh_state == STATE_DEFAULT || rfh_state_ == STATE_DEFAULT) {
if (is_waiting_for_beforeunload_ack_) {
is_waiting_for_beforeunload_ack_ = false;
render_view_host_->GetWidget()->decrement_in_flight_event_count();

Powered by Google App Engine
This is Rietveld 408576698