Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(596)

Side by Side Diff: content/browser/tab_contents/render_view_host_manager.cc

Issue 7725005: Fix for a memory corruption. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/renderer_host/render_view_host_manager_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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, and duplication in SwapInRenderViewHost.
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 // Shutdown the RVH that will be replaced in the map to avoid a leak.
648 iter->second->Shutdown();
649 }
650 swapped_out_hosts_[old_site_instance_id] = old_render_view_host;
640 } else { 651 } else {
641 old_render_view_host->Shutdown(); 652 old_render_view_host->Shutdown();
642 } 653 }
643 654
644 // Let the task manager know that we've swapped RenderViewHosts, since it 655 // Let the task manager know that we've swapped RenderViewHosts, since it
645 // might need to update its process groupings. 656 // might need to update its process groupings.
646 delegate_->NotifySwappedFromRenderManager(); 657 delegate_->NotifySwappedFromRenderManager();
647 } 658 }
648 659
649 RenderViewHost* RenderViewHostManager::UpdateRendererStateForNavigate( 660 RenderViewHost* RenderViewHostManager::UpdateRendererStateForNavigate(
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 Source<NavigationController>(&delegate_->GetControllerForRenderManager()), 859 Source<NavigationController>(&delegate_->GetControllerForRenderManager()),
849 Details<RenderViewHostSwitchedDetails>(&details)); 860 Details<RenderViewHostSwitchedDetails>(&details));
850 861
851 // If the given RVH was on the swapped out list, we can remove it. 862 // 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()); 863 swapped_out_hosts_.erase(render_view_host_->site_instance()->id());
853 864
854 // If the old RVH is live, we are swapping it out and should keep track of it 865 // 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. 866 // in case we navigate back to it.
856 if (old_render_view_host->IsRenderViewLive()) { 867 if (old_render_view_host->IsRenderViewLive()) {
857 DCHECK(old_render_view_host->is_swapped_out()); 868 DCHECK(old_render_view_host->is_swapped_out());
858 swapped_out_hosts_[old_render_view_host->site_instance()->id()] = 869 // Temp fix for http://crbug.com/90867 until we do a better cleanup to make
859 old_render_view_host; 870 // sure we don't get different rvh instances for the same site instance
871 // in the same rvhmgr.
872 // TODO(creis): Clean this up as well as duplication with CommitPending.
873 int32 old_site_instance_id = old_render_view_host->site_instance()->id();
874 RenderViewHostMap::iterator iter =
875 swapped_out_hosts_.find(old_site_instance_id);
876 if (iter != swapped_out_hosts_.end() &&
877 iter->second != old_render_view_host) {
878 // Shutdown the RVH that will be replaced in the map to avoid a leak.
879 iter->second->Shutdown();
880 }
881 swapped_out_hosts_[old_site_instance_id] = old_render_view_host;
860 } else { 882 } else {
861 old_render_view_host->Shutdown(); 883 old_render_view_host->Shutdown();
862 } 884 }
863 885
864 // Let the task manager know that we've swapped RenderViewHosts, since it 886 // Let the task manager know that we've swapped RenderViewHosts, since it
865 // might need to update its process groupings. 887 // might need to update its process groupings.
866 delegate_->NotifySwappedFromRenderManager(); 888 delegate_->NotifySwappedFromRenderManager();
867 } 889 }
868 890
869 bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) { 891 bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) {
870 if (!rvh->site_instance()) 892 if (!rvh->site_instance())
871 return false; 893 return false;
872 894
873 return swapped_out_hosts_.find(rvh->site_instance()->id()) != 895 return swapped_out_hosts_.find(rvh->site_instance()->id()) !=
874 swapped_out_hosts_.end(); 896 swapped_out_hosts_.end();
875 } 897 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_view_host_manager_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698