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

Side by Side Diff: content/browser/frame_host/render_frame_host_manager.cc

Issue 92153003: Rename RenderViewHostManager to RenderFrameHostManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/frame_host/render_view_host_manager.h" 5 #include "content/browser/frame_host/render_frame_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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "content/browser/child_process_security_policy_impl.h" 12 #include "content/browser/child_process_security_policy_impl.h"
13 #include "content/browser/devtools/render_view_devtools_agent_host.h" 13 #include "content/browser/devtools/render_view_devtools_agent_host.h"
14 #include "content/browser/frame_host/interstitial_page_impl.h" 14 #include "content/browser/frame_host/interstitial_page_impl.h"
15 #include "content/browser/frame_host/navigation_controller_impl.h" 15 #include "content/browser/frame_host/navigation_controller_impl.h"
(...skipping 10 matching lines...) Expand all
26 #include "content/public/browser/notification_service.h" 26 #include "content/public/browser/notification_service.h"
27 #include "content/public/browser/notification_types.h" 27 #include "content/public/browser/notification_types.h"
28 #include "content/public/browser/render_widget_host_iterator.h" 28 #include "content/public/browser/render_widget_host_iterator.h"
29 #include "content/public/browser/user_metrics.h" 29 #include "content/public/browser/user_metrics.h"
30 #include "content/public/browser/web_ui_controller.h" 30 #include "content/public/browser/web_ui_controller.h"
31 #include "content/public/common/content_switches.h" 31 #include "content/public/common/content_switches.h"
32 #include "content/public/common/url_constants.h" 32 #include "content/public/common/url_constants.h"
33 33
34 namespace content { 34 namespace content {
35 35
36 RenderViewHostManager::PendingNavigationParams::PendingNavigationParams() 36 RenderFrameHostManager::PendingNavigationParams::PendingNavigationParams()
37 : is_transfer(false), frame_id(-1), should_replace_current_entry(false) { 37 : is_transfer(false), frame_id(-1), should_replace_current_entry(false) {
38 } 38 }
39 39
40 RenderViewHostManager::PendingNavigationParams::PendingNavigationParams( 40 RenderFrameHostManager::PendingNavigationParams::PendingNavigationParams(
41 const GlobalRequestID& global_request_id, 41 const GlobalRequestID& global_request_id,
42 bool is_transfer, 42 bool is_transfer,
43 const std::vector<GURL>& transfer_url_chain, 43 const std::vector<GURL>& transfer_url_chain,
44 Referrer referrer, 44 Referrer referrer,
45 PageTransition page_transition, 45 PageTransition page_transition,
46 int64 frame_id, 46 int64 frame_id,
47 bool should_replace_current_entry) 47 bool should_replace_current_entry)
48 : global_request_id(global_request_id), 48 : global_request_id(global_request_id),
49 is_transfer(is_transfer), 49 is_transfer(is_transfer),
50 transfer_url_chain(transfer_url_chain), 50 transfer_url_chain(transfer_url_chain),
51 referrer(referrer), 51 referrer(referrer),
52 page_transition(page_transition), 52 page_transition(page_transition),
53 frame_id(frame_id), 53 frame_id(frame_id),
54 should_replace_current_entry(should_replace_current_entry) { 54 should_replace_current_entry(should_replace_current_entry) {
55 } 55 }
56 56
57 RenderViewHostManager::PendingNavigationParams::~PendingNavigationParams() {} 57 RenderFrameHostManager::PendingNavigationParams::~PendingNavigationParams() {}
58 58
59 RenderViewHostManager::RenderViewHostManager( 59 RenderFrameHostManager::RenderFrameHostManager(
60 RenderViewHostDelegate* render_view_delegate, 60 RenderViewHostDelegate* render_view_delegate,
61 RenderWidgetHostDelegate* render_widget_delegate, 61 RenderWidgetHostDelegate* render_widget_delegate,
62 Delegate* delegate) 62 Delegate* delegate)
63 : delegate_(delegate), 63 : delegate_(delegate),
64 cross_navigation_pending_(false), 64 cross_navigation_pending_(false),
65 render_view_delegate_(render_view_delegate), 65 render_view_delegate_(render_view_delegate),
66 render_widget_delegate_(render_widget_delegate), 66 render_widget_delegate_(render_widget_delegate),
67 render_view_host_(NULL), 67 render_view_host_(NULL),
68 pending_render_view_host_(NULL), 68 pending_render_view_host_(NULL),
69 interstitial_page_(NULL) { 69 interstitial_page_(NULL) {
70 } 70 }
71 71
72 RenderViewHostManager::~RenderViewHostManager() { 72 RenderFrameHostManager::~RenderFrameHostManager() {
73 if (pending_render_view_host_) 73 if (pending_render_view_host_)
74 CancelPending(); 74 CancelPending();
75 75
76 // We should always have a main RenderViewHost except in some tests. 76 // We should always have a main RenderViewHost except in some tests.
77 RenderViewHostImpl* render_view_host = render_view_host_; 77 RenderViewHostImpl* render_view_host = render_view_host_;
78 render_view_host_ = NULL; 78 render_view_host_ = NULL;
79 if (render_view_host) 79 if (render_view_host)
80 render_view_host->Shutdown(); 80 render_view_host->Shutdown();
81 81
82 // Shut down any swapped out RenderViewHosts. 82 // Shut down any swapped out RenderViewHosts.
83 for (RenderViewHostMap::iterator iter = swapped_out_hosts_.begin(); 83 for (RenderViewHostMap::iterator iter = swapped_out_hosts_.begin();
84 iter != swapped_out_hosts_.end(); 84 iter != swapped_out_hosts_.end();
85 ++iter) { 85 ++iter) {
86 iter->second->Shutdown(); 86 iter->second->Shutdown();
87 } 87 }
88 } 88 }
89 89
90 void RenderViewHostManager::Init(BrowserContext* browser_context, 90 void RenderFrameHostManager::Init(BrowserContext* browser_context,
91 SiteInstance* site_instance, 91 SiteInstance* site_instance,
92 int routing_id, 92 int routing_id,
93 int main_frame_routing_id) { 93 int main_frame_routing_id) {
94 // Create a RenderViewHost, once we have an instance. It is important to 94 // Create a RenderViewHost, once we have an instance. It is important to
95 // immediately give this SiteInstance to a RenderViewHost so that it is 95 // immediately give this SiteInstance to a RenderViewHost so that it is
96 // ref counted. 96 // ref counted.
97 if (!site_instance) 97 if (!site_instance)
98 site_instance = SiteInstance::Create(browser_context); 98 site_instance = SiteInstance::Create(browser_context);
99 render_view_host_ = static_cast<RenderViewHostImpl*>( 99 render_view_host_ = static_cast<RenderViewHostImpl*>(
100 RenderViewHostFactory::Create( 100 RenderViewHostFactory::Create(
101 site_instance, render_view_delegate_, render_widget_delegate_, 101 site_instance, render_view_delegate_, render_widget_delegate_,
102 routing_id, main_frame_routing_id, false, 102 routing_id, main_frame_routing_id, false,
103 delegate_->IsHidden())); 103 delegate_->IsHidden()));
104 render_view_host_->AttachToFrameTree(); 104 render_view_host_->AttachToFrameTree();
105 105
106 // Keep track of renderer processes as they start to shut down or are 106 // Keep track of renderer processes as they start to shut down or are
107 // crashed/killed. 107 // crashed/killed.
108 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSED, 108 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSED,
109 NotificationService::AllSources()); 109 NotificationService::AllSources());
110 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSING, 110 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSING,
111 NotificationService::AllSources()); 111 NotificationService::AllSources());
112 } 112 }
113 113
114 RenderViewHostImpl* RenderViewHostManager::current_host() const { 114 RenderViewHostImpl* RenderFrameHostManager::current_host() const {
115 return render_view_host_; 115 return render_view_host_;
116 } 116 }
117 117
118 RenderViewHostImpl* RenderViewHostManager::pending_render_view_host() const { 118 RenderViewHostImpl* RenderFrameHostManager::pending_render_view_host() const {
119 return pending_render_view_host_; 119 return pending_render_view_host_;
120 } 120 }
121 121
122 RenderWidgetHostView* RenderViewHostManager::GetRenderWidgetHostView() const { 122 RenderWidgetHostView* RenderFrameHostManager::GetRenderWidgetHostView() const {
123 if (interstitial_page_) 123 if (interstitial_page_)
124 return interstitial_page_->GetView(); 124 return interstitial_page_->GetView();
125 if (!render_view_host_) 125 if (!render_view_host_)
126 return NULL; 126 return NULL;
127 return render_view_host_->GetView(); 127 return render_view_host_->GetView();
128 } 128 }
129 129
130 void RenderViewHostManager::SetPendingWebUI(const NavigationEntryImpl& entry) { 130 void RenderFrameHostManager::SetPendingWebUI(const NavigationEntryImpl& entry) {
131 pending_web_ui_.reset( 131 pending_web_ui_.reset(
132 delegate_->CreateWebUIForRenderManager(entry.GetURL())); 132 delegate_->CreateWebUIForRenderManager(entry.GetURL()));
133 pending_and_current_web_ui_.reset(); 133 pending_and_current_web_ui_.reset();
134 134
135 // If we have assigned (zero or more) bindings to this NavigationEntry in the 135 // If we have assigned (zero or more) bindings to this NavigationEntry in the
136 // past, make sure we're not granting it different bindings than it had 136 // past, make sure we're not granting it different bindings than it had
137 // before. If so, note it and don't give it any bindings, to avoid a 137 // before. If so, note it and don't give it any bindings, to avoid a
138 // potential privilege escalation. 138 // potential privilege escalation.
139 if (pending_web_ui_.get() && 139 if (pending_web_ui_.get() &&
140 entry.bindings() != NavigationEntryImpl::kInvalidBindings && 140 entry.bindings() != NavigationEntryImpl::kInvalidBindings &&
141 pending_web_ui_->GetBindings() != entry.bindings()) { 141 pending_web_ui_->GetBindings() != entry.bindings()) {
142 RecordAction(UserMetricsAction("ProcessSwapBindingsMismatch_RVHM")); 142 RecordAction(UserMetricsAction("ProcessSwapBindingsMismatch_RVHM"));
143 pending_web_ui_.reset(); 143 pending_web_ui_.reset();
144 } 144 }
145 } 145 }
146 146
147 RenderViewHostImpl* RenderViewHostManager::Navigate( 147 RenderViewHostImpl* RenderFrameHostManager::Navigate(
148 const NavigationEntryImpl& entry) { 148 const NavigationEntryImpl& entry) {
149 TRACE_EVENT0("browser", "RenderViewHostManager:Navigate"); 149 TRACE_EVENT0("browser", "RenderFrameHostManager:Navigate");
150 // Create a pending RenderViewHost. It will give us the one we should use 150 // Create a pending RenderViewHost. It will give us the one we should use
151 RenderViewHostImpl* dest_render_view_host = 151 RenderViewHostImpl* dest_render_view_host =
152 static_cast<RenderViewHostImpl*>(UpdateRendererStateForNavigate(entry)); 152 static_cast<RenderViewHostImpl*>(UpdateRendererStateForNavigate(entry));
153 if (!dest_render_view_host) 153 if (!dest_render_view_host)
154 return NULL; // We weren't able to create a pending render view host. 154 return NULL; // We weren't able to create a pending render view host.
155 155
156 // If the current render_view_host_ isn't live, we should create it so 156 // If the current render_view_host_ isn't live, we should create it so
157 // that we don't show a sad tab while the dest_render_view_host fetches 157 // that we don't show a sad tab while the dest_render_view_host fetches
158 // its first page. (Bug 1145340) 158 // its first page. (Bug 1145340)
159 if (dest_render_view_host != render_view_host_ && 159 if (dest_render_view_host != render_view_host_ &&
(...skipping 22 matching lines...) Expand all
182 } else { 182 } else {
183 // This is our primary renderer, notify here as we won't be calling 183 // This is our primary renderer, notify here as we won't be calling
184 // CommitPending (which does the notify). 184 // CommitPending (which does the notify).
185 delegate_->NotifySwappedFromRenderManager(NULL, render_view_host_); 185 delegate_->NotifySwappedFromRenderManager(NULL, render_view_host_);
186 } 186 }
187 } 187 }
188 188
189 return dest_render_view_host; 189 return dest_render_view_host;
190 } 190 }
191 191
192 void RenderViewHostManager::Stop() { 192 void RenderFrameHostManager::Stop() {
193 render_view_host_->Stop(); 193 render_view_host_->Stop();
194 194
195 // If we are cross-navigating, we should stop the pending renderers. This 195 // If we are cross-navigating, we should stop the pending renderers. This
196 // will lead to a DidFailProvisionalLoad, which will properly destroy them. 196 // will lead to a DidFailProvisionalLoad, which will properly destroy them.
197 if (cross_navigation_pending_) { 197 if (cross_navigation_pending_) {
198 pending_render_view_host_->Send( 198 pending_render_view_host_->Send(
199 new ViewMsg_Stop(pending_render_view_host_->GetRoutingID())); 199 new ViewMsg_Stop(pending_render_view_host_->GetRoutingID()));
200 } 200 }
201 } 201 }
202 202
203 void RenderViewHostManager::SetIsLoading(bool is_loading) { 203 void RenderFrameHostManager::SetIsLoading(bool is_loading) {
204 render_view_host_->SetIsLoading(is_loading); 204 render_view_host_->SetIsLoading(is_loading);
205 if (pending_render_view_host_) 205 if (pending_render_view_host_)
206 pending_render_view_host_->SetIsLoading(is_loading); 206 pending_render_view_host_->SetIsLoading(is_loading);
207 } 207 }
208 208
209 bool RenderViewHostManager::ShouldCloseTabOnUnresponsiveRenderer() { 209 bool RenderFrameHostManager::ShouldCloseTabOnUnresponsiveRenderer() {
210 if (!cross_navigation_pending_) 210 if (!cross_navigation_pending_)
211 return true; 211 return true;
212 212
213 // We should always have a pending RVH when there's a cross-process navigation 213 // We should always have a pending RVH when there's a cross-process navigation
214 // in progress. Sanity check this for http://crbug.com/276333. 214 // in progress. Sanity check this for http://crbug.com/276333.
215 CHECK(pending_render_view_host_); 215 CHECK(pending_render_view_host_);
216 216
217 // If the tab becomes unresponsive during {before}unload while doing a 217 // If the tab becomes unresponsive during {before}unload while doing a
218 // cross-site navigation, proceed with the navigation. (This assumes that 218 // cross-site navigation, proceed with the navigation. (This assumes that
219 // the pending RenderViewHost is still responsive.) 219 // the pending RenderViewHost is still responsive.)
(...skipping 11 matching lines...) Expand all
231 // that the beforeunload handler will later finish and possibly return 231 // that the beforeunload handler will later finish and possibly return
232 // false (meaning the navigation should not proceed), but we'll ignore it 232 // false (meaning the navigation should not proceed), but we'll ignore it
233 // in this case because it took too long. 233 // in this case because it took too long.
234 if (pending_render_view_host_->are_navigations_suspended()) 234 if (pending_render_view_host_->are_navigations_suspended())
235 pending_render_view_host_->SetNavigationsSuspended( 235 pending_render_view_host_->SetNavigationsSuspended(
236 false, base::TimeTicks::Now()); 236 false, base::TimeTicks::Now());
237 } 237 }
238 return false; 238 return false;
239 } 239 }
240 240
241 void RenderViewHostManager::SwappedOut(RenderViewHost* render_view_host) { 241 void RenderFrameHostManager::SwappedOut(RenderViewHost* render_view_host) {
242 // Make sure this is from our current RVH, and that we have a pending 242 // Make sure this is from our current RVH, and that we have a pending
243 // navigation from OnCrossSiteResponse. (There may be no pending navigation 243 // navigation from OnCrossSiteResponse. (There may be no pending navigation
244 // for data URLs that don't make network requests, for example.) If not, 244 // for data URLs that don't make network requests, for example.) If not,
245 // just return early and ignore. 245 // just return early and ignore.
246 if (render_view_host != render_view_host_ || !pending_nav_params_.get()) { 246 if (render_view_host != render_view_host_ || !pending_nav_params_.get()) {
247 pending_nav_params_.reset(); 247 pending_nav_params_.reset();
248 return; 248 return;
249 } 249 }
250 250
251 // Now that the unload handler has run, we need to either initiate the 251 // Now that the unload handler has run, we need to either initiate the
(...skipping 24 matching lines...) Expand all
276 } else if (pending_render_view_host_) { 276 } else if (pending_render_view_host_) {
277 RenderProcessHostImpl* pending_process = 277 RenderProcessHostImpl* pending_process =
278 static_cast<RenderProcessHostImpl*>( 278 static_cast<RenderProcessHostImpl*>(
279 pending_render_view_host_->GetProcess()); 279 pending_render_view_host_->GetProcess());
280 pending_process->ResumeDeferredNavigation( 280 pending_process->ResumeDeferredNavigation(
281 pending_nav_params_->global_request_id); 281 pending_nav_params_->global_request_id);
282 } 282 }
283 pending_nav_params_.reset(); 283 pending_nav_params_.reset();
284 } 284 }
285 285
286 void RenderViewHostManager::DidNavigateMainFrame( 286 void RenderFrameHostManager::DidNavigateMainFrame(
287 RenderViewHost* render_view_host) { 287 RenderViewHost* render_view_host) {
288 if (!cross_navigation_pending_) { 288 if (!cross_navigation_pending_) {
289 DCHECK(!pending_render_view_host_); 289 DCHECK(!pending_render_view_host_);
290 290
291 // We should only hear this from our current renderer. 291 // We should only hear this from our current renderer.
292 DCHECK(render_view_host == render_view_host_); 292 DCHECK(render_view_host == render_view_host_);
293 293
294 // Even when there is no pending RVH, there may be a pending Web UI. 294 // Even when there is no pending RVH, there may be a pending Web UI.
295 if (pending_web_ui()) 295 if (pending_web_ui())
296 CommitPending(); 296 CommitPending();
(...skipping 14 matching lines...) Expand all
311 // A navigation in the original page has taken place. Cancel the pending 311 // A navigation in the original page has taken place. Cancel the pending
312 // one. 312 // one.
313 CancelPending(); 313 CancelPending();
314 cross_navigation_pending_ = false; 314 cross_navigation_pending_ = false;
315 } else { 315 } else {
316 // No one else should be sending us DidNavigate in this state. 316 // No one else should be sending us DidNavigate in this state.
317 DCHECK(false); 317 DCHECK(false);
318 } 318 }
319 } 319 }
320 320
321 void RenderViewHostManager::DidDisownOpener(RenderViewHost* render_view_host) { 321 void RenderFrameHostManager::DidDisownOpener(RenderViewHost* render_view_host) {
322 // Notify all swapped out hosts, including the pending RVH. 322 // Notify all swapped out hosts, including the pending RVH.
323 for (RenderViewHostMap::iterator iter = swapped_out_hosts_.begin(); 323 for (RenderViewHostMap::iterator iter = swapped_out_hosts_.begin();
324 iter != swapped_out_hosts_.end(); 324 iter != swapped_out_hosts_.end();
325 ++iter) { 325 ++iter) {
326 DCHECK_NE(iter->second->GetSiteInstance(), 326 DCHECK_NE(iter->second->GetSiteInstance(),
327 current_host()->GetSiteInstance()); 327 current_host()->GetSiteInstance());
328 iter->second->DisownOpener(); 328 iter->second->DisownOpener();
329 } 329 }
330 } 330 }
331 331
332 void RenderViewHostManager::RendererAbortedProvisionalLoad( 332 void RenderFrameHostManager::RendererAbortedProvisionalLoad(
333 RenderViewHost* render_view_host) { 333 RenderViewHost* render_view_host) {
334 // We used to cancel the pending renderer here for cross-site downloads. 334 // We used to cancel the pending renderer here for cross-site downloads.
335 // However, it's not safe to do that because the download logic repeatedly 335 // However, it's not safe to do that because the download logic repeatedly
336 // looks for this WebContents based on a render view ID. Instead, we just 336 // looks for this WebContents based on a render view ID. Instead, we just
337 // leave the pending renderer around until the next navigation event 337 // leave the pending renderer around until the next navigation event
338 // (Navigate, DidNavigate, etc), which will clean it up properly. 338 // (Navigate, DidNavigate, etc), which will clean it up properly.
339 // TODO(creis): All of this will go away when we move the cross-site logic 339 // TODO(creis): All of this will go away when we move the cross-site logic
340 // to ResourceDispatcherHost, so that we intercept responses rather than 340 // to ResourceDispatcherHost, so that we intercept responses rather than
341 // navigation events. (That's necessary to support onunload anyway.) Once 341 // navigation events. (That's necessary to support onunload anyway.) Once
342 // we've made that change, we won't create a pending renderer until we know 342 // we've made that change, we won't create a pending renderer until we know
343 // the response is not a download. 343 // the response is not a download.
344 } 344 }
345 345
346 void RenderViewHostManager::RendererProcessClosing( 346 void RenderFrameHostManager::RendererProcessClosing(
347 RenderProcessHost* render_process_host) { 347 RenderProcessHost* render_process_host) {
348 // Remove any swapped out RVHs from this process, so that we don't try to 348 // Remove any swapped out RVHs from this process, so that we don't try to
349 // swap them back in while the process is exiting. Start by finding them, 349 // swap them back in while the process is exiting. Start by finding them,
350 // since there could be more than one. 350 // since there could be more than one.
351 std::list<int> ids_to_remove; 351 std::list<int> ids_to_remove;
352 for (RenderViewHostMap::iterator iter = swapped_out_hosts_.begin(); 352 for (RenderViewHostMap::iterator iter = swapped_out_hosts_.begin();
353 iter != swapped_out_hosts_.end(); 353 iter != swapped_out_hosts_.end();
354 ++iter) { 354 ++iter) {
355 if (iter->second->GetProcess() == render_process_host) 355 if (iter->second->GetProcess() == render_process_host)
356 ids_to_remove.push_back(iter->first); 356 ids_to_remove.push_back(iter->first);
357 } 357 }
358 358
359 // Now delete them. 359 // Now delete them.
360 while (!ids_to_remove.empty()) { 360 while (!ids_to_remove.empty()) {
361 swapped_out_hosts_[ids_to_remove.back()]->Shutdown(); 361 swapped_out_hosts_[ids_to_remove.back()]->Shutdown();
362 swapped_out_hosts_.erase(ids_to_remove.back()); 362 swapped_out_hosts_.erase(ids_to_remove.back());
363 ids_to_remove.pop_back(); 363 ids_to_remove.pop_back();
364 } 364 }
365 } 365 }
366 366
367 void RenderViewHostManager::ShouldClosePage( 367 void RenderFrameHostManager::ShouldClosePage(
368 bool for_cross_site_transition, 368 bool for_cross_site_transition,
369 bool proceed, 369 bool proceed,
370 const base::TimeTicks& proceed_time) { 370 const base::TimeTicks& proceed_time) {
371 if (for_cross_site_transition) { 371 if (for_cross_site_transition) {
372 // Ignore if we're not in a cross-site navigation. 372 // Ignore if we're not in a cross-site navigation.
373 if (!cross_navigation_pending_) 373 if (!cross_navigation_pending_)
374 return; 374 return;
375 375
376 if (proceed) { 376 if (proceed) {
377 // Ok to unload the current page, so proceed with the cross-site 377 // Ok to unload the current page, so proceed with the cross-site
(...skipping 24 matching lines...) Expand all
402 CancelPending(); 402 CancelPending();
403 cross_navigation_pending_ = false; 403 cross_navigation_pending_ = false;
404 } 404 }
405 405
406 // This is not a cross-site navigation, the tab is being closed. 406 // This is not a cross-site navigation, the tab is being closed.
407 render_view_host_->ClosePage(); 407 render_view_host_->ClosePage();
408 } 408 }
409 } 409 }
410 } 410 }
411 411
412 void RenderViewHostManager::OnCrossSiteResponse( 412 void RenderFrameHostManager::OnCrossSiteResponse(
413 RenderViewHost* pending_render_view_host, 413 RenderViewHost* pending_render_view_host,
414 const GlobalRequestID& global_request_id, 414 const GlobalRequestID& global_request_id,
415 bool is_transfer, 415 bool is_transfer,
416 const std::vector<GURL>& transfer_url_chain, 416 const std::vector<GURL>& transfer_url_chain,
417 const Referrer& referrer, 417 const Referrer& referrer,
418 PageTransition page_transition, 418 PageTransition page_transition,
419 int64 frame_id, 419 int64 frame_id,
420 bool should_replace_current_entry) { 420 bool should_replace_current_entry) {
421 // This should be called either when the pending RVH is ready to commit or 421 // This should be called either when the pending RVH is ready to commit or
422 // when we realize that the current RVH's request requires a transfer. 422 // when we realize that the current RVH's request requires a transfer.
423 DCHECK( 423 DCHECK(
424 pending_render_view_host == pending_render_view_host_ || 424 pending_render_view_host == pending_render_view_host_ ||
425 pending_render_view_host == render_view_host_); 425 pending_render_view_host == render_view_host_);
426 426
427 // TODO(creis): Eventually we will want to check all navigation responses 427 // TODO(creis): Eventually we will want to check all navigation responses
428 // here, but currently we pass information for a transfer if 428 // here, but currently we pass information for a transfer if
429 // ShouldSwapProcessesForRedirect returned true in the network stack. 429 // ShouldSwapProcessesForRedirect returned true in the network stack.
430 // In that case, we should set up a transfer after the unload handler runs. 430 // In that case, we should set up a transfer after the unload handler runs.
431 // If is_transfer is false, we will just run the unload handler and resume. 431 // If is_transfer is false, we will just run the unload handler and resume.
432 pending_nav_params_.reset(new PendingNavigationParams( 432 pending_nav_params_.reset(new PendingNavigationParams(
433 global_request_id, is_transfer, transfer_url_chain, referrer, 433 global_request_id, is_transfer, transfer_url_chain, referrer,
434 page_transition, frame_id, should_replace_current_entry)); 434 page_transition, frame_id, should_replace_current_entry));
435 435
436 // Run the unload handler of the current page. 436 // Run the unload handler of the current page.
437 SwapOutOldPage(); 437 SwapOutOldPage();
438 } 438 }
439 439
440 void RenderViewHostManager::SwapOutOldPage() { 440 void RenderFrameHostManager::SwapOutOldPage() {
441 // Should only see this while we have a pending renderer or transfer. 441 // Should only see this while we have a pending renderer or transfer.
442 CHECK(cross_navigation_pending_ || pending_nav_params_.get()); 442 CHECK(cross_navigation_pending_ || pending_nav_params_.get());
443 443
444 // Tell the renderer to suppress any further modal dialogs so that we can swap 444 // Tell the renderer to suppress any further modal dialogs so that we can swap
445 // it out. This must be done before canceling any current dialog, in case 445 // it out. This must be done before canceling any current dialog, in case
446 // there is a loop creating additional dialogs. 446 // there is a loop creating additional dialogs.
447 render_view_host_->SuppressDialogsUntilSwapOut(); 447 render_view_host_->SuppressDialogsUntilSwapOut();
448 448
449 // Now close any modal dialogs that would prevent us from swapping out. This 449 // Now close any modal dialogs that would prevent us from swapping out. This
450 // must be done separately from SwapOut, so that the PageGroupLoadDeferrer is 450 // must be done separately from SwapOut, so that the PageGroupLoadDeferrer is
451 // no longer on the stack when we send the SwapOut message. 451 // no longer on the stack when we send the SwapOut message.
452 delegate_->CancelModalDialogsForRenderManager(); 452 delegate_->CancelModalDialogsForRenderManager();
453 453
454 // Tell the old renderer it is being swapped out. This will fire the unload 454 // Tell the old renderer it is being swapped out. This will fire the unload
455 // handler (without firing the beforeunload handler a second time). When the 455 // handler (without firing the beforeunload handler a second time). When the
456 // unload handler finishes and the navigation completes, we will send a 456 // unload handler finishes and the navigation completes, we will send a
457 // message to the ResourceDispatcherHost, allowing the pending RVH's response 457 // message to the ResourceDispatcherHost, allowing the pending RVH's response
458 // to resume. 458 // to resume.
459 render_view_host_->SwapOut(); 459 render_view_host_->SwapOut();
460 460
461 // ResourceDispatcherHost has told us to run the onunload handler, which 461 // ResourceDispatcherHost has told us to run the onunload handler, which
462 // means it is not a download or unsafe page, and we are going to perform the 462 // means it is not a download or unsafe page, and we are going to perform the
463 // navigation. Thus, we no longer need to remember that the RenderViewHost 463 // navigation. Thus, we no longer need to remember that the RenderViewHost
464 // is part of a pending cross-site request. 464 // is part of a pending cross-site request.
465 if (pending_render_view_host_) 465 if (pending_render_view_host_)
466 pending_render_view_host_->SetHasPendingCrossSiteRequest(false); 466 pending_render_view_host_->SetHasPendingCrossSiteRequest(false);
467 } 467 }
468 468
469 void RenderViewHostManager::Observe( 469 void RenderFrameHostManager::Observe(
470 int type, 470 int type,
471 const NotificationSource& source, 471 const NotificationSource& source,
472 const NotificationDetails& details) { 472 const NotificationDetails& details) {
473 switch (type) { 473 switch (type) {
474 case NOTIFICATION_RENDERER_PROCESS_CLOSED: 474 case NOTIFICATION_RENDERER_PROCESS_CLOSED:
475 case NOTIFICATION_RENDERER_PROCESS_CLOSING: 475 case NOTIFICATION_RENDERER_PROCESS_CLOSING:
476 RendererProcessClosing( 476 RendererProcessClosing(
477 Source<RenderProcessHost>(source).ptr()); 477 Source<RenderProcessHost>(source).ptr());
478 break; 478 break;
479 479
480 default: 480 default:
481 NOTREACHED(); 481 NOTREACHED();
482 } 482 }
483 } 483 }
484 484
485 bool RenderViewHostManager::ShouldTransitionCrossSite() { 485 bool RenderFrameHostManager::ShouldTransitionCrossSite() {
486 // False in the single-process mode, as it makes RVHs to accumulate 486 // False in the single-process mode, as it makes RVHs to accumulate
487 // in swapped_out_hosts_. 487 // in swapped_out_hosts_.
488 // True if we are using process-per-site-instance (default) or 488 // True if we are using process-per-site-instance (default) or
489 // process-per-site (kProcessPerSite). 489 // process-per-site (kProcessPerSite).
490 return 490 return
491 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess) && 491 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess) &&
492 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerTab); 492 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerTab);
493 } 493 }
494 494
495 bool RenderViewHostManager::ShouldSwapBrowsingInstancesForNavigation( 495 bool RenderFrameHostManager::ShouldSwapBrowsingInstancesForNavigation(
496 const NavigationEntry* current_entry, 496 const NavigationEntry* current_entry,
497 const NavigationEntryImpl* new_entry) const { 497 const NavigationEntryImpl* new_entry) const {
498 DCHECK(new_entry); 498 DCHECK(new_entry);
499 499
500 // If new_entry already has a SiteInstance, assume it is correct and use it. 500 // If new_entry already has a SiteInstance, assume it is correct and use it.
501 if (new_entry->site_instance()) 501 if (new_entry->site_instance())
502 return false; 502 return false;
503 503
504 // Check for reasons to swap processes even if we are in a process model that 504 // Check for reasons to swap processes even if we are in a process model that
505 // doesn't usually swap (e.g., process-per-tab). Any time we return true, 505 // doesn't usually swap (e.g., process-per-tab). Any time we return true,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 // without screwing up the session history sometimes (when navigating between 547 // without screwing up the session history sometimes (when navigating between
548 // "view-source:http://foo.com/" and "http://foo.com/", Blink doesn't treat 548 // "view-source:http://foo.com/" and "http://foo.com/", Blink doesn't treat
549 // it as a new navigation). So require a BrowsingInstance switch. 549 // it as a new navigation). So require a BrowsingInstance switch.
550 if (current_entry && 550 if (current_entry &&
551 current_entry->IsViewSourceMode() != new_entry->IsViewSourceMode()) 551 current_entry->IsViewSourceMode() != new_entry->IsViewSourceMode())
552 return true; 552 return true;
553 553
554 return false; 554 return false;
555 } 555 }
556 556
557 bool RenderViewHostManager::ShouldReuseWebUI( 557 bool RenderFrameHostManager::ShouldReuseWebUI(
558 const NavigationEntry* current_entry, 558 const NavigationEntry* current_entry,
559 const NavigationEntryImpl* new_entry) const { 559 const NavigationEntryImpl* new_entry) const {
560 NavigationControllerImpl& controller = 560 NavigationControllerImpl& controller =
561 delegate_->GetControllerForRenderManager(); 561 delegate_->GetControllerForRenderManager();
562 return current_entry && web_ui_.get() && 562 return current_entry && web_ui_.get() &&
563 (WebUIControllerFactoryRegistry::GetInstance()->GetWebUIType( 563 (WebUIControllerFactoryRegistry::GetInstance()->GetWebUIType(
564 controller.GetBrowserContext(), current_entry->GetURL()) == 564 controller.GetBrowserContext(), current_entry->GetURL()) ==
565 WebUIControllerFactoryRegistry::GetInstance()->GetWebUIType( 565 WebUIControllerFactoryRegistry::GetInstance()->GetWebUIType(
566 controller.GetBrowserContext(), new_entry->GetURL())); 566 controller.GetBrowserContext(), new_entry->GetURL()));
567 } 567 }
568 568
569 SiteInstance* RenderViewHostManager::GetSiteInstanceForEntry( 569 SiteInstance* RenderFrameHostManager::GetSiteInstanceForEntry(
570 const NavigationEntryImpl& entry, 570 const NavigationEntryImpl& entry,
571 SiteInstance* current_instance, 571 SiteInstance* current_instance,
572 bool force_browsing_instance_swap) { 572 bool force_browsing_instance_swap) {
573 // Determine which SiteInstance to use for navigating to |entry|. 573 // Determine which SiteInstance to use for navigating to |entry|.
574 const GURL& dest_url = entry.GetURL(); 574 const GURL& dest_url = entry.GetURL();
575 NavigationControllerImpl& controller = 575 NavigationControllerImpl& controller =
576 delegate_->GetControllerForRenderManager(); 576 delegate_->GetControllerForRenderManager();
577 BrowserContext* browser_context = controller.GetBrowserContext(); 577 BrowserContext* browser_context = controller.GetBrowserContext();
578 578
579 // If a swap is required, we need to force the SiteInstance AND 579 // If a swap is required, we need to force the SiteInstance AND
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 } 712 }
713 713
714 // Start the new renderer in a new SiteInstance, but in the current 714 // Start the new renderer in a new SiteInstance, but in the current
715 // BrowsingInstance. It is important to immediately give this new 715 // BrowsingInstance. It is important to immediately give this new
716 // SiteInstance to a RenderViewHost (if it is different than our current 716 // SiteInstance to a RenderViewHost (if it is different than our current
717 // SiteInstance), so that it is ref counted. This will happen in 717 // SiteInstance), so that it is ref counted. This will happen in
718 // CreateRenderView. 718 // CreateRenderView.
719 return current_instance->GetRelatedSiteInstance(dest_url); 719 return current_instance->GetRelatedSiteInstance(dest_url);
720 } 720 }
721 721
722 int RenderViewHostManager::CreateRenderView( 722 int RenderFrameHostManager::CreateRenderView(
723 SiteInstance* instance, 723 SiteInstance* instance,
724 int opener_route_id, 724 int opener_route_id,
725 bool swapped_out, 725 bool swapped_out,
726 bool hidden) { 726 bool hidden) {
727 CHECK(instance); 727 CHECK(instance);
728 DCHECK(!swapped_out || hidden); // Swapped out views should always be hidden. 728 DCHECK(!swapped_out || hidden); // Swapped out views should always be hidden.
729 729
730 // We are creating a pending or swapped out RVH here. We should never create 730 // We are creating a pending or swapped out RVH here. We should never create
731 // it in the same SiteInstance as our current RVH. 731 // it in the same SiteInstance as our current RVH.
732 CHECK_NE(render_view_host_->GetSiteInstance(), instance); 732 CHECK_NE(render_view_host_->GetSiteInstance(), instance);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 } 768 }
769 } 769 }
770 770
771 // Use this as our new pending RVH if it isn't swapped out. 771 // Use this as our new pending RVH if it isn't swapped out.
772 if (!swapped_out) 772 if (!swapped_out)
773 pending_render_view_host_ = new_render_view_host; 773 pending_render_view_host_ = new_render_view_host;
774 774
775 return new_render_view_host->GetRoutingID(); 775 return new_render_view_host->GetRoutingID();
776 } 776 }
777 777
778 bool RenderViewHostManager::InitRenderView(RenderViewHost* render_view_host, 778 bool RenderFrameHostManager::InitRenderView(RenderViewHost* render_view_host,
779 int opener_route_id) { 779 int opener_route_id) {
780 // If the pending navigation is to a WebUI and the RenderView is not in a 780 // If the pending navigation is to a WebUI and the RenderView is not in a
781 // guest process, tell the RenderView about any bindings it will need enabled. 781 // guest process, tell the RenderView about any bindings it will need enabled.
782 if (pending_web_ui() && !render_view_host->GetProcess()->IsGuest()) { 782 if (pending_web_ui() && !render_view_host->GetProcess()->IsGuest()) {
783 render_view_host->AllowBindings(pending_web_ui()->GetBindings()); 783 render_view_host->AllowBindings(pending_web_ui()->GetBindings());
784 } else { 784 } else {
785 // Ensure that we don't create an unprivileged RenderView in a WebUI-enabled 785 // Ensure that we don't create an unprivileged RenderView in a WebUI-enabled
786 // process. 786 // process.
787 CHECK(!ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( 787 CHECK(!ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings(
788 render_view_host->GetProcess()->GetID())); 788 render_view_host->GetProcess()->GetID()));
789 } 789 }
790 790
791 return delegate_->CreateRenderViewForRenderManager(render_view_host, 791 return delegate_->CreateRenderViewForRenderManager(render_view_host,
792 opener_route_id); 792 opener_route_id);
793 } 793 }
794 794
795 void RenderViewHostManager::CommitPending() { 795 void RenderFrameHostManager::CommitPending() {
796 // First check whether we're going to want to focus the location bar after 796 // First check whether we're going to want to focus the location bar after
797 // this commit. We do this now because the navigation hasn't formally 797 // this commit. We do this now because the navigation hasn't formally
798 // committed yet, so if we've already cleared |pending_web_ui_| the call chain 798 // committed yet, so if we've already cleared |pending_web_ui_| the call chain
799 // this triggers won't be able to figure out what's going on. 799 // this triggers won't be able to figure out what's going on.
800 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault(); 800 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault();
801 801
802 // Next commit the Web UI, if any. Either replace |web_ui_| with 802 // Next commit the Web UI, if any. Either replace |web_ui_| with
803 // |pending_web_ui_|, or clear |web_ui_| if there is no pending WebUI, or 803 // |pending_web_ui_|, or clear |web_ui_| if there is no pending WebUI, or
804 // leave |web_ui_| as is if reusing it. 804 // leave |web_ui_| as is if reusing it.
805 DCHECK(!(pending_web_ui_.get() && pending_and_current_web_ui_.get())); 805 DCHECK(!(pending_web_ui_.get() && pending_and_current_web_ui_.get()));
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 // Shutdown the RVH that will be replaced in the map to avoid a leak. 890 // Shutdown the RVH that will be replaced in the map to avoid a leak.
891 iter->second->Shutdown(); 891 iter->second->Shutdown();
892 } 892 }
893 swapped_out_hosts_[old_site_instance_id] = old_render_view_host; 893 swapped_out_hosts_[old_site_instance_id] = old_render_view_host;
894 } else { 894 } else {
895 old_render_view_host->Shutdown(); 895 old_render_view_host->Shutdown();
896 old_render_view_host = NULL; // Shutdown() deletes it. 896 old_render_view_host = NULL; // Shutdown() deletes it.
897 } 897 }
898 } 898 }
899 899
900 void RenderViewHostManager::ShutdownRenderViewHostsInSiteInstance( 900 void RenderFrameHostManager::ShutdownRenderViewHostsInSiteInstance(
901 int32 site_instance_id) { 901 int32 site_instance_id) {
902 // First remove any swapped out RVH for this SiteInstance from our 902 // First remove any swapped out RVH for this SiteInstance from our
903 // list. 903 // list.
904 swapped_out_hosts_.erase(site_instance_id); 904 swapped_out_hosts_.erase(site_instance_id);
905 905
906 scoped_ptr<RenderWidgetHostIterator> widgets( 906 scoped_ptr<RenderWidgetHostIterator> widgets(
907 RenderWidgetHostImpl::GetAllRenderWidgetHosts()); 907 RenderWidgetHostImpl::GetAllRenderWidgetHosts());
908 while (RenderWidgetHost* widget = widgets->GetNextHost()) { 908 while (RenderWidgetHost* widget = widgets->GetNextHost()) {
909 if (!widget->IsRenderView()) 909 if (!widget->IsRenderView())
910 continue; 910 continue;
911 RenderViewHostImpl* rvh = 911 RenderViewHostImpl* rvh =
912 static_cast<RenderViewHostImpl*>(RenderViewHost::From(widget)); 912 static_cast<RenderViewHostImpl*>(RenderViewHost::From(widget));
913 if (site_instance_id == rvh->GetSiteInstance()->GetId()) 913 if (site_instance_id == rvh->GetSiteInstance()->GetId())
914 rvh->Shutdown(); 914 rvh->Shutdown();
915 } 915 }
916 } 916 }
917 917
918 RenderViewHostImpl* RenderViewHostManager::UpdateRendererStateForNavigate( 918 RenderViewHostImpl* RenderFrameHostManager::UpdateRendererStateForNavigate(
919 const NavigationEntryImpl& entry) { 919 const NavigationEntryImpl& entry) {
920 // If we are currently navigating cross-process, we want to get back to normal 920 // If we are currently navigating cross-process, we want to get back to normal
921 // and then navigate as usual. 921 // and then navigate as usual.
922 if (cross_navigation_pending_) { 922 if (cross_navigation_pending_) {
923 if (pending_render_view_host_) 923 if (pending_render_view_host_)
924 CancelPending(); 924 CancelPending();
925 cross_navigation_pending_ = false; 925 cross_navigation_pending_ = false;
926 } 926 }
927 927
928 // render_view_host_'s SiteInstance and new_instance will not be deleted 928 // render_view_host_'s SiteInstance and new_instance will not be deleted
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 // The renderer can exit view source mode when any error or cancellation 1060 // The renderer can exit view source mode when any error or cancellation
1061 // happen. We must overwrite to recover the mode. 1061 // happen. We must overwrite to recover the mode.
1062 if (entry.IsViewSourceMode()) { 1062 if (entry.IsViewSourceMode()) {
1063 render_view_host_->Send( 1063 render_view_host_->Send(
1064 new ViewMsg_EnableViewSourceMode(render_view_host_->GetRoutingID())); 1064 new ViewMsg_EnableViewSourceMode(render_view_host_->GetRoutingID()));
1065 } 1065 }
1066 1066
1067 return render_view_host_; 1067 return render_view_host_;
1068 } 1068 }
1069 1069
1070 void RenderViewHostManager::CancelPending() { 1070 void RenderFrameHostManager::CancelPending() {
1071 RenderViewHostImpl* pending_render_view_host = pending_render_view_host_; 1071 RenderViewHostImpl* pending_render_view_host = pending_render_view_host_;
1072 pending_render_view_host_ = NULL; 1072 pending_render_view_host_ = NULL;
1073 1073
1074 RenderViewDevToolsAgentHost::OnCancelPendingNavigation( 1074 RenderViewDevToolsAgentHost::OnCancelPendingNavigation(
1075 pending_render_view_host, 1075 pending_render_view_host,
1076 render_view_host_); 1076 render_view_host_);
1077 1077
1078 // We no longer need to prevent the process from exiting. 1078 // We no longer need to prevent the process from exiting.
1079 pending_render_view_host->GetProcess()->RemovePendingView(); 1079 pending_render_view_host->GetProcess()->RemovePendingView();
1080 1080
1081 // The pending RVH may already be on the swapped out list if we started to 1081 // The pending RVH may already be on the swapped out list if we started to
1082 // swap it back in and then canceled. If so, make sure it gets swapped out 1082 // swap it back in and then canceled. If so, make sure it gets swapped out
1083 // again. If it's not on the swapped out list (e.g., aborting a pending 1083 // again. If it's not on the swapped out list (e.g., aborting a pending
1084 // load), then it's safe to shut down. 1084 // load), then it's safe to shut down.
1085 if (IsOnSwappedOutList(pending_render_view_host)) { 1085 if (IsOnSwappedOutList(pending_render_view_host)) {
1086 // Any currently suspended navigations are no longer needed. 1086 // Any currently suspended navigations are no longer needed.
1087 pending_render_view_host->CancelSuspendedNavigations(); 1087 pending_render_view_host->CancelSuspendedNavigations();
1088 1088
1089 pending_render_view_host->SwapOut(); 1089 pending_render_view_host->SwapOut();
1090 } else { 1090 } else {
1091 // We won't be coming back, so shut this one down. 1091 // We won't be coming back, so shut this one down.
1092 pending_render_view_host->Shutdown(); 1092 pending_render_view_host->Shutdown();
1093 } 1093 }
1094 1094
1095 pending_web_ui_.reset(); 1095 pending_web_ui_.reset();
1096 pending_and_current_web_ui_.reset(); 1096 pending_and_current_web_ui_.reset();
1097 } 1097 }
1098 1098
1099 void RenderViewHostManager::RenderViewDeleted(RenderViewHost* rvh) { 1099 void RenderFrameHostManager::RenderViewDeleted(RenderViewHost* rvh) {
1100 // We are doing this in order to work around and to track a crasher 1100 // We are doing this in order to work around and to track a crasher
1101 // (http://crbug.com/23411) where it seems that pending_render_view_host_ is 1101 // (http://crbug.com/23411) where it seems that pending_render_view_host_ is
1102 // deleted (not sure from where) but not NULLed. 1102 // deleted (not sure from where) but not NULLed.
1103 if (rvh == pending_render_view_host_) { 1103 if (rvh == pending_render_view_host_) {
1104 // If you hit this NOTREACHED, please report it in the following bug 1104 // If you hit this NOTREACHED, please report it in the following bug
1105 // http://crbug.com/23411 Make sure to include what you were doing when it 1105 // http://crbug.com/23411 Make sure to include what you were doing when it
1106 // happened (navigating to a new page, closing a tab...) and if you can 1106 // happened (navigating to a new page, closing a tab...) and if you can
1107 // reproduce. 1107 // reproduce.
1108 NOTREACHED(); 1108 NOTREACHED();
1109 pending_render_view_host_ = NULL; 1109 pending_render_view_host_ = NULL;
1110 } 1110 }
1111 1111
1112 // Make sure deleted RVHs are not kept in the swapped out list while we are 1112 // Make sure deleted RVHs are not kept in the swapped out list while we are
1113 // still alive. (If render_view_host_ is null, we're already being deleted.) 1113 // still alive. (If render_view_host_ is null, we're already being deleted.)
1114 if (!render_view_host_) 1114 if (!render_view_host_)
1115 return; 1115 return;
1116 // We can't look it up by SiteInstance ID, which may no longer be valid. 1116 // We can't look it up by SiteInstance ID, which may no longer be valid.
1117 for (RenderViewHostMap::iterator iter = swapped_out_hosts_.begin(); 1117 for (RenderViewHostMap::iterator iter = swapped_out_hosts_.begin();
1118 iter != swapped_out_hosts_.end(); 1118 iter != swapped_out_hosts_.end();
1119 ++iter) { 1119 ++iter) {
1120 if (iter->second == rvh) { 1120 if (iter->second == rvh) {
1121 swapped_out_hosts_.erase(iter); 1121 swapped_out_hosts_.erase(iter);
1122 break; 1122 break;
1123 } 1123 }
1124 } 1124 }
1125 } 1125 }
1126 1126
1127 bool RenderViewHostManager::IsOnSwappedOutList(RenderViewHost* rvh) const { 1127 bool RenderFrameHostManager::IsOnSwappedOutList(RenderViewHost* rvh) const {
1128 if (!rvh->GetSiteInstance()) 1128 if (!rvh->GetSiteInstance())
1129 return false; 1129 return false;
1130 1130
1131 RenderViewHostMap::const_iterator iter = swapped_out_hosts_.find( 1131 RenderViewHostMap::const_iterator iter = swapped_out_hosts_.find(
1132 rvh->GetSiteInstance()->GetId()); 1132 rvh->GetSiteInstance()->GetId());
1133 if (iter == swapped_out_hosts_.end()) 1133 if (iter == swapped_out_hosts_.end())
1134 return false; 1134 return false;
1135 1135
1136 return iter->second == rvh; 1136 return iter->second == rvh;
1137 } 1137 }
1138 1138
1139 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost( 1139 RenderViewHostImpl* RenderFrameHostManager::GetSwappedOutRenderViewHost(
1140 SiteInstance* instance) { 1140 SiteInstance* instance) {
1141 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); 1141 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId());
1142 if (iter != swapped_out_hosts_.end()) 1142 if (iter != swapped_out_hosts_.end())
1143 return iter->second; 1143 return iter->second;
1144 1144
1145 return NULL; 1145 return NULL;
1146 } 1146 }
1147 1147
1148 } // namespace content 1148 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698