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

Side by Side Diff: content/browser/frame_host/render_frame_host_manager.cc

Issue 109653014: Allow RenderFrames to swap out for subframe navigations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Nasko's comments Created 6 years, 12 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
« no previous file with comments | « content/browser/frame_host/render_frame_host_manager.h ('k') | content/common/frame_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/frame_host/render_frame_host_manager.h" 5 #include "content/browser/frame_host/render_frame_host_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 // in this case because it took too long. 247 // in this case because it took too long.
248 if (pending_render_frame_host_->render_view_host()-> 248 if (pending_render_frame_host_->render_view_host()->
249 are_navigations_suspended()) { 249 are_navigations_suspended()) {
250 pending_render_frame_host_->render_view_host()->SetNavigationsSuspended( 250 pending_render_frame_host_->render_view_host()->SetNavigationsSuspended(
251 false, base::TimeTicks::Now()); 251 false, base::TimeTicks::Now());
252 } 252 }
253 } 253 }
254 return false; 254 return false;
255 } 255 }
256 256
257 // TODO(creis): This should take in a RenderFrameHost. 257 // TODO(creis): Remove this in favor of SwappedOutFrame.
258 void RenderFrameHostManager::SwappedOut(RenderViewHost* render_view_host) { 258 void RenderFrameHostManager::SwappedOut(RenderViewHost* render_view_host) {
259 // Make sure this is from our current RVH, and that we have a pending 259 // Make sure this is from our current RVH, and that we have a pending
260 // navigation from OnCrossSiteResponse. (There may be no pending navigation 260 // navigation from OnCrossSiteResponse. (There may be no pending navigation
261 // for data URLs that don't make network requests, for example.) If not, 261 // for data URLs that don't make network requests, for example.) If not,
262 // just return early and ignore. 262 // just return early and ignore.
263 if (render_view_host != render_frame_host_->render_view_host() || 263 if (render_view_host != render_frame_host_->render_view_host() ||
264 !pending_nav_params_.get()) { 264 !pending_nav_params_.get()) {
265 pending_nav_params_.reset(); 265 pending_nav_params_.reset();
266 return; 266 return;
267 } 267 }
(...skipping 26 matching lines...) Expand all
294 } else if (pending_render_frame_host_) { 294 } else if (pending_render_frame_host_) {
295 RenderProcessHostImpl* pending_process = 295 RenderProcessHostImpl* pending_process =
296 static_cast<RenderProcessHostImpl*>( 296 static_cast<RenderProcessHostImpl*>(
297 pending_render_frame_host_->GetProcess()); 297 pending_render_frame_host_->GetProcess());
298 pending_process->ResumeDeferredNavigation( 298 pending_process->ResumeDeferredNavigation(
299 pending_nav_params_->global_request_id); 299 pending_nav_params_->global_request_id);
300 } 300 }
301 pending_nav_params_.reset(); 301 pending_nav_params_.reset();
302 } 302 }
303 303
304 void RenderFrameHostManager::SwappedOutFrame(
305 RenderFrameHostImpl* render_frame_host) {
306 // Make sure this is from our current RFH, and that we have a pending
307 // navigation from OnCrossSiteResponse. (There may be no pending navigation
308 // for data URLs that don't make network requests, for example.) If not,
309 // just return early and ignore.
310 if (render_frame_host != render_frame_host_ || !pending_nav_params_.get()) {
311 pending_nav_params_.reset();
312 return;
313 }
314
315 // Sanity check that this is for the correct frame.
316 DCHECK_EQ(frame_tree_node_->frame_id(), pending_nav_params_->frame_id);
317
318 // Now that the unload handler has run, we need to either initiate the
319 // pending transfer (if there is one) or resume the paused response (if not).
320 // TODO(creis): The blank swapped out page is visible during this time, but
321 // we can shorten this by delivering the response directly, rather than
322 // forcing an identical request to be made.
323 if (pending_nav_params_->is_transfer) {
324 // Treat the last URL in the chain as the destination and the remainder as
325 // the redirect chain.
326 CHECK(pending_nav_params_->transfer_url_chain.size());
327 GURL transfer_url = pending_nav_params_->transfer_url_chain.back();
328 pending_nav_params_->transfer_url_chain.pop_back();
329
330 // We don't know whether the original request had |user_action| set to true.
331 // However, since we force the navigation to be in the current tab, it
332 // doesn't matter.
333 // TODO(creis): Move RequestTransferURL to RenderFrameHost's navigator.
334 render_frame_host->render_view_host()->GetDelegate()->RequestTransferURL(
335 transfer_url,
336 pending_nav_params_->transfer_url_chain,
337 pending_nav_params_->referrer,
338 pending_nav_params_->page_transition,
339 CURRENT_TAB,
340 pending_nav_params_->frame_id,
341 pending_nav_params_->global_request_id,
342 false,
343 true);
344 } else if (pending_render_frame_host_) {
345 RenderProcessHostImpl* pending_process =
346 static_cast<RenderProcessHostImpl*>(
347 pending_render_frame_host_->GetProcess());
348 pending_process->ResumeDeferredNavigation(
349 pending_nav_params_->global_request_id);
350 }
351 pending_nav_params_.reset();
352 }
353
304 // TODO(creis): This should take in a RenderFrameHost. 354 // TODO(creis): This should take in a RenderFrameHost.
305 void RenderFrameHostManager::DidNavigateMainFrame( 355 void RenderFrameHostManager::DidNavigateMainFrame(
306 RenderViewHost* render_view_host) { 356 RenderViewHost* render_view_host) {
307 if (!cross_navigation_pending_) { 357 if (!cross_navigation_pending_) {
308 DCHECK(!pending_render_frame_host_); 358 DCHECK(!pending_render_frame_host_);
309 359
310 // We should only hear this from our current renderer. 360 // We should only hear this from our current renderer.
311 DCHECK(render_view_host == render_frame_host_->render_view_host()); 361 DCHECK(render_view_host == render_frame_host_->render_view_host());
312 362
313 // Even when there is no pending RVH, there may be a pending Web UI. 363 // Even when there is no pending RVH, there may be a pending Web UI.
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 // Now close any modal dialogs that would prevent us from swapping out. This 523 // Now close any modal dialogs that would prevent us from swapping out. This
474 // must be done separately from SwapOut, so that the PageGroupLoadDeferrer is 524 // must be done separately from SwapOut, so that the PageGroupLoadDeferrer is
475 // no longer on the stack when we send the SwapOut message. 525 // no longer on the stack when we send the SwapOut message.
476 delegate_->CancelModalDialogsForRenderManager(); 526 delegate_->CancelModalDialogsForRenderManager();
477 527
478 // Tell the old renderer it is being swapped out. This will fire the unload 528 // Tell the old renderer it is being swapped out. This will fire the unload
479 // handler (without firing the beforeunload handler a second time). When the 529 // handler (without firing the beforeunload handler a second time). When the
480 // unload handler finishes and the navigation completes, we will send a 530 // unload handler finishes and the navigation completes, we will send a
481 // message to the ResourceDispatcherHost, allowing the pending RVH's response 531 // message to the ResourceDispatcherHost, allowing the pending RVH's response
482 // to resume. 532 // to resume.
483 // TODO(creis): We should do this on the RFH or else we'll swap out the 533 // Note: This must be done on the RFH or else we'll swap out the top-level
484 // top-level page when subframes navigate. 534 // page when subframes navigate.
485 render_frame_host_->render_view_host()->SwapOut(); 535 if (frame_tree_node_->IsMainFrame())
536 render_frame_host_->render_view_host()->SwapOut();
537 else
538 render_frame_host_->SwapOut();
486 539
487 // ResourceDispatcherHost has told us to run the onunload handler, which 540 // ResourceDispatcherHost has told us to run the onunload handler, which
488 // means it is not a download or unsafe page, and we are going to perform the 541 // means it is not a download or unsafe page, and we are going to perform the
489 // navigation. Thus, we no longer need to remember that the RenderViewHost 542 // navigation. Thus, we no longer need to remember that the RenderFrameHost
490 // is part of a pending cross-site request. 543 // is part of a pending cross-site request.
491 if (pending_render_frame_host_) { 544 if (pending_render_frame_host_) {
492 pending_render_frame_host_->render_view_host()-> 545 pending_render_frame_host_->render_view_host()->
493 SetHasPendingCrossSiteRequest(false); 546 SetHasPendingCrossSiteRequest(false);
494 } 547 }
495 } 548 }
496 549
497 void RenderFrameHostManager::Observe( 550 void RenderFrameHostManager::Observe(
498 int type, 551 int type,
499 const NotificationSource& source, 552 const NotificationSource& source,
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 // to make sure the sad tab shows up, etc. 980 // to make sure the sad tab shows up, etc.
928 if (!render_frame_host_->render_view_host()->GetView()) { 981 if (!render_frame_host_->render_view_host()->GetView()) {
929 delegate_->RenderProcessGoneFromRenderManager( 982 delegate_->RenderProcessGoneFromRenderManager(
930 render_frame_host_->render_view_host()); 983 render_frame_host_->render_view_host());
931 } else if (!delegate_->IsHidden() && is_main_frame) { 984 } else if (!delegate_->IsHidden() && is_main_frame) {
932 render_frame_host_->render_view_host()->GetView()->Show(); 985 render_frame_host_->render_view_host()->GetView()->Show();
933 } 986 }
934 987
935 // Hide the old view now that the new one is visible. 988 // Hide the old view now that the new one is visible.
936 if (old_render_frame_host->render_view_host()->GetView()) { 989 if (old_render_frame_host->render_view_host()->GetView()) {
937 old_render_frame_host->render_view_host()->GetView()->Hide(); 990 if (is_main_frame) {
938 old_render_frame_host->render_view_host()->WasSwappedOut(); 991 old_render_frame_host->render_view_host()->GetView()->Hide();
992 old_render_frame_host->render_view_host()->WasSwappedOut();
993 } else {
994 // TODO(creis): We'll need to set this back to false if we navigate back.
995 old_render_frame_host->set_swapped_out(true);
Charlie Reis 2013/12/21 00:26:42 I also forgot to add this part from the draft CL i
996 }
939 } 997 }
940 998
941 // Make sure the size is up to date. (Fix for bug 1079768.) 999 // Make sure the size is up to date. (Fix for bug 1079768.)
942 delegate_->UpdateRenderViewSizeForRenderManager(); 1000 delegate_->UpdateRenderViewSizeForRenderManager();
943 1001
944 if (will_focus_location_bar) { 1002 if (will_focus_location_bar) {
945 delegate_->SetFocusToLocationBar(false); 1003 delegate_->SetFocusToLocationBar(false);
946 } else if (focus_render_view && 1004 } else if (focus_render_view &&
947 render_frame_host_->render_view_host()->GetView()) { 1005 render_frame_host_->render_view_host()->GetView()) {
948 RenderWidgetHostViewPort::FromRWHV( 1006 RenderWidgetHostViewPort::FromRWHV(
(...skipping 10 matching lines...) Expand all
959 render_frame_host_->render_view_host()); 1017 render_frame_host_->render_view_host());
960 } 1018 }
961 1019
962 // If the pending frame was on the swapped out list, we can remove it. 1020 // If the pending frame was on the swapped out list, we can remove it.
963 swapped_out_hosts_.erase(render_frame_host_->render_view_host()-> 1021 swapped_out_hosts_.erase(render_frame_host_->render_view_host()->
964 GetSiteInstance()->GetId()); 1022 GetSiteInstance()->GetId());
965 1023
966 if (old_render_frame_host->render_view_host()->IsRenderViewLive()) { 1024 if (old_render_frame_host->render_view_host()->IsRenderViewLive()) {
967 // If the old RFH is live, we are swapping it out and should keep track of 1025 // If the old RFH is live, we are swapping it out and should keep track of
968 // it in case we navigate back to it. 1026 // it in case we navigate back to it.
969 DCHECK(old_render_frame_host->render_view_host()->is_swapped_out()); 1027 DCHECK(old_render_frame_host->is_swapped_out() ||
1028 old_render_frame_host->render_view_host()->is_swapped_out());
970 // Temp fix for http://crbug.com/90867 until we do a better cleanup to make 1029 // Temp fix for http://crbug.com/90867 until we do a better cleanup to make
971 // sure we don't get different rvh instances for the same site instance 1030 // sure we don't get different rvh instances for the same site instance
972 // in the same rvhmgr. 1031 // in the same rvhmgr.
973 // TODO(creis): Clean this up. 1032 // TODO(creis): Clean this up.
974 int32 old_site_instance_id = 1033 int32 old_site_instance_id =
975 old_render_frame_host->render_view_host()->GetSiteInstance()->GetId(); 1034 old_render_frame_host->render_view_host()->GetSiteInstance()->GetId();
976 RenderFrameHostMap::iterator iter = 1035 RenderFrameHostMap::iterator iter =
977 swapped_out_hosts_.find(old_site_instance_id); 1036 swapped_out_hosts_.find(old_site_instance_id);
978 if (iter != swapped_out_hosts_.end() && 1037 if (iter != swapped_out_hosts_.end() &&
979 iter->second != old_render_frame_host) { 1038 iter->second != old_render_frame_host) {
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1285 SiteInstance* instance) const { 1344 SiteInstance* instance) const {
1286 RenderFrameHostMap::const_iterator iter = 1345 RenderFrameHostMap::const_iterator iter =
1287 swapped_out_hosts_.find(instance->GetId()); 1346 swapped_out_hosts_.find(instance->GetId());
1288 if (iter != swapped_out_hosts_.end()) 1347 if (iter != swapped_out_hosts_.end())
1289 return iter->second; 1348 return iter->second;
1290 1349
1291 return NULL; 1350 return NULL;
1292 } 1351 }
1293 1352
1294 } // namespace content 1353 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_manager.h ('k') | content/common/frame_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698