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

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

Issue 14267002: Change IsSwappedOut to const and do a more restrictive check. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Renaming IsSwappedOut to better reflect what it does. Created 7 years, 8 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
OLDNEW
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/logging.h" 10 #include "base/logging.h"
(...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 pending_render_view_host, 924 pending_render_view_host,
925 render_view_host_); 925 render_view_host_);
926 926
927 // We no longer need to prevent the process from exiting. 927 // We no longer need to prevent the process from exiting.
928 pending_render_view_host->GetProcess()->RemovePendingView(); 928 pending_render_view_host->GetProcess()->RemovePendingView();
929 929
930 // The pending RVH may already be on the swapped out list if we started to 930 // The pending RVH may already be on the swapped out list if we started to
931 // swap it back in and then canceled. If so, make sure it gets swapped out 931 // swap it back in and then canceled. If so, make sure it gets swapped out
932 // again. If it's not on the swapped out list (e.g., aborting a pending 932 // again. If it's not on the swapped out list (e.g., aborting a pending
933 // load), then it's safe to shut down. 933 // load), then it's safe to shut down.
934 if (IsSwappedOut(pending_render_view_host)) { 934 if (IsOnSwappedOutList(pending_render_view_host)) {
935 // Any currently suspended navigations are no longer needed. 935 // Any currently suspended navigations are no longer needed.
936 pending_render_view_host->CancelSuspendedNavigations(); 936 pending_render_view_host->CancelSuspendedNavigations();
937 937
938 // We can pass -1,-1 because there is no pending response in the 938 // We can pass -1,-1 because there is no pending response in the
939 // ResourceDispatcherHost to unpause. 939 // ResourceDispatcherHost to unpause.
940 pending_render_view_host->SwapOut(-1, -1); 940 pending_render_view_host->SwapOut(-1, -1);
941 } else { 941 } else {
942 // We won't be coming back, so shut this one down. 942 // We won't be coming back, so shut this one down.
943 pending_render_view_host->Shutdown(); 943 pending_render_view_host->Shutdown();
944 } 944 }
(...skipping 23 matching lines...) Expand all
968 for (RenderViewHostMap::iterator iter = swapped_out_hosts_.begin(); 968 for (RenderViewHostMap::iterator iter = swapped_out_hosts_.begin();
969 iter != swapped_out_hosts_.end(); 969 iter != swapped_out_hosts_.end();
970 ++iter) { 970 ++iter) {
971 if (iter->second == rvh) { 971 if (iter->second == rvh) {
972 swapped_out_hosts_.erase(iter); 972 swapped_out_hosts_.erase(iter);
973 break; 973 break;
974 } 974 }
975 } 975 }
976 } 976 }
977 977
978 bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) { 978 bool RenderViewHostManager::IsOnSwappedOutList(RenderViewHost* rvh) const {
979 if (!rvh->GetSiteInstance()) 979 if (!rvh->GetSiteInstance())
980 return false; 980 return false;
981 981
982 return swapped_out_hosts_.find(rvh->GetSiteInstance()->GetId()) != 982 RenderViewHostMap::const_iterator iter = swapped_out_hosts_.find(
983 swapped_out_hosts_.end(); 983 rvh->GetSiteInstance()->GetId());
984 if (iter == swapped_out_hosts_.end())
985 return false;
986
987 return iter->second == rvh;
984 } 988 }
985 989
986 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost( 990 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost(
987 SiteInstance* instance) { 991 SiteInstance* instance) {
988 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); 992 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId());
989 if (iter != swapped_out_hosts_.end()) 993 if (iter != swapped_out_hosts_.end())
990 return iter->second; 994 return iter->second;
991 995
992 return NULL; 996 return NULL;
993 } 997 }
994 998
995 } // namespace content 999 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698