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

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

Issue 1693353002: Reland #2 Remove the is_loading_ field from WebContentsImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed nits + rebase Created 4 years, 10 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 // swapping out) when the new navigation commits. 431 // swapping out) when the new navigation commits.
432 CHECK(cross_site_transferring_request); 432 CHECK(cross_site_transferring_request);
433 433
434 // A transfer should only have come from our pending or current RFH. 434 // A transfer should only have come from our pending or current RFH.
435 // TODO(creis): We need to handle the case that the pending RFH has changed 435 // TODO(creis): We need to handle the case that the pending RFH has changed
436 // in the mean time, while this was being posted from the IO thread. We 436 // in the mean time, while this was being posted from the IO thread. We
437 // should probably cancel the request in that case. 437 // should probably cancel the request in that case.
438 DCHECK(pending_render_frame_host == pending_render_frame_host_.get() || 438 DCHECK(pending_render_frame_host == pending_render_frame_host_.get() ||
439 pending_render_frame_host == render_frame_host_.get()); 439 pending_render_frame_host == render_frame_host_.get());
440 440
441 // Check if the FrameTreeNode is loading. This will be used later to notify
442 // the FrameTreeNode that the load stop if the transfer fails.
443 bool frame_tree_node_was_loading = frame_tree_node_->IsLoading();
444
441 // Store the transferring request so that we can release it if the transfer 445 // Store the transferring request so that we can release it if the transfer
442 // navigation matches. 446 // navigation matches.
443 cross_site_transferring_request_ = std::move(cross_site_transferring_request); 447 cross_site_transferring_request_ = std::move(cross_site_transferring_request);
444 448
445 // Store the NavigationHandle to give it to the appropriate RenderFrameHost 449 // Store the NavigationHandle to give it to the appropriate RenderFrameHost
446 // after it started navigating. 450 // after it started navigating.
447 transfer_navigation_handle_ = 451 transfer_navigation_handle_ =
448 pending_render_frame_host->PassNavigationHandleOwnership(); 452 pending_render_frame_host->PassNavigationHandleOwnership();
449 DCHECK(transfer_navigation_handle_); 453 DCHECK(transfer_navigation_handle_);
450 454
455 // Set the transferring RenderFrameHost as not loading, so that it does not
456 // emit a DidStopLoading notification if it is destroyed when creating the
457 // new navigating RenderFrameHost.
458 pending_render_frame_host->set_is_loading(false);
459
451 // Sanity check that the params are for the correct frame and process. 460 // Sanity check that the params are for the correct frame and process.
452 // These should match the RenderFrameHost that made the request. 461 // These should match the RenderFrameHost that made the request.
453 // If it started as a cross-process navigation via OpenURL, this is the 462 // If it started as a cross-process navigation via OpenURL, this is the
454 // pending one. If it wasn't cross-process until the transfer, this is 463 // pending one. If it wasn't cross-process until the transfer, this is
455 // the current one. 464 // the current one.
456 int render_frame_id = pending_render_frame_host_ 465 int render_frame_id = pending_render_frame_host_
457 ? pending_render_frame_host_->GetRoutingID() 466 ? pending_render_frame_host_->GetRoutingID()
458 : render_frame_host_->GetRoutingID(); 467 : render_frame_host_->GetRoutingID();
459 DCHECK_EQ(render_frame_id, pending_render_frame_host->GetRoutingID()); 468 DCHECK_EQ(render_frame_id, pending_render_frame_host->GetRoutingID());
460 int process_id = pending_render_frame_host_ ? 469 int process_id = pending_render_frame_host_ ?
(...skipping 12 matching lines...) Expand all
473 pending_render_frame_host, transfer_url, rest_of_chain, referrer, 482 pending_render_frame_host, transfer_url, rest_of_chain, referrer,
474 page_transition, global_request_id, should_replace_current_entry); 483 page_transition, global_request_id, should_replace_current_entry);
475 484
476 // The transferring request was only needed during the RequestTransferURL 485 // The transferring request was only needed during the RequestTransferURL
477 // call, so it is safe to clear at this point. 486 // call, so it is safe to clear at this point.
478 cross_site_transferring_request_.reset(); 487 cross_site_transferring_request_.reset();
479 488
480 // If the navigation continued, the NavigationHandle should have been 489 // If the navigation continued, the NavigationHandle should have been
481 // transfered to a RenderFrameHost. In the other cases, it should be cleared. 490 // transfered to a RenderFrameHost. In the other cases, it should be cleared.
482 transfer_navigation_handle_.reset(); 491 transfer_navigation_handle_.reset();
492
493 // If the navigation in the new renderer did not start, inform the
494 // FrameTreeNode that it stopped loading.
495 if (!frame_tree_node_->IsLoading() && frame_tree_node_was_loading)
496 frame_tree_node_->DidStopLoading();
483 } 497 }
484 498
485 void RenderFrameHostManager::DidNavigateFrame( 499 void RenderFrameHostManager::DidNavigateFrame(
486 RenderFrameHostImpl* render_frame_host, 500 RenderFrameHostImpl* render_frame_host,
487 bool was_caused_by_user_gesture) { 501 bool was_caused_by_user_gesture) {
488 CommitPendingIfNecessary(render_frame_host, was_caused_by_user_gesture); 502 CommitPendingIfNecessary(render_frame_host, was_caused_by_user_gesture);
489 503
490 // Make sure any dynamic changes to this frame's sandbox flags that were made 504 // Make sure any dynamic changes to this frame's sandbox flags that were made
491 // prior to navigation take effect. 505 // prior to navigation take effect.
492 CommitPendingSandboxFlags(); 506 CommitPendingSandboxFlags();
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 if (notify_webui_of_rv_creation && GetNavigatingWebUI()) 919 if (notify_webui_of_rv_creation && GetNavigatingWebUI())
906 GetNavigatingWebUI()->RenderViewCreated(navigation_rfh->render_view_host()); 920 GetNavigatingWebUI()->RenderViewCreated(navigation_rfh->render_view_host());
907 921
908 return navigation_rfh; 922 return navigation_rfh;
909 } 923 }
910 924
911 // PlzNavigate 925 // PlzNavigate
912 void RenderFrameHostManager::CleanUpNavigation() { 926 void RenderFrameHostManager::CleanUpNavigation() {
913 CHECK(IsBrowserSideNavigationEnabled()); 927 CHECK(IsBrowserSideNavigationEnabled());
914 render_frame_host_->ClearPendingWebUI(); 928 render_frame_host_->ClearPendingWebUI();
915 if (speculative_render_frame_host_) 929 if (speculative_render_frame_host_) {
930 bool was_loading = speculative_render_frame_host_->is_loading();
916 DiscardUnusedFrame(UnsetSpeculativeRenderFrameHost()); 931 DiscardUnusedFrame(UnsetSpeculativeRenderFrameHost());
932 if (was_loading)
933 frame_tree_node_->DidStopLoading();
934 }
917 } 935 }
918 936
919 // PlzNavigate 937 // PlzNavigate
920 scoped_ptr<RenderFrameHostImpl> 938 scoped_ptr<RenderFrameHostImpl>
921 RenderFrameHostManager::UnsetSpeculativeRenderFrameHost() { 939 RenderFrameHostManager::UnsetSpeculativeRenderFrameHost() {
922 CHECK(IsBrowserSideNavigationEnabled()); 940 CHECK(IsBrowserSideNavigationEnabled());
923 speculative_render_frame_host_->GetProcess()->RemovePendingView(); 941 speculative_render_frame_host_->GetProcess()->RemovePendingView();
924 return std::move(speculative_render_frame_host_); 942 return std::move(speculative_render_frame_host_);
925 } 943 }
926 944
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
1995 if (!delegate_->IsHidden() && new_rfh_has_view) { 2013 if (!delegate_->IsHidden() && new_rfh_has_view) {
1996 // In most cases, we need to show the new view. 2014 // In most cases, we need to show the new view.
1997 render_frame_host_->GetView()->Show(); 2015 render_frame_host_->GetView()->Show();
1998 } 2016 }
1999 if (!new_rfh_has_view) { 2017 if (!new_rfh_has_view) {
2000 // If the view is gone, then this RenderViewHost died while it was hidden. 2018 // If the view is gone, then this RenderViewHost died while it was hidden.
2001 // We ignored the RenderProcessGone call at the time, so we should send it 2019 // We ignored the RenderProcessGone call at the time, so we should send it
2002 // now to make sure the sad tab shows up, etc. 2020 // now to make sure the sad tab shows up, etc.
2003 DCHECK(!render_frame_host_->IsRenderFrameLive()); 2021 DCHECK(!render_frame_host_->IsRenderFrameLive());
2004 DCHECK(!render_frame_host_->render_view_host()->IsRenderViewLive()); 2022 DCHECK(!render_frame_host_->render_view_host()->IsRenderViewLive());
2023 render_frame_host_->ResetLoadingState();
2005 delegate_->RenderProcessGoneFromRenderManager( 2024 delegate_->RenderProcessGoneFromRenderManager(
2006 render_frame_host_->render_view_host()); 2025 render_frame_host_->render_view_host());
2007 } 2026 }
2008 2027
2009 // For top-level frames, also hide the old RenderViewHost's view. 2028 // For top-level frames, also hide the old RenderViewHost's view.
2010 // TODO(creis): As long as show/hide are on RVH, we don't want to hide on 2029 // TODO(creis): As long as show/hide are on RVH, we don't want to hide on
2011 // subframe navigations or we will interfere with the top-level frame. 2030 // subframe navigations or we will interfere with the top-level frame.
2012 if (is_main_frame && 2031 if (is_main_frame &&
2013 old_render_frame_host->render_view_host()->GetWidget()->GetView()) { 2032 old_render_frame_host->render_view_host()->GetWidget()->GetView()) {
2014 old_render_frame_host->render_view_host()->GetWidget()->GetView()->Hide(); 2033 old_render_frame_host->render_view_host()->GetWidget()->GetView()->Hide();
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
2246 render_frame_host_->pending_web_ui()->RenderViewCreated( 2265 render_frame_host_->pending_web_ui()->RenderViewCreated(
2247 render_frame_host_->render_view_host()); 2266 render_frame_host_->render_view_host());
2248 } 2267 }
2249 } 2268 }
2250 } 2269 }
2251 2270
2252 void RenderFrameHostManager::CancelPending() { 2271 void RenderFrameHostManager::CancelPending() {
2253 TRACE_EVENT1("navigation", "RenderFrameHostManager::CancelPending", 2272 TRACE_EVENT1("navigation", "RenderFrameHostManager::CancelPending",
2254 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); 2273 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id());
2255 render_frame_host_->ClearPendingWebUI(); 2274 render_frame_host_->ClearPendingWebUI();
2275
2276 bool pending_was_loading = pending_render_frame_host_->is_loading();
2256 DiscardUnusedFrame(UnsetPendingRenderFrameHost()); 2277 DiscardUnusedFrame(UnsetPendingRenderFrameHost());
2278 if (pending_was_loading)
2279 frame_tree_node_->DidStopLoading();
2257 } 2280 }
2258 2281
2259 scoped_ptr<RenderFrameHostImpl> 2282 scoped_ptr<RenderFrameHostImpl>
2260 RenderFrameHostManager::UnsetPendingRenderFrameHost() { 2283 RenderFrameHostManager::UnsetPendingRenderFrameHost() {
2261 scoped_ptr<RenderFrameHostImpl> pending_render_frame_host = 2284 scoped_ptr<RenderFrameHostImpl> pending_render_frame_host =
2262 std::move(pending_render_frame_host_); 2285 std::move(pending_render_frame_host_);
2263 2286
2264 RenderFrameDevToolsAgentHost::OnCancelPendingNavigation( 2287 RenderFrameDevToolsAgentHost::OnCancelPendingNavigation(
2265 pending_render_frame_host.get(), 2288 pending_render_frame_host.get(),
2266 render_frame_host_.get()); 2289 render_frame_host_.get());
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
2484 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { 2507 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) {
2485 if (!frame_tree_node_->opener()) 2508 if (!frame_tree_node_->opener())
2486 return MSG_ROUTING_NONE; 2509 return MSG_ROUTING_NONE;
2487 2510
2488 return frame_tree_node_->opener() 2511 return frame_tree_node_->opener()
2489 ->render_manager() 2512 ->render_manager()
2490 ->GetRoutingIdForSiteInstance(instance); 2513 ->GetRoutingIdForSiteInstance(instance);
2491 } 2514 }
2492 2515
2493 } // namespace content 2516 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.cc ('k') | content/browser/site_instance_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698