OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/web_contents/render_view_host_manager.h" | 5 #include "content/browser/web_contents/render_view_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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 int routing_id, | 76 int routing_id, |
77 int main_frame_routing_id) { | 77 int main_frame_routing_id) { |
78 // Create a RenderViewHost, once we have an instance. It is important to | 78 // Create a RenderViewHost, once we have an instance. It is important to |
79 // immediately give this SiteInstance to a RenderViewHost so that it is | 79 // immediately give this SiteInstance to a RenderViewHost so that it is |
80 // ref counted. | 80 // ref counted. |
81 if (!site_instance) | 81 if (!site_instance) |
82 site_instance = SiteInstance::Create(browser_context); | 82 site_instance = SiteInstance::Create(browser_context); |
83 render_view_host_ = static_cast<RenderViewHostImpl*>( | 83 render_view_host_ = static_cast<RenderViewHostImpl*>( |
84 RenderViewHostFactory::Create( | 84 RenderViewHostFactory::Create( |
85 site_instance, render_view_delegate_, render_widget_delegate_, | 85 site_instance, render_view_delegate_, render_widget_delegate_, |
86 routing_id, main_frame_routing_id, false, delegate_->IsHidden())); | 86 routing_id, main_frame_routing_id, false, |
| 87 delegate_->IsHidden())); |
| 88 render_view_host_->SwapIntoFrameTree(NULL); |
87 | 89 |
88 // Keep track of renderer processes as they start to shut down or are | 90 // Keep track of renderer processes as they start to shut down or are |
89 // crashed/killed. | 91 // crashed/killed. |
90 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSED, | 92 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSED, |
91 NotificationService::AllSources()); | 93 NotificationService::AllSources()); |
92 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSING, | 94 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSING, |
93 NotificationService::AllSources()); | 95 NotificationService::AllSources()); |
94 } | 96 } |
95 | 97 |
96 RenderViewHostImpl* RenderViewHostManager::current_host() const { | 98 RenderViewHostImpl* RenderViewHostManager::current_host() const { |
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 if (will_focus_location_bar) | 731 if (will_focus_location_bar) |
730 delegate_->SetFocusToLocationBar(false); | 732 delegate_->SetFocusToLocationBar(false); |
731 return; | 733 return; |
732 } | 734 } |
733 | 735 |
734 // Remember if the page was focused so we can focus the new renderer in | 736 // Remember if the page was focused so we can focus the new renderer in |
735 // that case. | 737 // that case. |
736 bool focus_render_view = !will_focus_location_bar && | 738 bool focus_render_view = !will_focus_location_bar && |
737 render_view_host_->GetView() && render_view_host_->GetView()->HasFocus(); | 739 render_view_host_->GetView() && render_view_host_->GetView()->HasFocus(); |
738 | 740 |
739 // Swap in the pending view and make it active. | 741 // Swap in the pending view and make it active. Also ensure the FrameTree |
| 742 // stays in sync. |
740 RenderViewHostImpl* old_render_view_host = render_view_host_; | 743 RenderViewHostImpl* old_render_view_host = render_view_host_; |
741 render_view_host_ = pending_render_view_host_; | 744 render_view_host_ = pending_render_view_host_; |
742 pending_render_view_host_ = NULL; | 745 pending_render_view_host_ = NULL; |
| 746 render_view_host_->SwapIntoFrameTree(old_render_view_host); |
743 | 747 |
744 // The process will no longer try to exit, so we can decrement the count. | 748 // The process will no longer try to exit, so we can decrement the count. |
745 render_view_host_->GetProcess()->RemovePendingView(); | 749 render_view_host_->GetProcess()->RemovePendingView(); |
746 | 750 |
747 // If the view is gone, then this RenderViewHost died while it was hidden. | 751 // If the view is gone, then this RenderViewHost died while it was hidden. |
748 // We ignored the RenderProcessGone call at the time, so we should send it now | 752 // We ignored the RenderProcessGone call at the time, so we should send it now |
749 // to make sure the sad tab shows up, etc. | 753 // to make sure the sad tab shows up, etc. |
750 if (render_view_host_->GetView()) | 754 if (render_view_host_->GetView()) |
751 render_view_host_->GetView()->Show(); | 755 render_view_host_->GetView()->Show(); |
752 else | 756 else |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost( | 1065 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost( |
1062 SiteInstance* instance) { | 1066 SiteInstance* instance) { |
1063 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); | 1067 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); |
1064 if (iter != swapped_out_hosts_.end()) | 1068 if (iter != swapped_out_hosts_.end()) |
1065 return iter->second; | 1069 return iter->second; |
1066 | 1070 |
1067 return NULL; | 1071 return NULL; |
1068 } | 1072 } |
1069 | 1073 |
1070 } // namespace content | 1074 } // namespace content |
OLD | NEW |