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

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: Minor cleanup. Created 7 years 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 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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 render_frame_host_->render_view_host()); 1012 render_frame_host_->render_view_host());
960 } 1013 }
961 1014
962 // If the pending frame was on the swapped out list, we can remove it. 1015 // 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()-> 1016 swapped_out_hosts_.erase(render_frame_host_->render_view_host()->
964 GetSiteInstance()->GetId()); 1017 GetSiteInstance()->GetId());
965 1018
966 if (old_render_frame_host->render_view_host()->IsRenderViewLive()) { 1019 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 1020 // 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. 1021 // it in case we navigate back to it.
969 DCHECK(old_render_frame_host->render_view_host()->is_swapped_out()); 1022 DCHECK(old_render_frame_host->is_swapped_out() ||
1023 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 1024 // 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 1025 // sure we don't get different rvh instances for the same site instance
972 // in the same rvhmgr. 1026 // in the same rvhmgr.
973 // TODO(creis): Clean this up. 1027 // TODO(creis): Clean this up.
974 int32 old_site_instance_id = 1028 int32 old_site_instance_id =
975 old_render_frame_host->render_view_host()->GetSiteInstance()->GetId(); 1029 old_render_frame_host->render_view_host()->GetSiteInstance()->GetId();
976 RenderFrameHostMap::iterator iter = 1030 RenderFrameHostMap::iterator iter =
977 swapped_out_hosts_.find(old_site_instance_id); 1031 swapped_out_hosts_.find(old_site_instance_id);
978 if (iter != swapped_out_hosts_.end() && 1032 if (iter != swapped_out_hosts_.end() &&
979 iter->second != old_render_frame_host) { 1033 iter->second != old_render_frame_host) {
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1285 SiteInstance* instance) const { 1339 SiteInstance* instance) const {
1286 RenderFrameHostMap::const_iterator iter = 1340 RenderFrameHostMap::const_iterator iter =
1287 swapped_out_hosts_.find(instance->GetId()); 1341 swapped_out_hosts_.find(instance->GetId());
1288 if (iter != swapped_out_hosts_.end()) 1342 if (iter != swapped_out_hosts_.end())
1289 return iter->second; 1343 return iter->second;
1290 1344
1291 return NULL; 1345 return NULL;
1292 } 1346 }
1293 1347
1294 } // namespace content 1348 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698