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