| 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 157 |
| 158 // Now that we've created a new renderer, be sure to hide it if it isn't | 158 // Now that we've created a new renderer, be sure to hide it if it isn't |
| 159 // our primary one. Otherwise, we might crash if we try to call Show() | 159 // our primary one. Otherwise, we might crash if we try to call Show() |
| 160 // on it later. | 160 // on it later. |
| 161 if (dest_render_view_host != render_view_host_ && | 161 if (dest_render_view_host != render_view_host_ && |
| 162 dest_render_view_host->GetView()) { | 162 dest_render_view_host->GetView()) { |
| 163 dest_render_view_host->GetView()->Hide(); | 163 dest_render_view_host->GetView()->Hide(); |
| 164 } else { | 164 } else { |
| 165 // This is our primary renderer, notify here as we won't be calling | 165 // This is our primary renderer, notify here as we won't be calling |
| 166 // CommitPending (which does the notify). | 166 // CommitPending (which does the notify). |
| 167 RenderViewHost* null_rvh = NULL; | 167 delegate_->NotifySwappedFromRenderManager(NULL, render_view_host_); |
| 168 std::pair<RenderViewHost*, RenderViewHost*> details = | |
| 169 std::make_pair(null_rvh, render_view_host_); | |
| 170 NotificationService::current()->Notify( | |
| 171 NOTIFICATION_RENDER_VIEW_HOST_CHANGED, | |
| 172 Source<NavigationController>( | |
| 173 &delegate_->GetControllerForRenderManager()), | |
| 174 Details<std::pair<RenderViewHost*, RenderViewHost*> >( | |
| 175 &details)); | |
| 176 } | 168 } |
| 177 } | 169 } |
| 178 | 170 |
| 179 return dest_render_view_host; | 171 return dest_render_view_host; |
| 180 } | 172 } |
| 181 | 173 |
| 182 void RenderViewHostManager::Stop() { | 174 void RenderViewHostManager::Stop() { |
| 183 render_view_host_->Stop(); | 175 render_view_host_->Stop(); |
| 184 | 176 |
| 185 // If we are cross-navigating, we should stop the pending renderers. This | 177 // If we are cross-navigating, we should stop the pending renderers. This |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 } | 751 } |
| 760 | 752 |
| 761 // Make sure the size is up to date. (Fix for bug 1079768.) | 753 // Make sure the size is up to date. (Fix for bug 1079768.) |
| 762 delegate_->UpdateRenderViewSizeForRenderManager(); | 754 delegate_->UpdateRenderViewSizeForRenderManager(); |
| 763 | 755 |
| 764 if (will_focus_location_bar) | 756 if (will_focus_location_bar) |
| 765 delegate_->SetFocusToLocationBar(false); | 757 delegate_->SetFocusToLocationBar(false); |
| 766 else if (focus_render_view && render_view_host_->GetView()) | 758 else if (focus_render_view && render_view_host_->GetView()) |
| 767 RenderWidgetHostViewPort::FromRWHV(render_view_host_->GetView())->Focus(); | 759 RenderWidgetHostViewPort::FromRWHV(render_view_host_->GetView())->Focus(); |
| 768 | 760 |
| 769 std::pair<RenderViewHost*, RenderViewHost*> details = | 761 // Notify that we've swapped RenderViewHosts. We do this |
| 770 std::make_pair(old_render_view_host, render_view_host_); | 762 // before shutting down the RVH so that we can clean up |
| 771 NotificationService::current()->Notify( | 763 // RendererResources related to the RVH first. |
| 772 NOTIFICATION_RENDER_VIEW_HOST_CHANGED, | 764 delegate_->NotifySwappedFromRenderManager(old_render_view_host, |
| 773 Source<NavigationController>( | 765 render_view_host_); |
| 774 &delegate_->GetControllerForRenderManager()), | |
| 775 Details<std::pair<RenderViewHost*, RenderViewHost*> >(&details)); | |
| 776 | 766 |
| 777 // If the pending view was on the swapped out list, we can remove it. | 767 // If the pending view was on the swapped out list, we can remove it. |
| 778 swapped_out_hosts_.erase(render_view_host_->GetSiteInstance()->GetId()); | 768 swapped_out_hosts_.erase(render_view_host_->GetSiteInstance()->GetId()); |
| 779 | 769 |
| 780 // Let the task manager know that we've swapped RenderViewHosts, | |
| 781 // since it might need to update its process groupings. We do this | |
| 782 // before shutting down the RVH so that we can clean up | |
| 783 // RendererResources related to the RVH first. | |
| 784 delegate_->NotifySwappedFromRenderManager(old_render_view_host); | |
| 785 | |
| 786 // If there are no active RVHs in this SiteInstance, it means that | 770 // If there are no active RVHs in this SiteInstance, it means that |
| 787 // this RVH was the last active one in the SiteInstance. Now that we | 771 // this RVH was the last active one in the SiteInstance. Now that we |
| 788 // know that all RVHs are swapped out, we can delete all the RVHs in | 772 // know that all RVHs are swapped out, we can delete all the RVHs in |
| 789 // this SiteInstance. | 773 // this SiteInstance. |
| 790 if (!static_cast<SiteInstanceImpl*>(old_render_view_host->GetSiteInstance())-> | 774 if (!static_cast<SiteInstanceImpl*>(old_render_view_host->GetSiteInstance())-> |
| 791 active_view_count()) { | 775 active_view_count()) { |
| 792 ShutdownRenderViewHostsInSiteInstance( | 776 ShutdownRenderViewHostsInSiteInstance( |
| 793 old_render_view_host->GetSiteInstance()->GetId()); | 777 old_render_view_host->GetSiteInstance()->GetId()); |
| 794 // This is deleted while cleaning up the SitaInstance's views. | 778 // This is deleted while cleaning up the SitaInstance's views. |
| 795 old_render_view_host = NULL; | 779 old_render_view_host = NULL; |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost( | 1045 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost( |
| 1062 SiteInstance* instance) { | 1046 SiteInstance* instance) { |
| 1063 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); | 1047 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); |
| 1064 if (iter != swapped_out_hosts_.end()) | 1048 if (iter != swapped_out_hosts_.end()) |
| 1065 return iter->second; | 1049 return iter->second; |
| 1066 | 1050 |
| 1067 return NULL; | 1051 return NULL; |
| 1068 } | 1052 } |
| 1069 | 1053 |
| 1070 } // namespace content | 1054 } // namespace content |
| OLD | NEW |