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

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

Issue 1440593004: Make operators on scoped_ptr match the ones defined for std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptrequals: followupfix-after-rebase Created 5 years, 1 month 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 <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 entry.GetTransitionType(), 392 entry.GetTransitionType(),
393 entry.restore_type() != NavigationEntryImpl::RESTORE_NONE, 393 entry.restore_type() != NavigationEntryImpl::RESTORE_NONE,
394 entry.IsViewSourceMode(), entry.transferred_global_request_id(), 394 entry.IsViewSourceMode(), entry.transferred_global_request_id(),
395 entry.bindings()); 395 entry.bindings());
396 if (!dest_render_frame_host) 396 if (!dest_render_frame_host)
397 return nullptr; // We weren't able to create a pending render frame host. 397 return nullptr; // We weren't able to create a pending render frame host.
398 398
399 // If the current render_frame_host_ isn't live, we should create it so 399 // If the current render_frame_host_ isn't live, we should create it so
400 // that we don't show a sad tab while the dest_render_frame_host fetches 400 // that we don't show a sad tab while the dest_render_frame_host fetches
401 // its first page. (Bug 1145340) 401 // its first page. (Bug 1145340)
402 if (dest_render_frame_host != render_frame_host_ && 402 if (dest_render_frame_host != render_frame_host_.get() &&
403 !render_frame_host_->IsRenderFrameLive()) { 403 !render_frame_host_->IsRenderFrameLive()) {
404 // Note: we don't call InitRenderView here because we are navigating away 404 // Note: we don't call InitRenderView here because we are navigating away
405 // soon anyway, and we don't have the NavigationEntry for this host. 405 // soon anyway, and we don't have the NavigationEntry for this host.
406 delegate_->CreateRenderViewForRenderManager( 406 delegate_->CreateRenderViewForRenderManager(
407 render_frame_host_->render_view_host(), MSG_ROUTING_NONE, 407 render_frame_host_->render_view_host(), MSG_ROUTING_NONE,
408 MSG_ROUTING_NONE, frame_tree_node_->current_replication_state()); 408 MSG_ROUTING_NONE, frame_tree_node_->current_replication_state());
409 } 409 }
410 410
411 // If the renderer isn't live, then try to create a new one to satisfy this 411 // If the renderer isn't live, then try to create a new one to satisfy this
412 // navigation request. 412 // navigation request.
413 if (!dest_render_frame_host->IsRenderFrameLive()) { 413 if (!dest_render_frame_host->IsRenderFrameLive()) {
414 // Instruct the destination render frame host to set up a Mojo connection 414 // Instruct the destination render frame host to set up a Mojo connection
415 // with the new render frame if necessary. Note that this call needs to 415 // with the new render frame if necessary. Note that this call needs to
416 // occur before initializing the RenderView; the flow of creating the 416 // occur before initializing the RenderView; the flow of creating the
417 // RenderView can cause browser-side code to execute that expects the this 417 // RenderView can cause browser-side code to execute that expects the this
418 // RFH's ServiceRegistry to be initialized (e.g., if the site is a WebUI 418 // RFH's ServiceRegistry to be initialized (e.g., if the site is a WebUI
419 // site that is handled via Mojo, then Mojo WebUI code in //chrome will 419 // site that is handled via Mojo, then Mojo WebUI code in //chrome will
420 // add a service to this RFH's ServiceRegistry). 420 // add a service to this RFH's ServiceRegistry).
421 dest_render_frame_host->SetUpMojoIfNeeded(); 421 dest_render_frame_host->SetUpMojoIfNeeded();
422 422
423 // Recreate the opener chain. 423 // Recreate the opener chain.
424 CreateOpenerProxies(dest_render_frame_host->GetSiteInstance(), 424 CreateOpenerProxies(dest_render_frame_host->GetSiteInstance(),
425 frame_tree_node_); 425 frame_tree_node_);
426 if (!InitRenderView(dest_render_frame_host->render_view_host(), nullptr)) 426 if (!InitRenderView(dest_render_frame_host->render_view_host(), nullptr))
427 return nullptr; 427 return nullptr;
428 428
429 // Now that we've created a new renderer, be sure to hide it if it isn't 429 // Now that we've created a new renderer, be sure to hide it if it isn't
430 // our primary one. Otherwise, we might crash if we try to call Show() 430 // our primary one. Otherwise, we might crash if we try to call Show()
431 // on it later. 431 // on it later.
432 if (dest_render_frame_host != render_frame_host_) { 432 if (dest_render_frame_host != render_frame_host_.get()) {
433 if (dest_render_frame_host->GetView()) 433 if (dest_render_frame_host->GetView())
434 dest_render_frame_host->GetView()->Hide(); 434 dest_render_frame_host->GetView()->Hide();
435 } else { 435 } else {
436 // After a renderer crash we'd have marked the host as invisible, so we 436 // After a renderer crash we'd have marked the host as invisible, so we
437 // need to set the visibility of the new View to the correct value here 437 // need to set the visibility of the new View to the correct value here
438 // after reload. 438 // after reload.
439 if (dest_render_frame_host->GetView() && 439 if (dest_render_frame_host->GetView() &&
440 dest_render_frame_host->render_view_host() 440 dest_render_frame_host->render_view_host()
441 ->GetWidget() 441 ->GetWidget()
442 ->is_hidden() != delegate_->IsHidden()) { 442 ->is_hidden() != delegate_->IsHidden()) {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 bool should_replace_current_entry) { 604 bool should_replace_current_entry) {
605 // We should only get here for transfer navigations. Most cross-process 605 // We should only get here for transfer navigations. Most cross-process
606 // navigations can just continue and wait to run the unload handler (by 606 // navigations can just continue and wait to run the unload handler (by
607 // swapping out) when the new navigation commits. 607 // swapping out) when the new navigation commits.
608 CHECK(cross_site_transferring_request); 608 CHECK(cross_site_transferring_request);
609 609
610 // A transfer should only have come from our pending or current RFH. 610 // A transfer should only have come from our pending or current RFH.
611 // TODO(creis): We need to handle the case that the pending RFH has changed 611 // TODO(creis): We need to handle the case that the pending RFH has changed
612 // in the mean time, while this was being posted from the IO thread. We 612 // in the mean time, while this was being posted from the IO thread. We
613 // should probably cancel the request in that case. 613 // should probably cancel the request in that case.
614 DCHECK(pending_render_frame_host == pending_render_frame_host_ || 614 DCHECK(pending_render_frame_host == pending_render_frame_host_.get() ||
615 pending_render_frame_host == render_frame_host_); 615 pending_render_frame_host == render_frame_host_.get());
616 616
617 // Store the transferring request so that we can release it if the transfer 617 // Store the transferring request so that we can release it if the transfer
618 // navigation matches. 618 // navigation matches.
619 cross_site_transferring_request_ = cross_site_transferring_request.Pass(); 619 cross_site_transferring_request_ = cross_site_transferring_request.Pass();
620 620
621 // Store the NavigationHandle to give it to the appropriate RenderFrameHost 621 // Store the NavigationHandle to give it to the appropriate RenderFrameHost
622 // after it started navigating. 622 // after it started navigating.
623 transfer_navigation_handle_ = 623 transfer_navigation_handle_ =
624 pending_render_frame_host->PassNavigationHandleOwnership(); 624 pending_render_frame_host->PassNavigationHandleOwnership();
625 DCHECK(transfer_navigation_handle_); 625 DCHECK(transfer_navigation_handle_);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 CommitPendingSandboxFlags(); 672 CommitPendingSandboxFlags();
673 } 673 }
674 674
675 void RenderFrameHostManager::CommitPendingIfNecessary( 675 void RenderFrameHostManager::CommitPendingIfNecessary(
676 RenderFrameHostImpl* render_frame_host, 676 RenderFrameHostImpl* render_frame_host,
677 bool was_caused_by_user_gesture) { 677 bool was_caused_by_user_gesture) {
678 if (!pending_render_frame_host_ && !speculative_render_frame_host_) { 678 if (!pending_render_frame_host_ && !speculative_render_frame_host_) {
679 DCHECK(!should_reuse_web_ui_ || web_ui_); 679 DCHECK(!should_reuse_web_ui_ || web_ui_);
680 680
681 // We should only hear this from our current renderer. 681 // We should only hear this from our current renderer.
682 DCHECK_EQ(render_frame_host_, render_frame_host); 682 DCHECK_EQ(render_frame_host_.get(), render_frame_host);
683 683
684 // Even when there is no pending RVH, there may be a pending Web UI. 684 // Even when there is no pending RVH, there may be a pending Web UI.
685 if (pending_web_ui() || speculative_web_ui_) 685 if (pending_web_ui() || speculative_web_ui_)
686 CommitPending(); 686 CommitPending();
687 return; 687 return;
688 } 688 }
689 689
690 if (render_frame_host == pending_render_frame_host_ || 690 if (render_frame_host == pending_render_frame_host_.get() ||
691 render_frame_host == speculative_render_frame_host_) { 691 render_frame_host == speculative_render_frame_host_.get()) {
692 // The pending cross-process navigation completed, so show the renderer. 692 // The pending cross-process navigation completed, so show the renderer.
693 CommitPending(); 693 CommitPending();
694 } else if (render_frame_host == render_frame_host_) { 694 } else if (render_frame_host == render_frame_host_.get()) {
695 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 695 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
696 switches::kEnableBrowserSideNavigation)) { 696 switches::kEnableBrowserSideNavigation)) {
697 CleanUpNavigation(); 697 CleanUpNavigation();
698 } else { 698 } else {
699 if (was_caused_by_user_gesture) { 699 if (was_caused_by_user_gesture) {
700 // A navigation in the original page has taken place. Cancel the 700 // A navigation in the original page has taken place. Cancel the
701 // pending one. Only do it for user gesture originated navigations to 701 // pending one. Only do it for user gesture originated navigations to
702 // prevent page doing any shenanigans to prevent user from navigating. 702 // prevent page doing any shenanigans to prevent user from navigating.
703 // See https://code.google.com/p/chromium/issues/detail?id=75195 703 // See https://code.google.com/p/chromium/issues/detail?id=75195
704 CancelPending(); 704 CancelPending();
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 1078
1079 // If the RenderFrame that needs to navigate is not live (its process was just 1079 // If the RenderFrame that needs to navigate is not live (its process was just
1080 // created or has crashed), initialize it. 1080 // created or has crashed), initialize it.
1081 if (!navigation_rfh->IsRenderFrameLive()) { 1081 if (!navigation_rfh->IsRenderFrameLive()) {
1082 // Recreate the opener chain. 1082 // Recreate the opener chain.
1083 CreateOpenerProxies(navigation_rfh->GetSiteInstance(), frame_tree_node_); 1083 CreateOpenerProxies(navigation_rfh->GetSiteInstance(), frame_tree_node_);
1084 if (!InitRenderView(navigation_rfh->render_view_host(), nullptr)) { 1084 if (!InitRenderView(navigation_rfh->render_view_host(), nullptr)) {
1085 return nullptr; 1085 return nullptr;
1086 } 1086 }
1087 1087
1088 if (navigation_rfh == render_frame_host_) { 1088 if (navigation_rfh == render_frame_host_.get()) {
1089 // TODO(nasko): This is a very ugly hack. The Chrome extensions process 1089 // TODO(nasko): This is a very ugly hack. The Chrome extensions process
1090 // manager still uses NotificationService and expects to see a 1090 // manager still uses NotificationService and expects to see a
1091 // RenderViewHost changed notification after WebContents and 1091 // RenderViewHost changed notification after WebContents and
1092 // RenderFrameHostManager are completely initialized. This should be 1092 // RenderFrameHostManager are completely initialized. This should be
1093 // removed once the process manager moves away from NotificationService. 1093 // removed once the process manager moves away from NotificationService.
1094 // See https://crbug.com/462682. 1094 // See https://crbug.com/462682.
1095 delegate_->NotifyMainFrameSwappedFromRenderManager( 1095 delegate_->NotifyMainFrameSwappedFromRenderManager(
1096 nullptr, render_frame_host_->render_view_host()); 1096 nullptr, render_frame_host_->render_view_host());
1097 } 1097 }
1098 } 1098 }
(...skipping 1583 matching lines...) Expand 10 before | Expand all | Expand 10 after
2682 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { 2682 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) {
2683 if (!frame_tree_node_->opener()) 2683 if (!frame_tree_node_->opener())
2684 return MSG_ROUTING_NONE; 2684 return MSG_ROUTING_NONE;
2685 2685
2686 return frame_tree_node_->opener() 2686 return frame_tree_node_->opener()
2687 ->render_manager() 2687 ->render_manager()
2688 ->GetRoutingIdForSiteInstance(instance); 2688 ->GetRoutingIdForSiteInstance(instance);
2689 } 2689 }
2690 2690
2691 } // namespace content 2691 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_update_job.cc ('k') | content/browser/service_worker/service_worker_write_to_cache_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698