OLD | NEW |
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 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 | 539 |
540 void RenderFrameHostManager::ClearPendingShutdownRFHForSiteInstance( | 540 void RenderFrameHostManager::ClearPendingShutdownRFHForSiteInstance( |
541 int32 site_instance_id, | 541 int32 site_instance_id, |
542 RenderFrameHostImpl* rfh) { | 542 RenderFrameHostImpl* rfh) { |
543 RFHPendingDeleteMap::iterator iter = | 543 RFHPendingDeleteMap::iterator iter = |
544 pending_delete_hosts_.find(site_instance_id); | 544 pending_delete_hosts_.find(site_instance_id); |
545 if (iter != pending_delete_hosts_.end() && iter->second.get() == rfh) | 545 if (iter != pending_delete_hosts_.end() && iter->second.get() == rfh) |
546 pending_delete_hosts_.erase(site_instance_id); | 546 pending_delete_hosts_.erase(site_instance_id); |
547 } | 547 } |
548 | 548 |
| 549 void RenderFrameHostManager::ResetProxyHosts() { |
| 550 STLDeleteValues(&proxy_hosts_); |
| 551 } |
| 552 |
549 void RenderFrameHostManager::Observe( | 553 void RenderFrameHostManager::Observe( |
550 int type, | 554 int type, |
551 const NotificationSource& source, | 555 const NotificationSource& source, |
552 const NotificationDetails& details) { | 556 const NotificationDetails& details) { |
553 switch (type) { | 557 switch (type) { |
554 case NOTIFICATION_RENDERER_PROCESS_CLOSED: | 558 case NOTIFICATION_RENDERER_PROCESS_CLOSED: |
555 case NOTIFICATION_RENDERER_PROCESS_CLOSING: | 559 case NOTIFICATION_RENDERER_PROCESS_CLOSING: |
556 RendererProcessClosing( | 560 RendererProcessClosing( |
557 Source<RenderProcessHost>(source).ptr()); | 561 Source<RenderProcessHost>(source).ptr()); |
558 break; | 562 break; |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 | 895 |
892 int RenderFrameHostManager::CreateRenderFrame( | 896 int RenderFrameHostManager::CreateRenderFrame( |
893 SiteInstance* instance, | 897 SiteInstance* instance, |
894 int opener_route_id, | 898 int opener_route_id, |
895 bool swapped_out, | 899 bool swapped_out, |
896 bool hidden) { | 900 bool hidden) { |
897 CHECK(instance); | 901 CHECK(instance); |
898 DCHECK(!swapped_out || hidden); // Swapped out views should always be hidden. | 902 DCHECK(!swapped_out || hidden); // Swapped out views should always be hidden. |
899 | 903 |
900 scoped_ptr<RenderFrameHostImpl> new_render_frame_host; | 904 scoped_ptr<RenderFrameHostImpl> new_render_frame_host; |
| 905 RenderFrameHostImpl* frame_to_announce = NULL; |
901 int routing_id = MSG_ROUTING_NONE; | 906 int routing_id = MSG_ROUTING_NONE; |
902 | 907 |
903 // We are creating a pending or swapped out RFH here. We should never create | 908 // We are creating a pending or swapped out RFH here. We should never create |
904 // it in the same SiteInstance as our current RFH. | 909 // it in the same SiteInstance as our current RFH. |
905 CHECK_NE(render_frame_host_->GetSiteInstance(), instance); | 910 CHECK_NE(render_frame_host_->GetSiteInstance(), instance); |
906 | 911 |
907 // Check if we've already created an RFH for this SiteInstance. If so, try | 912 // Check if we've already created an RFH for this SiteInstance. If so, try |
908 // to re-use the existing one, which has already been initialized. We'll | 913 // to re-use the existing one, which has already been initialized. We'll |
909 // remove it from the list of swapped out hosts if it commits. | 914 // remove it from the list of swapped out hosts if it commits. |
910 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); | 915 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 cross_process_frame_connector_ = NULL; | 949 cross_process_frame_connector_ = NULL; |
945 } | 950 } |
946 } | 951 } |
947 } else { | 952 } else { |
948 // Create a new RenderFrameHost if we don't find an existing one. | 953 // Create a new RenderFrameHost if we don't find an existing one. |
949 new_render_frame_host = CreateRenderFrameHost( | 954 new_render_frame_host = CreateRenderFrameHost( |
950 instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE, swapped_out, hidden); | 955 instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE, swapped_out, hidden); |
951 RenderViewHostImpl* render_view_host = | 956 RenderViewHostImpl* render_view_host = |
952 new_render_frame_host->render_view_host(); | 957 new_render_frame_host->render_view_host(); |
953 int proxy_routing_id = MSG_ROUTING_NONE; | 958 int proxy_routing_id = MSG_ROUTING_NONE; |
| 959 frame_to_announce = new_render_frame_host.get(); |
954 | 960 |
955 // Prevent the process from exiting while we're trying to navigate in it. | 961 // Prevent the process from exiting while we're trying to navigate in it. |
956 // Otherwise, if the new RFH is swapped out already, store it. | 962 // Otherwise, if the new RFH is swapped out already, store it. |
957 if (!swapped_out) { | 963 if (!swapped_out) { |
958 new_render_frame_host->GetProcess()->AddPendingView(); | 964 new_render_frame_host->GetProcess()->AddPendingView(); |
959 } else { | 965 } else { |
960 proxy = new RenderFrameProxyHost( | 966 proxy = new RenderFrameProxyHost( |
961 new_render_frame_host->GetSiteInstance(), frame_tree_node_); | 967 new_render_frame_host->GetSiteInstance(), frame_tree_node_); |
962 proxy_hosts_[instance->GetId()] = proxy; | 968 proxy_hosts_[instance->GetId()] = proxy; |
963 proxy->TakeFrameHostOwnership(new_render_frame_host.Pass()); | 969 proxy->TakeFrameHostOwnership(new_render_frame_host.Pass()); |
964 proxy_routing_id = proxy->GetRoutingID(); | 970 proxy_routing_id = proxy->GetRoutingID(); |
965 } | 971 } |
966 | 972 |
967 bool success = InitRenderView( | 973 bool success = InitRenderView( |
968 render_view_host, opener_route_id, proxy_routing_id); | 974 render_view_host, opener_route_id, proxy_routing_id); |
969 if (success && frame_tree_node_->IsMainFrame()) { | 975 if (success && frame_tree_node_->IsMainFrame()) { |
970 // Don't show the main frame's view until we get a DidNavigate from it. | 976 // Don't show the main frame's view until we get a DidNavigate from it. |
971 render_view_host->GetView()->Hide(); | 977 render_view_host->GetView()->Hide(); |
972 } else if (!swapped_out && pending_render_frame_host_) { | 978 } else if (!swapped_out && pending_render_frame_host_) { |
973 CancelPending(); | 979 CancelPending(); |
974 } | 980 } |
975 routing_id = render_view_host->GetRoutingID(); | 981 routing_id = render_view_host->GetRoutingID(); |
976 } | 982 } |
977 | 983 |
978 // Use this as our new pending RFH if it isn't swapped out. | 984 // Use this as our new pending RFH if it isn't swapped out. |
979 if (!swapped_out) | 985 if (!swapped_out) |
980 pending_render_frame_host_ = new_render_frame_host.Pass(); | 986 pending_render_frame_host_ = new_render_frame_host.Pass(); |
981 | 987 |
| 988 // If a brand new RFH was created, announce it to observers. |
| 989 if (frame_to_announce) |
| 990 render_frame_delegate_->RenderFrameCreated(frame_to_announce); |
| 991 |
982 return routing_id; | 992 return routing_id; |
983 } | 993 } |
984 | 994 |
985 bool RenderFrameHostManager::InitRenderView(RenderViewHost* render_view_host, | 995 bool RenderFrameHostManager::InitRenderView(RenderViewHost* render_view_host, |
986 int opener_route_id, | 996 int opener_route_id, |
987 int proxy_routing_id) { | 997 int proxy_routing_id) { |
988 // We may have initialized this RenderViewHost for another RenderFrameHost. | 998 // We may have initialized this RenderViewHost for another RenderFrameHost. |
989 if (render_view_host->IsRenderViewLive()) | 999 if (render_view_host->IsRenderViewLive()) |
990 return true; | 1000 return true; |
991 | 1001 |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1450 SiteInstance* instance) const { | 1460 SiteInstance* instance) const { |
1451 RenderFrameProxyHostMap::const_iterator iter = | 1461 RenderFrameProxyHostMap::const_iterator iter = |
1452 proxy_hosts_.find(instance->GetId()); | 1462 proxy_hosts_.find(instance->GetId()); |
1453 if (iter != proxy_hosts_.end()) | 1463 if (iter != proxy_hosts_.end()) |
1454 return iter->second; | 1464 return iter->second; |
1455 | 1465 |
1456 return NULL; | 1466 return NULL; |
1457 } | 1467 } |
1458 | 1468 |
1459 } // namespace content | 1469 } // namespace content |
OLD | NEW |