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

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

Issue 11275062: Move content\browser\web_contents to content namespace. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 1 month 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"
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_process_host_impl.h" 12 #include "content/browser/renderer_host/render_process_host_impl.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_view_host_impl.h" 14 #include "content/browser/renderer_host/render_view_host_impl.h"
15 #include "content/browser/site_instance_impl.h" 15 #include "content/browser/site_instance_impl.h"
16 #include "content/browser/web_contents/navigation_controller_impl.h" 16 #include "content/browser/web_contents/navigation_controller_impl.h"
17 #include "content/browser/web_contents/navigation_entry_impl.h" 17 #include "content/browser/web_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/port/browser/render_widget_host_view_port.h" 20 #include "content/port/browser/render_widget_host_view_port.h"
21 #include "content/public/browser/content_browser_client.h" 21 #include "content/public/browser/content_browser_client.h"
22 #include "content/public/browser/notification_service.h" 22 #include "content/public/browser/notification_service.h"
23 #include "content/public/browser/notification_types.h" 23 #include "content/public/browser/notification_types.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_controller_factory.h" 26 #include "content/public/browser/web_ui_controller_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 namespace content {
31 using content::NavigationControllerImpl;
32 using content::NavigationEntry;
33 using content::NavigationEntryImpl;
34 using content::RenderProcessHost;
35 using content::RenderProcessHostImpl;
36 using content::RenderViewHost;
37 using content::RenderViewHostImpl;
38 using content::RenderWidgetHostView;
39 using content::RenderWidgetHostViewPort;
40 using content::SiteInstance;
41 using content::WebUIControllerFactory;
42 using content::WebUIImpl;
43 31
44 RenderViewHostManager::RenderViewHostManager( 32 RenderViewHostManager::RenderViewHostManager(
45 content::RenderViewHostDelegate* render_view_delegate, 33 RenderViewHostDelegate* render_view_delegate,
46 content::RenderWidgetHostDelegate* render_widget_delegate, 34 RenderWidgetHostDelegate* render_widget_delegate,
47 Delegate* delegate) 35 Delegate* delegate)
48 : delegate_(delegate), 36 : delegate_(delegate),
49 cross_navigation_pending_(false), 37 cross_navigation_pending_(false),
50 render_view_delegate_(render_view_delegate), 38 render_view_delegate_(render_view_delegate),
51 render_widget_delegate_(render_widget_delegate), 39 render_widget_delegate_(render_widget_delegate),
52 render_view_host_(NULL), 40 render_view_host_(NULL),
53 pending_render_view_host_(NULL), 41 pending_render_view_host_(NULL),
54 interstitial_page_(NULL) { 42 interstitial_page_(NULL) {
55 } 43 }
56 44
57 RenderViewHostManager::~RenderViewHostManager() { 45 RenderViewHostManager::~RenderViewHostManager() {
58 if (pending_render_view_host_) 46 if (pending_render_view_host_)
59 CancelPending(); 47 CancelPending();
60 48
61 // We should always have a main RenderViewHost except in some tests. 49 // We should always have a main RenderViewHost except in some tests.
62 RenderViewHostImpl* render_view_host = render_view_host_; 50 RenderViewHostImpl* render_view_host = render_view_host_;
63 render_view_host_ = NULL; 51 render_view_host_ = NULL;
64 if (render_view_host) 52 if (render_view_host)
65 render_view_host->Shutdown(); 53 render_view_host->Shutdown();
66 54
67 // Shut down any swapped out RenderViewHosts. 55 // Shut down any swapped out RenderViewHosts.
68 for (RenderViewHostMap::iterator iter = swapped_out_hosts_.begin(); 56 for (RenderViewHostMap::iterator iter = swapped_out_hosts_.begin();
69 iter != swapped_out_hosts_.end(); 57 iter != swapped_out_hosts_.end();
70 ++iter) { 58 ++iter) {
71 iter->second->Shutdown(); 59 iter->second->Shutdown();
72 } 60 }
73 } 61 }
74 62
75 void RenderViewHostManager::Init(content::BrowserContext* browser_context, 63 void RenderViewHostManager::Init(BrowserContext* browser_context,
76 SiteInstance* site_instance, 64 SiteInstance* site_instance,
77 int routing_id) { 65 int routing_id) {
78 // 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
79 // immediately give this SiteInstance to a RenderViewHost so that it is 67 // immediately give this SiteInstance to a RenderViewHost so that it is
80 // ref counted. 68 // ref counted.
81 if (!site_instance) 69 if (!site_instance)
82 site_instance = SiteInstance::Create(browser_context); 70 site_instance = SiteInstance::Create(browser_context);
83 render_view_host_ = static_cast<RenderViewHostImpl*>( 71 render_view_host_ = static_cast<RenderViewHostImpl*>(
84 RenderViewHostFactory::Create( 72 RenderViewHostFactory::Create(
85 site_instance, render_view_delegate_, render_widget_delegate_, 73 site_instance, render_view_delegate_, render_widget_delegate_,
86 routing_id, false, delegate_-> 74 routing_id, false, delegate_->
87 GetControllerForRenderManager().GetSessionStorageNamespace( 75 GetControllerForRenderManager().GetSessionStorageNamespace(
88 site_instance))); 76 site_instance)));
89 77
90 // Keep track of renderer processes as they start to shut down. 78 // Keep track of renderer processes as they start to shut down.
91 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSING, 79 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSING,
92 content::NotificationService::AllSources()); 80 NotificationService::AllSources());
93 } 81 }
94 82
95 RenderViewHostImpl* RenderViewHostManager::current_host() const { 83 RenderViewHostImpl* RenderViewHostManager::current_host() const {
96 return render_view_host_; 84 return render_view_host_;
97 } 85 }
98 86
99 RenderViewHostImpl* RenderViewHostManager::pending_render_view_host() const { 87 RenderViewHostImpl* RenderViewHostManager::pending_render_view_host() const {
100 return pending_render_view_host_; 88 return pending_render_view_host_;
101 } 89 }
102 90
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 // on it later. 124 // on it later.
137 if (dest_render_view_host != render_view_host_ && 125 if (dest_render_view_host != render_view_host_ &&
138 dest_render_view_host->GetView()) { 126 dest_render_view_host->GetView()) {
139 dest_render_view_host->GetView()->Hide(); 127 dest_render_view_host->GetView()->Hide();
140 } else { 128 } else {
141 // This is our primary renderer, notify here as we won't be calling 129 // This is our primary renderer, notify here as we won't be calling
142 // CommitPending (which does the notify). 130 // CommitPending (which does the notify).
143 RenderViewHost* null_rvh = NULL; 131 RenderViewHost* null_rvh = NULL;
144 std::pair<RenderViewHost*, RenderViewHost*> details = 132 std::pair<RenderViewHost*, RenderViewHost*> details =
145 std::make_pair(null_rvh, render_view_host_); 133 std::make_pair(null_rvh, render_view_host_);
146 content::NotificationService::current()->Notify( 134 NotificationService::current()->Notify(
147 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, 135 NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
148 content::Source<NavigationController>( 136 Source<NavigationController>(
149 &delegate_->GetControllerForRenderManager()), 137 &delegate_->GetControllerForRenderManager()),
150 content::Details<std::pair<RenderViewHost*, RenderViewHost*> >( 138 Details<std::pair<RenderViewHost*, RenderViewHost*> >(
151 &details)); 139 &details));
152 } 140 }
153 } 141 }
154 142
155 return dest_render_view_host; 143 return dest_render_view_host;
156 } 144 }
157 145
158 void RenderViewHostManager::Stop() { 146 void RenderViewHostManager::Stop() {
159 render_view_host_->Stop(); 147 render_view_host_->Stop();
160 148
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 // ResourceDispatcherHost has told us to run the onunload handler, which 360 // ResourceDispatcherHost has told us to run the onunload handler, which
373 // means it is not a download or unsafe page, and we are going to perform the 361 // means it is not a download or unsafe page, and we are going to perform the
374 // navigation. Thus, we no longer need to remember that the RenderViewHost 362 // navigation. Thus, we no longer need to remember that the RenderViewHost
375 // is part of a pending cross-site request. 363 // is part of a pending cross-site request.
376 pending_render_view_host_->SetHasPendingCrossSiteRequest(false, 364 pending_render_view_host_->SetHasPendingCrossSiteRequest(false,
377 new_request_id); 365 new_request_id);
378 } 366 }
379 367
380 void RenderViewHostManager::Observe( 368 void RenderViewHostManager::Observe(
381 int type, 369 int type,
382 const content::NotificationSource& source, 370 const NotificationSource& source,
383 const content::NotificationDetails& details) { 371 const NotificationDetails& details) {
384 switch (type) { 372 switch (type) {
385 case content::NOTIFICATION_RENDERER_PROCESS_CLOSING: 373 case NOTIFICATION_RENDERER_PROCESS_CLOSING:
386 RendererProcessClosing( 374 RendererProcessClosing(
387 content::Source<RenderProcessHost>(source).ptr()); 375 Source<RenderProcessHost>(source).ptr());
388 break; 376 break;
389 377
390 default: 378 default:
391 NOTREACHED(); 379 NOTREACHED();
392 } 380 }
393 } 381 }
394 382
395 bool RenderViewHostManager::ShouldTransitionCrossSite() { 383 bool RenderViewHostManager::ShouldTransitionCrossSite() {
396 // True if we are using process-per-site-instance (default) or 384 // True if we are using process-per-site-instance (default) or
397 // process-per-site (kProcessPerSite). 385 // process-per-site (kProcessPerSite).
398 return !CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerTab); 386 return !CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerTab);
399 } 387 }
400 388
401 bool RenderViewHostManager::ShouldSwapProcessesForNavigation( 389 bool RenderViewHostManager::ShouldSwapProcessesForNavigation(
402 const NavigationEntry* curr_entry, 390 const NavigationEntry* curr_entry,
403 const NavigationEntryImpl* new_entry) const { 391 const NavigationEntryImpl* new_entry) const {
404 DCHECK(new_entry); 392 DCHECK(new_entry);
405 393
406 // Check for reasons to swap processes even if we are in a process model that 394 // Check for reasons to swap processes even if we are in a process model that
407 // doesn't usually swap (e.g., process-per-tab). 395 // doesn't usually swap (e.g., process-per-tab).
408 396
409 // For security, we should transition between processes when one is a Web UI 397 // For security, we should transition between processes when one is a Web UI
410 // page and one isn't. If there's no curr_entry, check the current RVH's 398 // page and one isn't. If there's no curr_entry, check the current RVH's
411 // site, which might already be committed to a Web UI URL (such as the NTP). 399 // site, which might already be committed to a Web UI URL (such as the NTP).
412 const GURL& current_url = (curr_entry) ? curr_entry->GetURL() : 400 const GURL& current_url = (curr_entry) ? curr_entry->GetURL() :
413 render_view_host_->GetSiteInstance()->GetSiteURL(); 401 render_view_host_->GetSiteInstance()->GetSiteURL();
414 content::BrowserContext* browser_context = 402 BrowserContext* browser_context =
415 delegate_->GetControllerForRenderManager().GetBrowserContext(); 403 delegate_->GetControllerForRenderManager().GetBrowserContext();
416 const WebUIControllerFactory* web_ui_factory = 404 const WebUIControllerFactory* web_ui_factory =
417 content::GetContentClient()->browser()->GetWebUIControllerFactory(); 405 GetContentClient()->browser()->GetWebUIControllerFactory();
418 if (web_ui_factory) { 406 if (web_ui_factory) {
419 if (web_ui_factory->UseWebUIForURL(browser_context, current_url)) { 407 if (web_ui_factory->UseWebUIForURL(browser_context, current_url)) {
420 // Force swap if it's not an acceptable URL for Web UI. 408 // Force swap if it's not an acceptable URL for Web UI.
421 // Here, data URLs are never allowed. 409 // Here, data URLs are never allowed.
422 if (!web_ui_factory->IsURLAcceptableForWebUI(browser_context, 410 if (!web_ui_factory->IsURLAcceptableForWebUI(browser_context,
423 new_entry->GetURL(), false)) 411 new_entry->GetURL(), false))
424 return true; 412 return true;
425 } else { 413 } else {
426 // Force swap if it's a Web UI URL. 414 // Force swap if it's a Web UI URL.
427 if (web_ui_factory->UseWebUIForURL(browser_context, new_entry->GetURL())) 415 if (web_ui_factory->UseWebUIForURL(browser_context, new_entry->GetURL()))
428 return true; 416 return true;
429 } 417 }
430 } 418 }
431 419
432 if (content::GetContentClient()->browser()->ShouldSwapProcessesForNavigation( 420 if (GetContentClient()->browser()->ShouldSwapProcessesForNavigation(
433 curr_entry ? curr_entry->GetURL() : GURL(), new_entry->GetURL())) { 421 curr_entry ? curr_entry->GetURL() : GURL(), new_entry->GetURL())) {
434 return true; 422 return true;
435 } 423 }
436 424
437 if (!curr_entry) 425 if (!curr_entry)
438 return false; 426 return false;
439 427
440 // We can't switch a RenderView between view source and non-view source mode 428 // We can't switch a RenderView between view source and non-view source mode
441 // without screwing up the session history sometimes (when navigating between 429 // without screwing up the session history sometimes (when navigating between
442 // "view-source:http://foo.com/" and "http://foo.com/", WebKit doesn't treat 430 // "view-source:http://foo.com/" and "http://foo.com/", WebKit doesn't treat
443 // it as a new navigation). So require a view switch. 431 // it as a new navigation). So require a view switch.
444 if (curr_entry->IsViewSourceMode() != new_entry->IsViewSourceMode()) 432 if (curr_entry->IsViewSourceMode() != new_entry->IsViewSourceMode())
445 return true; 433 return true;
446 434
447 return false; 435 return false;
448 } 436 }
449 437
450 bool RenderViewHostManager::ShouldReuseWebUI( 438 bool RenderViewHostManager::ShouldReuseWebUI(
451 const NavigationEntry* curr_entry, 439 const NavigationEntry* curr_entry,
452 const NavigationEntryImpl* new_entry) const { 440 const NavigationEntryImpl* new_entry) const {
453 NavigationControllerImpl& controller = 441 NavigationControllerImpl& controller =
454 delegate_->GetControllerForRenderManager(); 442 delegate_->GetControllerForRenderManager();
455 WebUIControllerFactory* factory = 443 WebUIControllerFactory* factory =
456 content::GetContentClient()->browser()->GetWebUIControllerFactory(); 444 GetContentClient()->browser()->GetWebUIControllerFactory();
457 return curr_entry && web_ui_.get() && 445 return curr_entry && web_ui_.get() &&
458 (factory->GetWebUIType(controller.GetBrowserContext(), 446 (factory->GetWebUIType(controller.GetBrowserContext(),
459 curr_entry->GetURL()) == 447 curr_entry->GetURL()) ==
460 factory->GetWebUIType(controller.GetBrowserContext(), 448 factory->GetWebUIType(controller.GetBrowserContext(),
461 new_entry->GetURL())); 449 new_entry->GetURL()));
462 } 450 }
463 451
464 SiteInstance* RenderViewHostManager::GetSiteInstanceForEntry( 452 SiteInstance* RenderViewHostManager::GetSiteInstanceForEntry(
465 const NavigationEntryImpl& entry, 453 const NavigationEntryImpl& entry,
466 SiteInstance* curr_instance) { 454 SiteInstance* curr_instance) {
467 // NOTE: This is only called when ShouldTransitionCrossSite is true. 455 // NOTE: This is only called when ShouldTransitionCrossSite is true.
468 456
469 const GURL& dest_url = entry.GetURL(); 457 const GURL& dest_url = entry.GetURL();
470 NavigationControllerImpl& controller = 458 NavigationControllerImpl& controller =
471 delegate_->GetControllerForRenderManager(); 459 delegate_->GetControllerForRenderManager();
472 content::BrowserContext* browser_context = controller.GetBrowserContext(); 460 BrowserContext* browser_context = controller.GetBrowserContext();
473 461
474 // If the entry has an instance already we should use it. 462 // If the entry has an instance already we should use it.
475 if (entry.site_instance()) 463 if (entry.site_instance())
476 return entry.site_instance(); 464 return entry.site_instance();
477 465
478 // (UGLY) HEURISTIC, process-per-site only: 466 // (UGLY) HEURISTIC, process-per-site only:
479 // 467 //
480 // If this navigation is generated, then it probably corresponds to a search 468 // If this navigation is generated, then it probably corresponds to a search
481 // query. Given that search results typically lead to users navigating to 469 // query. Given that search results typically lead to users navigating to
482 // other sites, we don't really want to use the search engine hostname to 470 // other sites, we don't really want to use the search engine hostname to
483 // determine the site instance for this navigation. 471 // determine the site instance for this navigation.
484 // 472 //
485 // NOTE: This can be removed once we have a way to transition between 473 // NOTE: This can be removed once we have a way to transition between
486 // RenderViews in response to a link click. 474 // RenderViews in response to a link click.
487 // 475 //
488 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerSite) && 476 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerSite) &&
489 entry.GetTransitionType() == content::PAGE_TRANSITION_GENERATED) 477 entry.GetTransitionType() == PAGE_TRANSITION_GENERATED)
490 return curr_instance; 478 return curr_instance;
491 479
492 SiteInstanceImpl* curr_site_instance = 480 SiteInstanceImpl* curr_site_instance =
493 static_cast<SiteInstanceImpl*>(curr_instance); 481 static_cast<SiteInstanceImpl*>(curr_instance);
494 482
495 // If we haven't used our SiteInstance (and thus RVH) yet, then we can use it 483 // If we haven't used our SiteInstance (and thus RVH) yet, then we can use it
496 // for this entry. We won't commit the SiteInstance to this site until the 484 // for this entry. We won't commit the SiteInstance to this site until the
497 // navigation commits (in DidNavigate), unless the navigation entry was 485 // navigation commits (in DidNavigate), unless the navigation entry was
498 // restored or it's a Web UI as described below. 486 // restored or it's a Web UI as described below.
499 if (!curr_site_instance->HasSite()) { 487 if (!curr_site_instance->HasSite()) {
(...skipping 27 matching lines...) Expand all
527 // View-source URLs must use a new SiteInstance and BrowsingInstance. 515 // View-source URLs must use a new SiteInstance and BrowsingInstance.
528 // TODO(nasko): This is the same condition as later in the function. This 516 // TODO(nasko): This is the same condition as later in the function. This
529 // should be taken into account when refactoring this method as part of 517 // should be taken into account when refactoring this method as part of
530 // http://crbug.com/123007. 518 // http://crbug.com/123007.
531 if (entry.IsViewSourceMode()) 519 if (entry.IsViewSourceMode())
532 return SiteInstance::CreateForURL(browser_context, dest_url); 520 return SiteInstance::CreateForURL(browser_context, dest_url);
533 521
534 // If we are navigating from a blank SiteInstance to a WebUI, make sure we 522 // If we are navigating from a blank SiteInstance to a WebUI, make sure we
535 // create a new SiteInstance. 523 // create a new SiteInstance.
536 const WebUIControllerFactory* web_ui_factory = 524 const WebUIControllerFactory* web_ui_factory =
537 content::GetContentClient()->browser()->GetWebUIControllerFactory(); 525 GetContentClient()->browser()->GetWebUIControllerFactory();
538 if (web_ui_factory && 526 if (web_ui_factory &&
539 web_ui_factory->UseWebUIForURL(browser_context, dest_url)) { 527 web_ui_factory->UseWebUIForURL(browser_context, dest_url)) {
540 return SiteInstance::CreateForURL(browser_context, dest_url); 528 return SiteInstance::CreateForURL(browser_context, dest_url);
541 } 529 }
542 530
543 // Normally the "site" on the SiteInstance is set lazily when the load 531 // Normally the "site" on the SiteInstance is set lazily when the load
544 // actually commits. This is to support better process sharing in case 532 // actually commits. This is to support better process sharing in case
545 // the site redirects to some other site: we want to use the destination 533 // the site redirects to some other site: we want to use the destination
546 // site in the site instance. 534 // site in the site instance.
547 // 535 //
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 // Make sure the size is up to date. (Fix for bug 1079768.) 721 // Make sure the size is up to date. (Fix for bug 1079768.)
734 delegate_->UpdateRenderViewSizeForRenderManager(); 722 delegate_->UpdateRenderViewSizeForRenderManager();
735 723
736 if (will_focus_location_bar) 724 if (will_focus_location_bar)
737 delegate_->SetFocusToLocationBar(false); 725 delegate_->SetFocusToLocationBar(false);
738 else if (focus_render_view && render_view_host_->GetView()) 726 else if (focus_render_view && render_view_host_->GetView())
739 RenderWidgetHostViewPort::FromRWHV(render_view_host_->GetView())->Focus(); 727 RenderWidgetHostViewPort::FromRWHV(render_view_host_->GetView())->Focus();
740 728
741 std::pair<RenderViewHost*, RenderViewHost*> details = 729 std::pair<RenderViewHost*, RenderViewHost*> details =
742 std::make_pair(old_render_view_host, render_view_host_); 730 std::make_pair(old_render_view_host, render_view_host_);
743 content::NotificationService::current()->Notify( 731 NotificationService::current()->Notify(
744 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, 732 NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
745 content::Source<NavigationController>( 733 Source<NavigationController>(
746 &delegate_->GetControllerForRenderManager()), 734 &delegate_->GetControllerForRenderManager()),
747 content::Details<std::pair<RenderViewHost*, RenderViewHost*> >(&details)); 735 Details<std::pair<RenderViewHost*, RenderViewHost*> >(&details));
748 736
749 // If the pending view was on the swapped out list, we can remove it. 737 // If the pending view was on the swapped out list, we can remove it.
750 swapped_out_hosts_.erase(render_view_host_->GetSiteInstance()->GetId()); 738 swapped_out_hosts_.erase(render_view_host_->GetSiteInstance()->GetId());
751 739
752 // If the old RVH is live, we are swapping it out and should keep track of it 740 // If the old RVH is live, we are swapping it out and should keep track of it
753 // in case we navigate back to it. 741 // in case we navigate back to it.
754 if (old_render_view_host->IsRenderViewLive()) { 742 if (old_render_view_host->IsRenderViewLive()) {
755 DCHECK(old_render_view_host->is_swapped_out()); 743 DCHECK(old_render_view_host->is_swapped_out());
756 // Temp fix for http://crbug.com/90867 until we do a better cleanup to make 744 // Temp fix for http://crbug.com/90867 until we do a better cleanup to make
757 // sure we don't get different rvh instances for the same site instance 745 // sure we don't get different rvh instances for the same site instance
(...skipping 29 matching lines...) Expand all
787 } 775 }
788 776
789 // render_view_host_ will not be deleted before the end of this method, so we 777 // render_view_host_ will not be deleted before the end of this method, so we
790 // don't have to worry about this SiteInstance's ref count dropping to zero. 778 // don't have to worry about this SiteInstance's ref count dropping to zero.
791 SiteInstance* curr_instance = render_view_host_->GetSiteInstance(); 779 SiteInstance* curr_instance = render_view_host_->GetSiteInstance();
792 780
793 // Determine if we need a new SiteInstance for this entry. 781 // Determine if we need a new SiteInstance for this entry.
794 // Again, new_instance won't be deleted before the end of this method, so it 782 // Again, new_instance won't be deleted before the end of this method, so it
795 // is safe to use a normal pointer here. 783 // is safe to use a normal pointer here.
796 SiteInstance* new_instance = curr_instance; 784 SiteInstance* new_instance = curr_instance;
797 const content::NavigationEntry* curr_entry = 785 const NavigationEntry* curr_entry =
798 delegate_->GetLastCommittedNavigationEntryForRenderManager(); 786 delegate_->GetLastCommittedNavigationEntryForRenderManager();
799 bool is_guest_scheme = curr_instance->GetSiteURL().SchemeIs( 787 bool is_guest_scheme = curr_instance->GetSiteURL().SchemeIs(
800 chrome::kGuestScheme); 788 chrome::kGuestScheme);
801 bool force_swap = ShouldSwapProcessesForNavigation(curr_entry, &entry); 789 bool force_swap = ShouldSwapProcessesForNavigation(curr_entry, &entry);
802 if (!is_guest_scheme && (ShouldTransitionCrossSite() || force_swap)) 790 if (!is_guest_scheme && (ShouldTransitionCrossSite() || force_swap))
803 new_instance = GetSiteInstanceForEntry(entry, curr_instance); 791 new_instance = GetSiteInstanceForEntry(entry, curr_instance);
804 792
805 if (!is_guest_scheme && (new_instance != curr_instance || force_swap)) { 793 if (!is_guest_scheme && (new_instance != curr_instance || force_swap)) {
806 // New SiteInstance. 794 // New SiteInstance.
807 DCHECK(!cross_navigation_pending_); 795 DCHECK(!cross_navigation_pending_);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 // Same SiteInstance can be used. Navigate render_view_host_ if we are not 886 // Same SiteInstance can be used. Navigate render_view_host_ if we are not
899 // cross navigating. 887 // cross navigating.
900 DCHECK(!cross_navigation_pending_); 888 DCHECK(!cross_navigation_pending_);
901 return render_view_host_; 889 return render_view_host_;
902 } 890 }
903 891
904 void RenderViewHostManager::CancelPending() { 892 void RenderViewHostManager::CancelPending() {
905 RenderViewHostImpl* pending_render_view_host = pending_render_view_host_; 893 RenderViewHostImpl* pending_render_view_host = pending_render_view_host_;
906 pending_render_view_host_ = NULL; 894 pending_render_view_host_ = NULL;
907 895
908 content::DevToolsManagerImpl::GetInstance()->OnCancelPendingNavigation( 896 DevToolsManagerImpl::GetInstance()->OnCancelPendingNavigation(
909 pending_render_view_host, 897 pending_render_view_host,
910 render_view_host_); 898 render_view_host_);
911 899
912 // We no longer need to prevent the process from exiting. 900 // We no longer need to prevent the process from exiting.
913 pending_render_view_host->GetProcess()->RemovePendingView(); 901 pending_render_view_host->GetProcess()->RemovePendingView();
914 902
915 // The pending RVH may already be on the swapped out list if we started to 903 // The pending RVH may already be on the swapped out list if we started to
916 // swap it back in and then canceled. If so, make sure it gets swapped out 904 // swap it back in and then canceled. If so, make sure it gets swapped out
917 // again. If it's not on the swapped out list (e.g., aborting a pending 905 // again. If it's not on the swapped out list (e.g., aborting a pending
918 // load), then it's safe to shut down. 906 // load), then it's safe to shut down.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 } 957 }
970 958
971 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost( 959 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost(
972 SiteInstance* instance) { 960 SiteInstance* instance) {
973 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); 961 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId());
974 if (iter != swapped_out_hosts_.end()) 962 if (iter != swapped_out_hosts_.end())
975 return iter->second; 963 return iter->second;
976 964
977 return NULL; 965 return NULL;
978 } 966 }
967
968 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698