| 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/tab_contents/render_view_host_manager.h" | 5 #include "content/browser/tab_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" |
| 11 #include "content/browser/debugger/devtools_manager_impl.h" | 11 #include "content/browser/debugger/devtools_manager_impl.h" |
| 12 #include "content/browser/renderer_host/render_view_host.h" | 12 #include "content/browser/renderer_host/render_view_host.h" |
| 13 #include "content/browser/renderer_host/render_view_host_factory.h" | 13 #include "content/browser/renderer_host/render_view_host_factory.h" |
| 14 #include "content/browser/renderer_host/render_widget_host_view.h" | 14 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 15 #include "content/browser/site_instance.h" | 15 #include "content/browser/site_instance_impl.h" |
| 16 #include "content/browser/tab_contents/navigation_controller_impl.h" | 16 #include "content/browser/tab_contents/navigation_controller_impl.h" |
| 17 #include "content/browser/tab_contents/navigation_entry_impl.h" | 17 #include "content/browser/tab_contents/navigation_entry_impl.h" |
| 18 #include "content/browser/webui/web_ui_impl.h" | 18 #include "content/browser/webui/web_ui_impl.h" |
| 19 #include "content/common/view_messages.h" | 19 #include "content/common/view_messages.h" |
| 20 #include "content/public/browser/content_browser_client.h" | 20 #include "content/public/browser/content_browser_client.h" |
| 21 #include "content/public/browser/notification_service.h" | 21 #include "content/public/browser/notification_service.h" |
| 22 #include "content/public/browser/notification_types.h" | 22 #include "content/public/browser/notification_types.h" |
| 23 #include "content/public/browser/render_view_host_delegate.h" | 23 #include "content/public/browser/render_view_host_delegate.h" |
| 24 #include "content/public/browser/web_contents_view.h" | 24 #include "content/public/browser/web_contents_view.h" |
| 25 #include "content/public/browser/web_ui_controller.h" | 25 #include "content/public/browser/web_ui_controller.h" |
| 26 #include "content/public/browser/web_ui_factory.h" | 26 #include "content/public/browser/web_ui_factory.h" |
| 27 #include "content/public/common/content_switches.h" | 27 #include "content/public/common/content_switches.h" |
| 28 #include "content/public/common/url_constants.h" | 28 #include "content/public/common/url_constants.h" |
| 29 | 29 |
| 30 using content::NavigationController; | 30 using content::NavigationController; |
| 31 using content::NavigationEntry; | 31 using content::NavigationEntry; |
| 32 using content::NavigationEntryImpl; | 32 using content::NavigationEntryImpl; |
| 33 using content::SiteInstance; |
| 33 | 34 |
| 34 RenderViewHostManager::RenderViewHostManager( | 35 RenderViewHostManager::RenderViewHostManager( |
| 35 content::RenderViewHostDelegate* render_view_delegate, | 36 content::RenderViewHostDelegate* render_view_delegate, |
| 36 Delegate* delegate) | 37 Delegate* delegate) |
| 37 : delegate_(delegate), | 38 : delegate_(delegate), |
| 38 cross_navigation_pending_(false), | 39 cross_navigation_pending_(false), |
| 39 render_view_delegate_(render_view_delegate), | 40 render_view_delegate_(render_view_delegate), |
| 40 render_view_host_(NULL), | 41 render_view_host_(NULL), |
| 41 pending_render_view_host_(NULL), | 42 pending_render_view_host_(NULL), |
| 42 interstitial_page_(NULL) { | 43 interstitial_page_(NULL) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 59 } | 60 } |
| 60 } | 61 } |
| 61 | 62 |
| 62 void RenderViewHostManager::Init(content::BrowserContext* browser_context, | 63 void RenderViewHostManager::Init(content::BrowserContext* browser_context, |
| 63 SiteInstance* site_instance, | 64 SiteInstance* site_instance, |
| 64 int routing_id) { | 65 int routing_id) { |
| 65 // Create a RenderViewHost, once we have an instance. It is important to | 66 // Create a RenderViewHost, once we have an instance. It is important to |
| 66 // immediately give this SiteInstance to a RenderViewHost so that it is | 67 // immediately give this SiteInstance to a RenderViewHost so that it is |
| 67 // ref counted. | 68 // ref counted. |
| 68 if (!site_instance) | 69 if (!site_instance) |
| 69 site_instance = SiteInstance::CreateSiteInstance(browser_context); | 70 site_instance = SiteInstance::Create(browser_context); |
| 70 render_view_host_ = RenderViewHostFactory::Create( | 71 render_view_host_ = RenderViewHostFactory::Create( |
| 71 site_instance, render_view_delegate_, routing_id, delegate_-> | 72 site_instance, render_view_delegate_, routing_id, delegate_-> |
| 72 GetControllerForRenderManager().GetSessionStorageNamespace()); | 73 GetControllerForRenderManager().GetSessionStorageNamespace()); |
| 73 | 74 |
| 74 // Keep track of renderer processes as they start to shut down. | 75 // Keep track of renderer processes as they start to shut down. |
| 75 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSING, | 76 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSING, |
| 76 content::NotificationService::AllSources()); | 77 content::NotificationService::AllSources()); |
| 77 } | 78 } |
| 78 | 79 |
| 79 RenderWidgetHostView* RenderViewHostManager::GetRenderWidgetHostView() const { | 80 RenderWidgetHostView* RenderViewHostManager::GetRenderWidgetHostView() const { |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 const NavigationEntryImpl* new_entry) const { | 339 const NavigationEntryImpl* new_entry) const { |
| 339 DCHECK(new_entry); | 340 DCHECK(new_entry); |
| 340 | 341 |
| 341 // Check for reasons to swap processes even if we are in a process model that | 342 // Check for reasons to swap processes even if we are in a process model that |
| 342 // doesn't usually swap (e.g., process-per-tab). | 343 // doesn't usually swap (e.g., process-per-tab). |
| 343 | 344 |
| 344 // For security, we should transition between processes when one is a Web UI | 345 // For security, we should transition between processes when one is a Web UI |
| 345 // page and one isn't. If there's no cur_entry, check the current RVH's | 346 // page and one isn't. If there's no cur_entry, check the current RVH's |
| 346 // site, which might already be committed to a Web UI URL (such as the NTP). | 347 // site, which might already be committed to a Web UI URL (such as the NTP). |
| 347 const GURL& current_url = (cur_entry) ? cur_entry->GetURL() : | 348 const GURL& current_url = (cur_entry) ? cur_entry->GetURL() : |
| 348 render_view_host_->site_instance()->site(); | 349 render_view_host_->site_instance()->GetSite(); |
| 349 content::BrowserContext* browser_context = | 350 content::BrowserContext* browser_context = |
| 350 delegate_->GetControllerForRenderManager().GetBrowserContext(); | 351 delegate_->GetControllerForRenderManager().GetBrowserContext(); |
| 351 const content::WebUIFactory* web_ui_factory = | 352 const content::WebUIFactory* web_ui_factory = |
| 352 content::GetContentClient()->browser()->GetWebUIFactory(); | 353 content::GetContentClient()->browser()->GetWebUIFactory(); |
| 353 if (web_ui_factory->UseWebUIForURL(browser_context, current_url)) { | 354 if (web_ui_factory->UseWebUIForURL(browser_context, current_url)) { |
| 354 // Force swap if it's not an acceptable URL for Web UI. | 355 // Force swap if it's not an acceptable URL for Web UI. |
| 355 if (!web_ui_factory->IsURLAcceptableForWebUI(browser_context, | 356 if (!web_ui_factory->IsURLAcceptableForWebUI(browser_context, |
| 356 new_entry->GetURL())) | 357 new_entry->GetURL())) |
| 357 return true; | 358 return true; |
| 358 } else { | 359 } else { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 // other sites, we don't really want to use the search engine hostname to | 401 // other sites, we don't really want to use the search engine hostname to |
| 401 // determine the site instance for this navigation. | 402 // determine the site instance for this navigation. |
| 402 // | 403 // |
| 403 // NOTE: This can be removed once we have a way to transition between | 404 // NOTE: This can be removed once we have a way to transition between |
| 404 // RenderViews in response to a link click. | 405 // RenderViews in response to a link click. |
| 405 // | 406 // |
| 406 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerSite) && | 407 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerSite) && |
| 407 entry.GetTransitionType() == content::PAGE_TRANSITION_GENERATED) | 408 entry.GetTransitionType() == content::PAGE_TRANSITION_GENERATED) |
| 408 return curr_instance; | 409 return curr_instance; |
| 409 | 410 |
| 411 SiteInstanceImpl* curr_site_instance = |
| 412 static_cast<SiteInstanceImpl*>(curr_instance); |
| 413 |
| 410 // If we haven't used our SiteInstance (and thus RVH) yet, then we can use it | 414 // If we haven't used our SiteInstance (and thus RVH) yet, then we can use it |
| 411 // for this entry. We won't commit the SiteInstance to this site until the | 415 // for this entry. We won't commit the SiteInstance to this site until the |
| 412 // navigation commits (in DidNavigate), unless the navigation entry was | 416 // navigation commits (in DidNavigate), unless the navigation entry was |
| 413 // restored or it's a Web UI as described below. | 417 // restored or it's a Web UI as described below. |
| 414 if (!curr_instance->has_site()) { | 418 if (!curr_site_instance->HasSite()) { |
| 415 // If we've already created a SiteInstance for our destination, we don't | 419 // If we've already created a SiteInstance for our destination, we don't |
| 416 // want to use this unused SiteInstance; use the existing one. (We don't | 420 // want to use this unused SiteInstance; use the existing one. (We don't |
| 417 // do this check if the curr_instance has a site, because for now, we want | 421 // do this check if the curr_instance has a site, because for now, we want |
| 418 // to compare against the current URL and not the SiteInstance's site. In | 422 // to compare against the current URL and not the SiteInstance's site. In |
| 419 // this case, there is no current URL, so comparing against the site is ok. | 423 // this case, there is no current URL, so comparing against the site is ok. |
| 420 // See additional comments below.) | 424 // See additional comments below.) |
| 421 if (curr_instance->HasRelatedSiteInstance(dest_url)) | 425 if (curr_site_instance->HasRelatedSiteInstance(dest_url)) |
| 422 return curr_instance->GetRelatedSiteInstance(dest_url); | 426 return curr_site_instance->GetRelatedSiteInstance(dest_url); |
| 423 | 427 |
| 424 // For extensions, Web UI URLs (such as the new tab page), and apps we do | 428 // For extensions, Web UI URLs (such as the new tab page), and apps we do |
| 425 // not want to use the curr_instance if it has no site, since it will have a | 429 // not want to use the curr_instance if it has no site, since it will have a |
| 426 // RenderProcessHost of PRIV_NORMAL. Create a new SiteInstance for this | 430 // RenderProcessHost of PRIV_NORMAL. Create a new SiteInstance for this |
| 427 // URL instead (with the correct process type). | 431 // URL instead (with the correct process type). |
| 428 if (curr_instance->HasWrongProcessForURL(dest_url)) | 432 if (curr_site_instance->HasWrongProcessForURL(dest_url)) |
| 429 return curr_instance->GetRelatedSiteInstance(dest_url); | 433 return curr_site_instance->GetRelatedSiteInstance(dest_url); |
| 430 | 434 |
| 431 // Normally the "site" on the SiteInstance is set lazily when the load | 435 // Normally the "site" on the SiteInstance is set lazily when the load |
| 432 // actually commits. This is to support better process sharing in case | 436 // actually commits. This is to support better process sharing in case |
| 433 // the site redirects to some other site: we want to use the destination | 437 // the site redirects to some other site: we want to use the destination |
| 434 // site in the site instance. | 438 // site in the site instance. |
| 435 // | 439 // |
| 436 // In the case of session restore, as it loads all the pages immediately | 440 // In the case of session restore, as it loads all the pages immediately |
| 437 // we need to set the site first, otherwise after a restore none of the | 441 // we need to set the site first, otherwise after a restore none of the |
| 438 // pages would share renderers in process-per-site. | 442 // pages would share renderers in process-per-site. |
| 439 if (entry.restore_type() != NavigationEntryImpl::RESTORE_NONE) | 443 if (entry.restore_type() != NavigationEntryImpl::RESTORE_NONE) |
| 440 curr_instance->SetSite(dest_url); | 444 curr_site_instance->SetSite(dest_url); |
| 441 | 445 |
| 442 return curr_instance; | 446 return curr_site_instance; |
| 443 } | 447 } |
| 444 | 448 |
| 445 // Otherwise, only create a new SiteInstance for cross-site navigation. | 449 // Otherwise, only create a new SiteInstance for cross-site navigation. |
| 446 | 450 |
| 447 // TODO(creis): Once we intercept links and script-based navigations, we | 451 // TODO(creis): Once we intercept links and script-based navigations, we |
| 448 // will be able to enforce that all entries in a SiteInstance actually have | 452 // will be able to enforce that all entries in a SiteInstance actually have |
| 449 // the same site, and it will be safe to compare the URL against the | 453 // the same site, and it will be safe to compare the URL against the |
| 450 // SiteInstance's site, as follows: | 454 // SiteInstance's site, as follows: |
| 451 // const GURL& current_url = curr_instance->site(); | 455 // const GURL& current_url = curr_instance->site(); |
| 452 // For now, though, we're in a hybrid model where you only switch | 456 // For now, though, we're in a hybrid model where you only switch |
| 453 // SiteInstances if you type in a cross-site URL. This means we have to | 457 // SiteInstances if you type in a cross-site URL. This means we have to |
| 454 // compare the entry's URL to the last committed entry's URL. | 458 // compare the entry's URL to the last committed entry's URL. |
| 455 NavigationEntry* curr_entry = controller.GetLastCommittedEntry(); | 459 NavigationEntry* curr_entry = controller.GetLastCommittedEntry(); |
| 456 if (interstitial_page_) { | 460 if (interstitial_page_) { |
| 457 // The interstitial is currently the last committed entry, but we want to | 461 // The interstitial is currently the last committed entry, but we want to |
| 458 // compare against the last non-interstitial entry. | 462 // compare against the last non-interstitial entry. |
| 459 curr_entry = controller.GetEntryAtOffset(-1); | 463 curr_entry = controller.GetEntryAtOffset(-1); |
| 460 } | 464 } |
| 461 // If there is no last non-interstitial entry (and curr_instance already | 465 // If there is no last non-interstitial entry (and curr_instance already |
| 462 // has a site), then we must have been opened from another tab. We want | 466 // has a site), then we must have been opened from another tab. We want |
| 463 // to compare against the URL of the page that opened us, but we can't | 467 // to compare against the URL of the page that opened us, but we can't |
| 464 // get to it directly. The best we can do is check against the site of | 468 // get to it directly. The best we can do is check against the site of |
| 465 // the SiteInstance. This will be correct when we intercept links and | 469 // the SiteInstance. This will be correct when we intercept links and |
| 466 // script-based navigations, but for now, it could place some pages in a | 470 // script-based navigations, but for now, it could place some pages in a |
| 467 // new process unnecessarily. We should only hit this case if a page tries | 471 // new process unnecessarily. We should only hit this case if a page tries |
| 468 // to open a new tab to an interstitial-inducing URL, and then navigates | 472 // to open a new tab to an interstitial-inducing URL, and then navigates |
| 469 // the page to a different same-site URL. (This seems very unlikely in | 473 // the page to a different same-site URL. (This seems very unlikely in |
| 470 // practice.) | 474 // practice.) |
| 471 const GURL& current_url = (curr_entry) ? curr_entry->GetURL() : | 475 const GURL& current_url = (curr_entry) ? curr_entry->GetURL() : |
| 472 curr_instance->site(); | 476 curr_instance->GetSite(); |
| 473 | 477 |
| 474 // Use the current SiteInstance for same site navigations, as long as the | 478 // Use the current SiteInstance for same site navigations, as long as the |
| 475 // process type is correct. (The URL may have been installed as an app since | 479 // process type is correct. (The URL may have been installed as an app since |
| 476 // the last time we visited it.) | 480 // the last time we visited it.) |
| 477 if (SiteInstance::IsSameWebSite(browser_context, current_url, dest_url) && | 481 if (SiteInstance::IsSameWebSite(browser_context, current_url, dest_url) && |
| 478 !curr_instance->HasWrongProcessForURL(dest_url)) { | 482 !static_cast<SiteInstanceImpl*>(curr_instance)->HasWrongProcessForURL( |
| 483 dest_url)) { |
| 479 return curr_instance; | 484 return curr_instance; |
| 480 } else if (ShouldSwapProcessesForNavigation(curr_entry, &entry)) { | 485 } else if (ShouldSwapProcessesForNavigation(curr_entry, &entry)) { |
| 481 // When we're swapping, we need to force the site instance AND browsing | 486 // When we're swapping, we need to force the site instance AND browsing |
| 482 // instance to be different ones. This addresses special cases where we use | 487 // instance to be different ones. This addresses special cases where we use |
| 483 // a single BrowsingInstance for all pages of a certain type (e.g., New Tab | 488 // a single BrowsingInstance for all pages of a certain type (e.g., New Tab |
| 484 // Pages), keeping them in the same process. When you navigate away from | 489 // Pages), keeping them in the same process. When you navigate away from |
| 485 // that page, we want to explicity ignore that BrowsingInstance and group | 490 // that page, we want to explicity ignore that BrowsingInstance and group |
| 486 // this page into the appropriate SiteInstance for its URL. | 491 // this page into the appropriate SiteInstance for its URL. |
| 487 return SiteInstance::CreateSiteInstanceForURL(browser_context, dest_url); | 492 return SiteInstance::CreateForURL(browser_context, dest_url); |
| 488 } else { | 493 } else { |
| 489 // Start the new renderer in a new SiteInstance, but in the current | 494 // Start the new renderer in a new SiteInstance, but in the current |
| 490 // BrowsingInstance. It is important to immediately give this new | 495 // BrowsingInstance. It is important to immediately give this new |
| 491 // SiteInstance to a RenderViewHost (if it is different than our current | 496 // SiteInstance to a RenderViewHost (if it is different than our current |
| 492 // SiteInstance), so that it is ref counted. This will happen in | 497 // SiteInstance), so that it is ref counted. This will happen in |
| 493 // CreatePendingRenderView. | 498 // CreatePendingRenderView. |
| 494 return curr_instance->GetRelatedSiteInstance(dest_url); | 499 return curr_instance->GetRelatedSiteInstance(dest_url); |
| 495 } | 500 } |
| 496 } | 501 } |
| 497 | 502 |
| 498 bool RenderViewHostManager::CreatePendingRenderView( | 503 bool RenderViewHostManager::CreatePendingRenderView( |
| 499 const NavigationEntryImpl& entry, SiteInstance* instance) { | 504 const NavigationEntryImpl& entry, SiteInstance* instance) { |
| 500 NavigationEntry* curr_entry = | 505 NavigationEntry* curr_entry = |
| 501 delegate_->GetControllerForRenderManager().GetLastCommittedEntry(); | 506 delegate_->GetControllerForRenderManager().GetLastCommittedEntry(); |
| 502 if (curr_entry) { | 507 if (curr_entry) { |
| 503 DCHECK(!curr_entry->GetContentState().empty()); | 508 DCHECK(!curr_entry->GetContentState().empty()); |
| 504 // TODO(creis): Should send a message to the RenderView to let it know | 509 // TODO(creis): Should send a message to the RenderView to let it know |
| 505 // we're about to switch away, so that it sends an UpdateState message. | 510 // we're about to switch away, so that it sends an UpdateState message. |
| 506 } | 511 } |
| 507 | 512 |
| 508 // Check if we've already created an RVH for this SiteInstance. | 513 // Check if we've already created an RVH for this SiteInstance. |
| 509 CHECK(instance); | 514 CHECK(instance); |
| 510 RenderViewHostMap::iterator iter = | 515 RenderViewHostMap::iterator iter = |
| 511 swapped_out_hosts_.find(instance->id()); | 516 swapped_out_hosts_.find(instance->GetId()); |
| 512 if (iter != swapped_out_hosts_.end()) { | 517 if (iter != swapped_out_hosts_.end()) { |
| 513 // Re-use the existing RenderViewHost, which has already been initialized. | 518 // Re-use the existing RenderViewHost, which has already been initialized. |
| 514 // We'll remove it from the list of swapped out hosts if it commits. | 519 // We'll remove it from the list of swapped out hosts if it commits. |
| 515 pending_render_view_host_ = iter->second; | 520 pending_render_view_host_ = iter->second; |
| 516 | 521 |
| 517 // Prevent the process from exiting while we're trying to use it. | 522 // Prevent the process from exiting while we're trying to use it. |
| 518 pending_render_view_host_->process()->AddPendingView(); | 523 pending_render_view_host_->process()->AddPendingView(); |
| 519 | 524 |
| 520 return true; | 525 return true; |
| 521 } | 526 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 | 611 |
| 607 std::pair<RenderViewHost*, RenderViewHost*> details = | 612 std::pair<RenderViewHost*, RenderViewHost*> details = |
| 608 std::make_pair(old_render_view_host, render_view_host_); | 613 std::make_pair(old_render_view_host, render_view_host_); |
| 609 content::NotificationService::current()->Notify( | 614 content::NotificationService::current()->Notify( |
| 610 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, | 615 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
| 611 content::Source<NavigationController>( | 616 content::Source<NavigationController>( |
| 612 &delegate_->GetControllerForRenderManager()), | 617 &delegate_->GetControllerForRenderManager()), |
| 613 content::Details<std::pair<RenderViewHost*, RenderViewHost*> >(&details)); | 618 content::Details<std::pair<RenderViewHost*, RenderViewHost*> >(&details)); |
| 614 | 619 |
| 615 // If the pending view was on the swapped out list, we can remove it. | 620 // If the pending view was on the swapped out list, we can remove it. |
| 616 swapped_out_hosts_.erase(render_view_host_->site_instance()->id()); | 621 swapped_out_hosts_.erase(render_view_host_->site_instance()->GetId()); |
| 617 | 622 |
| 618 // If the old RVH is live, we are swapping it out and should keep track of it | 623 // If the old RVH is live, we are swapping it out and should keep track of it |
| 619 // in case we navigate back to it. | 624 // in case we navigate back to it. |
| 620 if (old_render_view_host->IsRenderViewLive()) { | 625 if (old_render_view_host->IsRenderViewLive()) { |
| 621 DCHECK(old_render_view_host->is_swapped_out()); | 626 DCHECK(old_render_view_host->is_swapped_out()); |
| 622 // Temp fix for http://crbug.com/90867 until we do a better cleanup to make | 627 // Temp fix for http://crbug.com/90867 until we do a better cleanup to make |
| 623 // sure we don't get different rvh instances for the same site instance | 628 // sure we don't get different rvh instances for the same site instance |
| 624 // in the same rvhmgr. | 629 // in the same rvhmgr. |
| 625 // TODO(creis): Clean this up. | 630 // TODO(creis): Clean this up. |
| 626 int32 old_site_instance_id = old_render_view_host->site_instance()->id(); | 631 int32 old_site_instance_id = old_render_view_host->site_instance()->GetId(); |
| 627 RenderViewHostMap::iterator iter = | 632 RenderViewHostMap::iterator iter = |
| 628 swapped_out_hosts_.find(old_site_instance_id); | 633 swapped_out_hosts_.find(old_site_instance_id); |
| 629 if (iter != swapped_out_hosts_.end() && | 634 if (iter != swapped_out_hosts_.end() && |
| 630 iter->second != old_render_view_host) { | 635 iter->second != old_render_view_host) { |
| 631 // Shutdown the RVH that will be replaced in the map to avoid a leak. | 636 // Shutdown the RVH that will be replaced in the map to avoid a leak. |
| 632 iter->second->Shutdown(); | 637 iter->second->Shutdown(); |
| 633 } | 638 } |
| 634 swapped_out_hosts_[old_site_instance_id] = old_render_view_host; | 639 swapped_out_hosts_[old_site_instance_id] = old_render_view_host; |
| 635 } else { | 640 } else { |
| 636 old_render_view_host->Shutdown(); | 641 old_render_view_host->Shutdown(); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 swapped_out_hosts_.erase(iter); | 813 swapped_out_hosts_.erase(iter); |
| 809 break; | 814 break; |
| 810 } | 815 } |
| 811 } | 816 } |
| 812 } | 817 } |
| 813 | 818 |
| 814 bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) { | 819 bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) { |
| 815 if (!rvh->site_instance()) | 820 if (!rvh->site_instance()) |
| 816 return false; | 821 return false; |
| 817 | 822 |
| 818 return swapped_out_hosts_.find(rvh->site_instance()->id()) != | 823 return swapped_out_hosts_.find(rvh->site_instance()->GetId()) != |
| 819 swapped_out_hosts_.end(); | 824 swapped_out_hosts_.end(); |
| 820 } | 825 } |
| OLD | NEW |