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

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

Issue 1690633002: Revert of Remove the is_loading_ field from WebContentsImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 // navigations can just continue and wait to run the unload handler (by 430 // navigations can just continue and wait to run the unload handler (by
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 DCHECK(frame_tree_node_->IsLoading());
441 440
442 // Store the transferring request so that we can release it if the transfer 441 // Store the transferring request so that we can release it if the transfer
443 // navigation matches. 442 // navigation matches.
444 cross_site_transferring_request_ = std::move(cross_site_transferring_request); 443 cross_site_transferring_request_ = std::move(cross_site_transferring_request);
445 444
446 // Store the NavigationHandle to give it to the appropriate RenderFrameHost 445 // Store the NavigationHandle to give it to the appropriate RenderFrameHost
447 // after it started navigating. 446 // after it started navigating.
448 transfer_navigation_handle_ = 447 transfer_navigation_handle_ =
449 pending_render_frame_host->PassNavigationHandleOwnership(); 448 pending_render_frame_host->PassNavigationHandleOwnership();
450 DCHECK(transfer_navigation_handle_); 449 DCHECK(transfer_navigation_handle_);
451 450
452 // Set the transferring RenderFrameHost as not loading, so that it does not
453 // emit a DidStopLoading notification if it is destroyed when creating the
454 // new navigating RenderFrameHost.
455 pending_render_frame_host->set_is_loading(false);
456
457 // Sanity check that the params are for the correct frame and process. 451 // Sanity check that the params are for the correct frame and process.
458 // These should match the RenderFrameHost that made the request. 452 // These should match the RenderFrameHost that made the request.
459 // If it started as a cross-process navigation via OpenURL, this is the 453 // If it started as a cross-process navigation via OpenURL, this is the
460 // pending one. If it wasn't cross-process until the transfer, this is 454 // pending one. If it wasn't cross-process until the transfer, this is
461 // the current one. 455 // the current one.
462 int render_frame_id = pending_render_frame_host_ 456 int render_frame_id = pending_render_frame_host_
463 ? pending_render_frame_host_->GetRoutingID() 457 ? pending_render_frame_host_->GetRoutingID()
464 : render_frame_host_->GetRoutingID(); 458 : render_frame_host_->GetRoutingID();
465 DCHECK_EQ(render_frame_id, pending_render_frame_host->GetRoutingID()); 459 DCHECK_EQ(render_frame_id, pending_render_frame_host->GetRoutingID());
466 int process_id = pending_render_frame_host_ ? 460 int process_id = pending_render_frame_host_ ?
(...skipping 12 matching lines...) Expand all
479 pending_render_frame_host, transfer_url, rest_of_chain, referrer, 473 pending_render_frame_host, transfer_url, rest_of_chain, referrer,
480 page_transition, global_request_id, should_replace_current_entry); 474 page_transition, global_request_id, should_replace_current_entry);
481 475
482 // The transferring request was only needed during the RequestTransferURL 476 // The transferring request was only needed during the RequestTransferURL
483 // call, so it is safe to clear at this point. 477 // call, so it is safe to clear at this point.
484 cross_site_transferring_request_.reset(); 478 cross_site_transferring_request_.reset();
485 479
486 // If the navigation continued, the NavigationHandle should have been 480 // If the navigation continued, the NavigationHandle should have been
487 // transfered to a RenderFrameHost. In the other cases, it should be cleared. 481 // transfered to a RenderFrameHost. In the other cases, it should be cleared.
488 transfer_navigation_handle_.reset(); 482 transfer_navigation_handle_.reset();
489
490 // If the navigation in the new renderer did not start, inform the
491 // FrameTreeNode that it stopped loading.
492 if (!frame_tree_node_->IsLoading())
493 frame_tree_node_->DidStopLoading();
494 } 483 }
495 484
496 void RenderFrameHostManager::DidNavigateFrame( 485 void RenderFrameHostManager::DidNavigateFrame(
497 RenderFrameHostImpl* render_frame_host, 486 RenderFrameHostImpl* render_frame_host,
498 bool was_caused_by_user_gesture) { 487 bool was_caused_by_user_gesture) {
499 CommitPendingIfNecessary(render_frame_host, was_caused_by_user_gesture); 488 CommitPendingIfNecessary(render_frame_host, was_caused_by_user_gesture);
500 489
501 // Make sure any dynamic changes to this frame's sandbox flags that were made 490 // Make sure any dynamic changes to this frame's sandbox flags that were made
502 // prior to navigation take effect. 491 // prior to navigation take effect.
503 CommitPendingSandboxFlags(); 492 CommitPendingSandboxFlags();
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 if (notify_webui_of_rv_creation && GetNavigatingWebUI()) 905 if (notify_webui_of_rv_creation && GetNavigatingWebUI())
917 GetNavigatingWebUI()->RenderViewCreated(navigation_rfh->render_view_host()); 906 GetNavigatingWebUI()->RenderViewCreated(navigation_rfh->render_view_host());
918 907
919 return navigation_rfh; 908 return navigation_rfh;
920 } 909 }
921 910
922 // PlzNavigate 911 // PlzNavigate
923 void RenderFrameHostManager::CleanUpNavigation() { 912 void RenderFrameHostManager::CleanUpNavigation() {
924 CHECK(IsBrowserSideNavigationEnabled()); 913 CHECK(IsBrowserSideNavigationEnabled());
925 render_frame_host_->ClearPendingWebUI(); 914 render_frame_host_->ClearPendingWebUI();
926 if (speculative_render_frame_host_) { 915 if (speculative_render_frame_host_)
927 bool was_loading = speculative_render_frame_host_->is_loading();
928 DiscardUnusedFrame(UnsetSpeculativeRenderFrameHost()); 916 DiscardUnusedFrame(UnsetSpeculativeRenderFrameHost());
929 if (was_loading)
930 frame_tree_node_->DidStopLoading();
931 }
932 } 917 }
933 918
934 // PlzNavigate 919 // PlzNavigate
935 scoped_ptr<RenderFrameHostImpl> 920 scoped_ptr<RenderFrameHostImpl>
936 RenderFrameHostManager::UnsetSpeculativeRenderFrameHost() { 921 RenderFrameHostManager::UnsetSpeculativeRenderFrameHost() {
937 CHECK(IsBrowserSideNavigationEnabled()); 922 CHECK(IsBrowserSideNavigationEnabled());
938 speculative_render_frame_host_->GetProcess()->RemovePendingView(); 923 speculative_render_frame_host_->GetProcess()->RemovePendingView();
939 return std::move(speculative_render_frame_host_); 924 return std::move(speculative_render_frame_host_);
940 } 925 }
941 926
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
2010 if (!delegate_->IsHidden() && new_rfh_has_view) { 1995 if (!delegate_->IsHidden() && new_rfh_has_view) {
2011 // In most cases, we need to show the new view. 1996 // In most cases, we need to show the new view.
2012 render_frame_host_->GetView()->Show(); 1997 render_frame_host_->GetView()->Show();
2013 } 1998 }
2014 if (!new_rfh_has_view) { 1999 if (!new_rfh_has_view) {
2015 // If the view is gone, then this RenderViewHost died while it was hidden. 2000 // If the view is gone, then this RenderViewHost died while it was hidden.
2016 // We ignored the RenderProcessGone call at the time, so we should send it 2001 // We ignored the RenderProcessGone call at the time, so we should send it
2017 // now to make sure the sad tab shows up, etc. 2002 // now to make sure the sad tab shows up, etc.
2018 DCHECK(!render_frame_host_->IsRenderFrameLive()); 2003 DCHECK(!render_frame_host_->IsRenderFrameLive());
2019 DCHECK(!render_frame_host_->render_view_host()->IsRenderViewLive()); 2004 DCHECK(!render_frame_host_->render_view_host()->IsRenderViewLive());
2020 render_frame_host_->ResetLoadingState();
2021 delegate_->RenderProcessGoneFromRenderManager( 2005 delegate_->RenderProcessGoneFromRenderManager(
2022 render_frame_host_->render_view_host()); 2006 render_frame_host_->render_view_host());
2023 } 2007 }
2024 2008
2025 // For top-level frames, also hide the old RenderViewHost's view. 2009 // For top-level frames, also hide the old RenderViewHost's view.
2026 // TODO(creis): As long as show/hide are on RVH, we don't want to hide on 2010 // TODO(creis): As long as show/hide are on RVH, we don't want to hide on
2027 // subframe navigations or we will interfere with the top-level frame. 2011 // subframe navigations or we will interfere with the top-level frame.
2028 if (is_main_frame && 2012 if (is_main_frame &&
2029 old_render_frame_host->render_view_host()->GetWidget()->GetView()) { 2013 old_render_frame_host->render_view_host()->GetWidget()->GetView()) {
2030 old_render_frame_host->render_view_host()->GetWidget()->GetView()->Hide(); 2014 old_render_frame_host->render_view_host()->GetWidget()->GetView()->Hide();
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
2262 render_frame_host_->pending_web_ui()->RenderViewCreated( 2246 render_frame_host_->pending_web_ui()->RenderViewCreated(
2263 render_frame_host_->render_view_host()); 2247 render_frame_host_->render_view_host());
2264 } 2248 }
2265 } 2249 }
2266 } 2250 }
2267 2251
2268 void RenderFrameHostManager::CancelPending() { 2252 void RenderFrameHostManager::CancelPending() {
2269 TRACE_EVENT1("navigation", "RenderFrameHostManager::CancelPending", 2253 TRACE_EVENT1("navigation", "RenderFrameHostManager::CancelPending",
2270 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); 2254 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id());
2271 render_frame_host_->ClearPendingWebUI(); 2255 render_frame_host_->ClearPendingWebUI();
2272
2273 bool pending_was_loading = pending_render_frame_host_->is_loading();
2274 DiscardUnusedFrame(UnsetPendingRenderFrameHost()); 2256 DiscardUnusedFrame(UnsetPendingRenderFrameHost());
2275 if (pending_was_loading)
2276 frame_tree_node_->DidStopLoading();
2277 } 2257 }
2278 2258
2279 scoped_ptr<RenderFrameHostImpl> 2259 scoped_ptr<RenderFrameHostImpl>
2280 RenderFrameHostManager::UnsetPendingRenderFrameHost() { 2260 RenderFrameHostManager::UnsetPendingRenderFrameHost() {
2281 scoped_ptr<RenderFrameHostImpl> pending_render_frame_host = 2261 scoped_ptr<RenderFrameHostImpl> pending_render_frame_host =
2282 std::move(pending_render_frame_host_); 2262 std::move(pending_render_frame_host_);
2283 2263
2284 RenderFrameDevToolsAgentHost::OnCancelPendingNavigation( 2264 RenderFrameDevToolsAgentHost::OnCancelPendingNavigation(
2285 pending_render_frame_host.get(), 2265 pending_render_frame_host.get(),
2286 render_frame_host_.get()); 2266 render_frame_host_.get());
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
2500 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { 2480 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) {
2501 if (!frame_tree_node_->opener()) 2481 if (!frame_tree_node_->opener())
2502 return MSG_ROUTING_NONE; 2482 return MSG_ROUTING_NONE;
2503 2483
2504 return frame_tree_node_->opener() 2484 return frame_tree_node_->opener()
2505 ->render_manager() 2485 ->render_manager()
2506 ->GetRoutingIdForSiteInstance(instance); 2486 ->GetRoutingIdForSiteInstance(instance);
2507 } 2487 }
2508 2488
2509 } // namespace content 2489 } // 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