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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
7 #include "base/memory/scoped_vector.h" | 7 #include "base/memory/scoped_vector.h" |
8 #include "base/string16.h" | 8 #include "base/string16.h" |
9 #include "content/browser/browser_thread_impl.h" | 9 #include "content/browser/browser_thread_impl.h" |
10 #include "content/browser/browsing_instance.h" | 10 #include "content/browser/browsing_instance.h" |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 static_cast<SiteInstanceImpl*>( | 401 static_cast<SiteInstanceImpl*>( |
402 browsing_instance->GetSiteInstanceForURL(url_a1))); | 402 browsing_instance->GetSiteInstanceForURL(url_a1))); |
403 EXPECT_TRUE(site_instance_a1.get() != NULL); | 403 EXPECT_TRUE(site_instance_a1.get() != NULL); |
404 | 404 |
405 // A separate site should create a separate SiteInstance. | 405 // A separate site should create a separate SiteInstance. |
406 const GURL url_b1("http://www.yahoo.com/"); | 406 const GURL url_b1("http://www.yahoo.com/"); |
407 scoped_refptr<SiteInstanceImpl> site_instance_b1( | 407 scoped_refptr<SiteInstanceImpl> site_instance_b1( |
408 static_cast<SiteInstanceImpl*>( | 408 static_cast<SiteInstanceImpl*>( |
409 browsing_instance->GetSiteInstanceForURL(url_b1))); | 409 browsing_instance->GetSiteInstanceForURL(url_b1))); |
410 EXPECT_NE(site_instance_a1.get(), site_instance_b1.get()); | 410 EXPECT_NE(site_instance_a1.get(), site_instance_b1.get()); |
411 EXPECT_TRUE(site_instance_a1->IsRelatedSiteInstance(site_instance_b1)); | 411 EXPECT_TRUE(site_instance_a1->IsRelatedSiteInstance(site_instance_b1.get())); |
412 | 412 |
413 // Getting the new SiteInstance from the BrowsingInstance and from another | 413 // Getting the new SiteInstance from the BrowsingInstance and from another |
414 // SiteInstance in the BrowsingInstance should give the same result. | 414 // SiteInstance in the BrowsingInstance should give the same result. |
415 EXPECT_EQ(site_instance_b1.get(), | 415 EXPECT_EQ(site_instance_b1.get(), |
416 site_instance_a1->GetRelatedSiteInstance(url_b1)); | 416 site_instance_a1->GetRelatedSiteInstance(url_b1)); |
417 | 417 |
418 // A second visit to the original site should return the same SiteInstance. | 418 // A second visit to the original site should return the same SiteInstance. |
419 const GURL url_a2("http://www.google.com/2.html"); | 419 const GURL url_a2("http://www.google.com/2.html"); |
420 EXPECT_EQ(site_instance_a1.get(), | 420 EXPECT_EQ(site_instance_a1.get(), |
421 browsing_instance->GetSiteInstanceForURL(url_a2)); | 421 browsing_instance->GetSiteInstanceForURL(url_a2)); |
422 EXPECT_EQ(site_instance_a1.get(), | 422 EXPECT_EQ(site_instance_a1.get(), |
423 site_instance_a1->GetRelatedSiteInstance(url_a2)); | 423 site_instance_a1->GetRelatedSiteInstance(url_a2)); |
424 | 424 |
425 // A visit to the original site in a new BrowsingInstance (same or different | 425 // A visit to the original site in a new BrowsingInstance (same or different |
426 // browser context) should return a different SiteInstance. | 426 // browser context) should return a different SiteInstance. |
427 TestBrowsingInstance* browsing_instance2 = | 427 TestBrowsingInstance* browsing_instance2 = |
428 new TestBrowsingInstance(browser_context.get(), &delete_counter); | 428 new TestBrowsingInstance(browser_context.get(), &delete_counter); |
429 // Ensure the new SiteInstance is ref counted so that it gets deleted. | 429 // Ensure the new SiteInstance is ref counted so that it gets deleted. |
430 scoped_refptr<SiteInstanceImpl> site_instance_a2_2( | 430 scoped_refptr<SiteInstanceImpl> site_instance_a2_2( |
431 static_cast<SiteInstanceImpl*>( | 431 static_cast<SiteInstanceImpl*>( |
432 browsing_instance2->GetSiteInstanceForURL(url_a2))); | 432 browsing_instance2->GetSiteInstanceForURL(url_a2))); |
433 EXPECT_NE(site_instance_a1.get(), site_instance_a2_2.get()); | 433 EXPECT_NE(site_instance_a1.get(), site_instance_a2_2.get()); |
434 EXPECT_FALSE(site_instance_a1->IsRelatedSiteInstance(site_instance_a2_2)); | 434 EXPECT_FALSE( |
| 435 site_instance_a1->IsRelatedSiteInstance(site_instance_a2_2.get())); |
435 | 436 |
436 // The two SiteInstances for http://google.com should not use the same process | 437 // The two SiteInstances for http://google.com should not use the same process |
437 // if process-per-site is not enabled. | 438 // if process-per-site is not enabled. |
438 scoped_ptr<RenderProcessHost> process_a1(site_instance_a1->GetProcess()); | 439 scoped_ptr<RenderProcessHost> process_a1(site_instance_a1->GetProcess()); |
439 scoped_ptr<RenderProcessHost> process_a2_2(site_instance_a2_2->GetProcess()); | 440 scoped_ptr<RenderProcessHost> process_a2_2(site_instance_a2_2->GetProcess()); |
440 EXPECT_NE(process_a1.get(), process_a2_2.get()); | 441 EXPECT_NE(process_a1.get(), process_a2_2.get()); |
441 | 442 |
442 // Should be able to see that we do have SiteInstances. | 443 // Should be able to see that we do have SiteInstances. |
443 EXPECT_TRUE(browsing_instance->HasSiteInstance( | 444 EXPECT_TRUE(browsing_instance->HasSiteInstance( |
444 GURL("http://mail.google.com"))); | 445 GURL("http://mail.google.com"))); |
(...skipping 30 matching lines...) Expand all Loading... |
475 browsing_instance->GetSiteInstanceForURL(url_a1))); | 476 browsing_instance->GetSiteInstanceForURL(url_a1))); |
476 EXPECT_TRUE(site_instance_a1.get() != NULL); | 477 EXPECT_TRUE(site_instance_a1.get() != NULL); |
477 scoped_ptr<RenderProcessHost> process_a1(site_instance_a1->GetProcess()); | 478 scoped_ptr<RenderProcessHost> process_a1(site_instance_a1->GetProcess()); |
478 | 479 |
479 // A separate site should create a separate SiteInstance. | 480 // A separate site should create a separate SiteInstance. |
480 const GURL url_b1("http://www.yahoo.com/"); | 481 const GURL url_b1("http://www.yahoo.com/"); |
481 scoped_refptr<SiteInstanceImpl> site_instance_b1( | 482 scoped_refptr<SiteInstanceImpl> site_instance_b1( |
482 static_cast<SiteInstanceImpl*>( | 483 static_cast<SiteInstanceImpl*>( |
483 browsing_instance->GetSiteInstanceForURL(url_b1))); | 484 browsing_instance->GetSiteInstanceForURL(url_b1))); |
484 EXPECT_NE(site_instance_a1.get(), site_instance_b1.get()); | 485 EXPECT_NE(site_instance_a1.get(), site_instance_b1.get()); |
485 EXPECT_TRUE(site_instance_a1->IsRelatedSiteInstance(site_instance_b1)); | 486 EXPECT_TRUE(site_instance_a1->IsRelatedSiteInstance(site_instance_b1.get())); |
486 | 487 |
487 // Getting the new SiteInstance from the BrowsingInstance and from another | 488 // Getting the new SiteInstance from the BrowsingInstance and from another |
488 // SiteInstance in the BrowsingInstance should give the same result. | 489 // SiteInstance in the BrowsingInstance should give the same result. |
489 EXPECT_EQ(site_instance_b1.get(), | 490 EXPECT_EQ(site_instance_b1.get(), |
490 site_instance_a1->GetRelatedSiteInstance(url_b1)); | 491 site_instance_a1->GetRelatedSiteInstance(url_b1)); |
491 | 492 |
492 // A second visit to the original site should return the same SiteInstance. | 493 // A second visit to the original site should return the same SiteInstance. |
493 const GURL url_a2("http://www.google.com/2.html"); | 494 const GURL url_a2("http://www.google.com/2.html"); |
494 EXPECT_EQ(site_instance_a1.get(), | 495 EXPECT_EQ(site_instance_a1.get(), |
495 browsing_instance->GetSiteInstanceForURL(url_a2)); | 496 browsing_instance->GetSiteInstanceForURL(url_a2)); |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 EXPECT_TRUE(instance->GetSiteURL().is_empty()); | 754 EXPECT_TRUE(instance->GetSiteURL().is_empty()); |
754 host.reset(instance->GetProcess()); | 755 host.reset(instance->GetProcess()); |
755 | 756 |
756 EXPECT_FALSE(RenderProcessHostImpl::GetProcessHostForSite( | 757 EXPECT_FALSE(RenderProcessHostImpl::GetProcessHostForSite( |
757 browser_context.get(), GURL())); | 758 browser_context.get(), GURL())); |
758 | 759 |
759 DrainMessageLoops(); | 760 DrainMessageLoops(); |
760 } | 761 } |
761 | 762 |
762 } // namespace content | 763 } // namespace content |
OLD | NEW |