OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/tab_contents/render_view_host_manager.h" | 5 #include "content/browser/tab_contents/render_view_host_manager.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "content/browser/content_browser_client.h" | 9 #include "content/browser/content_browser_client.h" |
10 #include "content/browser/renderer_host/render_view_host.h" | 10 #include "content/browser/renderer_host/render_view_host.h" |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
628 Source<NavigationController>(&delegate_->GetControllerForRenderManager()), | 628 Source<NavigationController>(&delegate_->GetControllerForRenderManager()), |
629 Details<RenderViewHostSwitchedDetails>(&details)); | 629 Details<RenderViewHostSwitchedDetails>(&details)); |
630 | 630 |
631 // If the pending view was on the swapped out list, we can remove it. | 631 // If the pending view was on the swapped out list, we can remove it. |
632 swapped_out_hosts_.erase(render_view_host_->site_instance()->id()); | 632 swapped_out_hosts_.erase(render_view_host_->site_instance()->id()); |
633 | 633 |
634 // If the old RVH is live, we are swapping it out and should keep track of it | 634 // If the old RVH is live, we are swapping it out and should keep track of it |
635 // in case we navigate back to it. | 635 // in case we navigate back to it. |
636 if (old_render_view_host->IsRenderViewLive()) { | 636 if (old_render_view_host->IsRenderViewLive()) { |
637 DCHECK(old_render_view_host->is_swapped_out()); | 637 DCHECK(old_render_view_host->is_swapped_out()); |
638 swapped_out_hosts_[old_render_view_host->site_instance()->id()] = | 638 // Temp fix for http://crbug.com/90867 until we do a better cleanup to make |
639 old_render_view_host; | 639 // sure we don't get different rvh instances for the same site instance |
640 // in the same rvhmgr. | |
641 // TODO(creis): Clean this up. | |
Charlie Reis
2011/08/24 21:18:52
Ugh, I'll try to fix the duplicated code in my nex
MAD
2011/08/24 21:31:07
Added a note, thought you already had one here:
v
| |
642 int32 old_site_instance_id = old_render_view_host->site_instance()->id(); | |
643 RenderViewHostMap::iterator iter = | |
644 swapped_out_hosts_.find(old_site_instance_id); | |
645 if (iter != swapped_out_hosts_.end() && | |
646 iter->second != old_render_view_host) { | |
647 iter->second->Shutdown(); | |
Charlie Reis
2011/08/24 21:18:52
Please add just a little more comment here, like "
MAD
2011/08/24 21:31:07
Done.
| |
648 } | |
649 swapped_out_hosts_[old_site_instance_id] = old_render_view_host; | |
640 } else { | 650 } else { |
641 old_render_view_host->Shutdown(); | 651 old_render_view_host->Shutdown(); |
642 } | 652 } |
643 | 653 |
644 // Let the task manager know that we've swapped RenderViewHosts, since it | 654 // Let the task manager know that we've swapped RenderViewHosts, since it |
645 // might need to update its process groupings. | 655 // might need to update its process groupings. |
646 delegate_->NotifySwappedFromRenderManager(); | 656 delegate_->NotifySwappedFromRenderManager(); |
647 } | 657 } |
648 | 658 |
649 RenderViewHost* RenderViewHostManager::UpdateRendererStateForNavigate( | 659 RenderViewHost* RenderViewHostManager::UpdateRendererStateForNavigate( |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
848 Source<NavigationController>(&delegate_->GetControllerForRenderManager()), | 858 Source<NavigationController>(&delegate_->GetControllerForRenderManager()), |
849 Details<RenderViewHostSwitchedDetails>(&details)); | 859 Details<RenderViewHostSwitchedDetails>(&details)); |
850 | 860 |
851 // If the given RVH was on the swapped out list, we can remove it. | 861 // If the given RVH was on the swapped out list, we can remove it. |
852 swapped_out_hosts_.erase(render_view_host_->site_instance()->id()); | 862 swapped_out_hosts_.erase(render_view_host_->site_instance()->id()); |
853 | 863 |
854 // If the old RVH is live, we are swapping it out and should keep track of it | 864 // If the old RVH is live, we are swapping it out and should keep track of it |
855 // in case we navigate back to it. | 865 // in case we navigate back to it. |
856 if (old_render_view_host->IsRenderViewLive()) { | 866 if (old_render_view_host->IsRenderViewLive()) { |
857 DCHECK(old_render_view_host->is_swapped_out()); | 867 DCHECK(old_render_view_host->is_swapped_out()); |
858 swapped_out_hosts_[old_render_view_host->site_instance()->id()] = | 868 // Temp fix for http://crbug.com/90867 until we do a better cleanup to make |
859 old_render_view_host; | 869 // sure we don't get different rvh instances for the same site instance |
870 // in the same rvhmgr. | |
871 // TODO(creis): Clean this up. | |
872 int32 old_site_instance_id = old_render_view_host->site_instance()->id(); | |
873 RenderViewHostMap::iterator iter = | |
874 swapped_out_hosts_.find(old_site_instance_id); | |
875 if (iter != swapped_out_hosts_.end() && | |
876 iter->second != old_render_view_host) { | |
877 iter->second->Shutdown(); | |
878 } | |
879 swapped_out_hosts_[old_site_instance_id] = old_render_view_host; | |
860 } else { | 880 } else { |
861 old_render_view_host->Shutdown(); | 881 old_render_view_host->Shutdown(); |
862 } | 882 } |
863 | 883 |
864 // Let the task manager know that we've swapped RenderViewHosts, since it | 884 // Let the task manager know that we've swapped RenderViewHosts, since it |
865 // might need to update its process groupings. | 885 // might need to update its process groupings. |
866 delegate_->NotifySwappedFromRenderManager(); | 886 delegate_->NotifySwappedFromRenderManager(); |
867 } | 887 } |
868 | 888 |
869 bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) { | 889 bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) { |
870 if (!rvh->site_instance()) | 890 if (!rvh->site_instance()) |
871 return false; | 891 return false; |
872 | 892 |
873 return swapped_out_hosts_.find(rvh->site_instance()->id()) != | 893 return swapped_out_hosts_.find(rvh->site_instance()->id()) != |
874 swapped_out_hosts_.end(); | 894 swapped_out_hosts_.end(); |
875 } | 895 } |
OLD | NEW |