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

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

Issue 497183003: Fix DisownOpener and related tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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
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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 // A navigation in the original page has taken place. Cancel the pending 447 // A navigation in the original page has taken place. Cancel the pending
448 // one. 448 // one.
449 CancelPending(); 449 CancelPending();
450 cross_navigation_pending_ = false; 450 cross_navigation_pending_ = false;
451 } else { 451 } else {
452 // No one else should be sending us DidNavigate in this state. 452 // No one else should be sending us DidNavigate in this state.
453 DCHECK(false); 453 DCHECK(false);
454 } 454 }
455 } 455 }
456 456
457 // TODO(creis): Take in RenderFrameHost instead, since frames can have openers. 457 // TODO(creis): Take in RenderFrameHost instead, since frames can have openers.
Charlie Reis 2014/08/22 19:41:23 I thought about tackling this here as well, but I
458 void RenderFrameHostManager::DidDisownOpener(RenderViewHost* render_view_host) { 458 void RenderFrameHostManager::DidDisownOpener(RenderViewHost* render_view_host) {
459 // Notify all swapped out hosts, including the pending RVH. 459 // Notify all RenderViewHosts but the one that notified us. This is necessary
Charlie Reis 2014/08/22 19:41:23 Bug 1: We wanted to notify the pending RVH, but we
460 // in case a process swap has occurred while the message was in flight.
460 for (RenderFrameProxyHostMap::iterator iter = proxy_hosts_.begin(); 461 for (RenderFrameProxyHostMap::iterator iter = proxy_hosts_.begin();
461 iter != proxy_hosts_.end(); 462 iter != proxy_hosts_.end();
462 ++iter) { 463 ++iter) {
463 DCHECK_NE(iter->second->GetSiteInstance(), 464 DCHECK_NE(iter->second->GetSiteInstance(),
464 current_frame_host()->GetSiteInstance()); 465 current_frame_host()->GetSiteInstance());
465 iter->second->GetRenderViewHost()->DisownOpener(); 466 iter->second->GetRenderViewHost()->DisownOpener();
466 } 467 }
468
469 if (render_frame_host_->render_view_host() != render_view_host)
470 render_frame_host_->render_view_host()->DisownOpener();
Charlie Reis 2014/08/22 19:41:23 Bug 2: It's possible for a cross-process navigatio
471
472 if (pending_render_frame_host_ &&
473 pending_render_frame_host_->render_view_host() != render_view_host) {
474 pending_render_frame_host_->render_view_host()->DisownOpener();
475 }
467 } 476 }
468 477
469 void RenderFrameHostManager::RendererProcessClosing( 478 void RenderFrameHostManager::RendererProcessClosing(
470 RenderProcessHost* render_process_host) { 479 RenderProcessHost* render_process_host) {
471 // Remove any swapped out RVHs from this process, so that we don't try to 480 // Remove any swapped out RVHs from this process, so that we don't try to
472 // swap them back in while the process is exiting. Start by finding them, 481 // swap them back in while the process is exiting. Start by finding them,
473 // since there could be more than one. 482 // since there could be more than one.
474 std::list<int> ids_to_remove; 483 std::list<int> ids_to_remove;
475 for (RenderFrameProxyHostMap::iterator iter = proxy_hosts_.begin(); 484 for (RenderFrameProxyHostMap::iterator iter = proxy_hosts_.begin();
476 iter != proxy_hosts_.end(); 485 iter != proxy_hosts_.end();
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 scoped_ptr<RenderFrameHostImpl> new_render_frame_host; 1054 scoped_ptr<RenderFrameHostImpl> new_render_frame_host;
1046 RenderFrameHostImpl* frame_to_announce = NULL; 1055 RenderFrameHostImpl* frame_to_announce = NULL;
1047 int routing_id = MSG_ROUTING_NONE; 1056 int routing_id = MSG_ROUTING_NONE;
1048 1057
1049 // We are creating a pending or swapped out RFH here. We should never create 1058 // We are creating a pending or swapped out RFH here. We should never create
1050 // it in the same SiteInstance as our current RFH. 1059 // it in the same SiteInstance as our current RFH.
1051 CHECK_NE(render_frame_host_->GetSiteInstance(), instance); 1060 CHECK_NE(render_frame_host_->GetSiteInstance(), instance);
1052 1061
1053 // Check if we've already created an RFH for this SiteInstance. If so, try 1062 // Check if we've already created an RFH for this SiteInstance. If so, try
1054 // to re-use the existing one, which has already been initialized. We'll 1063 // to re-use the existing one, which has already been initialized. We'll
1055 // remove it from the list of swapped out hosts if it commits. 1064 // remove it from the list of proxy hosts below if it will be active.
1056 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); 1065 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance);
1057 1066
1058 if (proxy) { 1067 if (proxy) {
1059 routing_id = proxy->GetRenderViewHost()->GetRoutingID(); 1068 routing_id = proxy->GetRenderViewHost()->GetRoutingID();
1060 // Delete the existing RenderFrameProxyHost, but reuse the RenderFrameHost. 1069 // Delete the existing RenderFrameProxyHost, but reuse the RenderFrameHost.
1061 // Prevent the process from exiting while we're trying to use it. 1070 // Prevent the process from exiting while we're trying to use it.
1062 if (!swapped_out) { 1071 if (!swapped_out) {
1063 new_render_frame_host = proxy->PassFrameHostOwnership(); 1072 new_render_frame_host = proxy->PassFrameHostOwnership();
1064 new_render_frame_host->GetProcess()->AddPendingView(); 1073 new_render_frame_host->GetProcess()->AddPendingView();
1065 1074
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
1649 void RenderFrameHostManager::DeleteRenderFrameProxyHost( 1658 void RenderFrameHostManager::DeleteRenderFrameProxyHost(
1650 SiteInstance* instance) { 1659 SiteInstance* instance) {
1651 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); 1660 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId());
1652 if (iter != proxy_hosts_.end()) { 1661 if (iter != proxy_hosts_.end()) {
1653 delete iter->second; 1662 delete iter->second;
1654 proxy_hosts_.erase(iter); 1663 proxy_hosts_.erase(iter);
1655 } 1664 }
1656 } 1665 }
1657 1666
1658 } // namespace content 1667 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698