| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/tab_contents/render_view_host_manager.h" | 5 #include "chrome/browser/tab_contents/render_view_host_manager.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "chrome/browser/dom_ui/dom_ui.h" | 9 #include "chrome/browser/dom_ui/dom_ui.h" |
| 10 #include "chrome/browser/dom_ui/dom_ui_factory.h" | 10 #include "chrome/browser/dom_ui/dom_ui_factory.h" |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 // | 332 // |
| 333 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerSite) && | 333 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerSite) && |
| 334 entry.transition_type() == PageTransition::GENERATED) | 334 entry.transition_type() == PageTransition::GENERATED) |
| 335 return curr_instance; | 335 return curr_instance; |
| 336 | 336 |
| 337 const GURL& dest_url = entry.url(); | 337 const GURL& dest_url = entry.url(); |
| 338 | 338 |
| 339 // If we haven't used our SiteInstance (and thus RVH) yet, then we can use it | 339 // If we haven't used our SiteInstance (and thus RVH) yet, then we can use it |
| 340 // for this entry. We won't commit the SiteInstance to this site until the | 340 // for this entry. We won't commit the SiteInstance to this site until the |
| 341 // navigation commits (in DidNavigate), unless the navigation entry was | 341 // navigation commits (in DidNavigate), unless the navigation entry was |
| 342 // restored. As session restore loads all the pages immediately we need to set | 342 // restored or it's a DOM UI as described below. |
| 343 // the site first, otherwise after a restore none of the pages would share | |
| 344 // renderers. | |
| 345 if (!curr_instance->has_site()) { | 343 if (!curr_instance->has_site()) { |
| 346 // If we've already created a SiteInstance for our destination, we don't | 344 // If we've already created a SiteInstance for our destination, we don't |
| 347 // want to use this unused SiteInstance; use the existing one. (We don't | 345 // want to use this unused SiteInstance; use the existing one. (We don't |
| 348 // do this check if the curr_instance has a site, because for now, we want | 346 // do this check if the curr_instance has a site, because for now, we want |
| 349 // to compare against the current URL and not the SiteInstance's site. In | 347 // to compare against the current URL and not the SiteInstance's site. In |
| 350 // this case, there is no current URL, so comparing against the site is ok. | 348 // this case, there is no current URL, so comparing against the site is ok. |
| 351 // See additional comments below.) | 349 // See additional comments below.) |
| 352 if (curr_instance->HasRelatedSiteInstance(dest_url)) { | 350 if (curr_instance->HasRelatedSiteInstance(dest_url)) { |
| 353 return curr_instance->GetRelatedSiteInstance(dest_url); | 351 return curr_instance->GetRelatedSiteInstance(dest_url); |
| 354 } else { | 352 } else { |
| 355 if (entry.restore_type() != NavigationEntry::RESTORE_NONE) | 353 // Normally the "site" on the SiteInstance is set lazily when the load |
| 354 // actually commits. This is to support better process sharing in case |
| 355 // the site redirects to some other site: we want to use the destination |
| 356 // site in the site instance. |
| 357 // |
| 358 // In the case of session restore, as it loads all the pages immediately |
| 359 // we need to set the site first, otherwise after a restore none of the |
| 360 // pages would share renderers. |
| 361 // |
| 362 // For DOM UI (this mostly comes up for the new tab page), the |
| 363 // SiteInstance has special meaning: we never want to reassign the |
| 364 // process. If you navigate to another site before the DOM UI commits, |
| 365 // we still want to create a new process rather than re-using the |
| 366 // existing DOM UI process. |
| 367 if (entry.restore_type() != NavigationEntry::RESTORE_NONE || |
| 368 DOMUIFactory::HasDOMUIScheme(dest_url)) |
| 356 curr_instance->SetSite(dest_url); | 369 curr_instance->SetSite(dest_url); |
| 357 return curr_instance; | 370 return curr_instance; |
| 358 } | 371 } |
| 359 } | 372 } |
| 360 | 373 |
| 361 // Otherwise, only create a new SiteInstance for cross-site navigation. | 374 // Otherwise, only create a new SiteInstance for cross-site navigation. |
| 362 | 375 |
| 363 // TODO(creis): Once we intercept links and script-based navigations, we | 376 // TODO(creis): Once we intercept links and script-based navigations, we |
| 364 // will be able to enforce that all entries in a SiteInstance actually have | 377 // will be able to enforce that all entries in a SiteInstance actually have |
| 365 // the same site, and it will be safe to compare the URL against the | 378 // the same site, and it will be safe to compare the URL against the |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 // deleted (not sure from where) but not NULLed. | 632 // deleted (not sure from where) but not NULLed. |
| 620 if (rvh == pending_render_view_host_) { | 633 if (rvh == pending_render_view_host_) { |
| 621 // If you hit this NOTREACHED, please report it in the following bug | 634 // If you hit this NOTREACHED, please report it in the following bug |
| 622 // http://crbug.com/23411 Make sure to include what you were doing when it | 635 // http://crbug.com/23411 Make sure to include what you were doing when it |
| 623 // happened (navigating to a new page, closing a tab...) and if you can | 636 // happened (navigating to a new page, closing a tab...) and if you can |
| 624 // reproduce. | 637 // reproduce. |
| 625 NOTREACHED(); | 638 NOTREACHED(); |
| 626 pending_render_view_host_ = NULL; | 639 pending_render_view_host_ = NULL; |
| 627 } | 640 } |
| 628 } | 641 } |
| OLD | NEW |