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

Side by Side Diff: content/browser/site_instance_impl_unittest.cc

Issue 11275088: Remove implicit scoped_refptr operator T* Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
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 "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/stl_util.h" 7 #include "base/stl_util.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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 static_cast<SiteInstanceImpl*>( 420 static_cast<SiteInstanceImpl*>(
421 browsing_instance->GetSiteInstanceForURL(url_a1))); 421 browsing_instance->GetSiteInstanceForURL(url_a1)));
422 EXPECT_TRUE(site_instance_a1.get() != NULL); 422 EXPECT_TRUE(site_instance_a1.get() != NULL);
423 423
424 // A separate site should create a separate SiteInstance. 424 // A separate site should create a separate SiteInstance.
425 const GURL url_b1("http://www.yahoo.com/"); 425 const GURL url_b1("http://www.yahoo.com/");
426 scoped_refptr<SiteInstanceImpl> site_instance_b1( 426 scoped_refptr<SiteInstanceImpl> site_instance_b1(
427 static_cast<SiteInstanceImpl*>( 427 static_cast<SiteInstanceImpl*>(
428 browsing_instance->GetSiteInstanceForURL(url_b1))); 428 browsing_instance->GetSiteInstanceForURL(url_b1)));
429 EXPECT_NE(site_instance_a1.get(), site_instance_b1.get()); 429 EXPECT_NE(site_instance_a1.get(), site_instance_b1.get());
430 EXPECT_TRUE(site_instance_a1->IsRelatedSiteInstance(site_instance_b1)); 430 EXPECT_TRUE(site_instance_a1->IsRelatedSiteInstance(site_instance_b1.get()));
431 431
432 // Getting the new SiteInstance from the BrowsingInstance and from another 432 // Getting the new SiteInstance from the BrowsingInstance and from another
433 // SiteInstance in the BrowsingInstance should give the same result. 433 // SiteInstance in the BrowsingInstance should give the same result.
434 EXPECT_EQ(site_instance_b1.get(), 434 EXPECT_EQ(site_instance_b1.get(),
435 site_instance_a1->GetRelatedSiteInstance(url_b1)); 435 site_instance_a1->GetRelatedSiteInstance(url_b1));
436 436
437 // A second visit to the original site should return the same SiteInstance. 437 // A second visit to the original site should return the same SiteInstance.
438 const GURL url_a2("http://www.google.com/2.html"); 438 const GURL url_a2("http://www.google.com/2.html");
439 EXPECT_EQ(site_instance_a1.get(), 439 EXPECT_EQ(site_instance_a1.get(),
440 browsing_instance->GetSiteInstanceForURL(url_a2)); 440 browsing_instance->GetSiteInstanceForURL(url_a2));
441 EXPECT_EQ(site_instance_a1.get(), 441 EXPECT_EQ(site_instance_a1.get(),
442 site_instance_a1->GetRelatedSiteInstance(url_a2)); 442 site_instance_a1->GetRelatedSiteInstance(url_a2));
443 443
444 // A visit to the original site in a new BrowsingInstance (same or different 444 // A visit to the original site in a new BrowsingInstance (same or different
445 // browser context) should return a different SiteInstance. 445 // browser context) should return a different SiteInstance.
446 TestBrowsingInstance* browsing_instance2 = 446 TestBrowsingInstance* browsing_instance2 =
447 new TestBrowsingInstance(browser_context.get(), &delete_counter); 447 new TestBrowsingInstance(browser_context.get(), &delete_counter);
448 // Ensure the new SiteInstance is ref counted so that it gets deleted. 448 // Ensure the new SiteInstance is ref counted so that it gets deleted.
449 scoped_refptr<SiteInstanceImpl> site_instance_a2_2( 449 scoped_refptr<SiteInstanceImpl> site_instance_a2_2(
450 static_cast<SiteInstanceImpl*>( 450 static_cast<SiteInstanceImpl*>(
451 browsing_instance2->GetSiteInstanceForURL(url_a2))); 451 browsing_instance2->GetSiteInstanceForURL(url_a2)));
452 EXPECT_NE(site_instance_a1.get(), site_instance_a2_2.get()); 452 EXPECT_NE(site_instance_a1.get(), site_instance_a2_2.get());
453 EXPECT_FALSE(site_instance_a1->IsRelatedSiteInstance(site_instance_a2_2)); 453 EXPECT_FALSE(
454 site_instance_a1->IsRelatedSiteInstance(site_instance_a2_2.get()));
454 455
455 // The two SiteInstances for http://google.com should not use the same process 456 // The two SiteInstances for http://google.com should not use the same process
456 // if process-per-site is not enabled. 457 // if process-per-site is not enabled.
457 scoped_ptr<RenderProcessHost> process_a1(site_instance_a1->GetProcess()); 458 scoped_ptr<RenderProcessHost> process_a1(site_instance_a1->GetProcess());
458 scoped_ptr<RenderProcessHost> process_a2_2(site_instance_a2_2->GetProcess()); 459 scoped_ptr<RenderProcessHost> process_a2_2(site_instance_a2_2->GetProcess());
459 EXPECT_NE(process_a1.get(), process_a2_2.get()); 460 EXPECT_NE(process_a1.get(), process_a2_2.get());
460 461
461 // Should be able to see that we do have SiteInstances. 462 // Should be able to see that we do have SiteInstances.
462 EXPECT_TRUE(browsing_instance->HasSiteInstance( 463 EXPECT_TRUE(browsing_instance->HasSiteInstance(
463 GURL("http://mail.google.com"))); 464 GURL("http://mail.google.com")));
(...skipping 30 matching lines...) Expand all
494 browsing_instance->GetSiteInstanceForURL(url_a1))); 495 browsing_instance->GetSiteInstanceForURL(url_a1)));
495 EXPECT_TRUE(site_instance_a1.get() != NULL); 496 EXPECT_TRUE(site_instance_a1.get() != NULL);
496 scoped_ptr<RenderProcessHost> process_a1(site_instance_a1->GetProcess()); 497 scoped_ptr<RenderProcessHost> process_a1(site_instance_a1->GetProcess());
497 498
498 // A separate site should create a separate SiteInstance. 499 // A separate site should create a separate SiteInstance.
499 const GURL url_b1("http://www.yahoo.com/"); 500 const GURL url_b1("http://www.yahoo.com/");
500 scoped_refptr<SiteInstanceImpl> site_instance_b1( 501 scoped_refptr<SiteInstanceImpl> site_instance_b1(
501 static_cast<SiteInstanceImpl*>( 502 static_cast<SiteInstanceImpl*>(
502 browsing_instance->GetSiteInstanceForURL(url_b1))); 503 browsing_instance->GetSiteInstanceForURL(url_b1)));
503 EXPECT_NE(site_instance_a1.get(), site_instance_b1.get()); 504 EXPECT_NE(site_instance_a1.get(), site_instance_b1.get());
504 EXPECT_TRUE(site_instance_a1->IsRelatedSiteInstance(site_instance_b1)); 505 EXPECT_TRUE(site_instance_a1->IsRelatedSiteInstance(site_instance_b1.get()));
505 506
506 // Getting the new SiteInstance from the BrowsingInstance and from another 507 // Getting the new SiteInstance from the BrowsingInstance and from another
507 // SiteInstance in the BrowsingInstance should give the same result. 508 // SiteInstance in the BrowsingInstance should give the same result.
508 EXPECT_EQ(site_instance_b1.get(), 509 EXPECT_EQ(site_instance_b1.get(),
509 site_instance_a1->GetRelatedSiteInstance(url_b1)); 510 site_instance_a1->GetRelatedSiteInstance(url_b1));
510 511
511 // A second visit to the original site should return the same SiteInstance. 512 // A second visit to the original site should return the same SiteInstance.
512 const GURL url_a2("http://www.google.com/2.html"); 513 const GURL url_a2("http://www.google.com/2.html");
513 EXPECT_EQ(site_instance_a1.get(), 514 EXPECT_EQ(site_instance_a1.get(),
514 browsing_instance->GetSiteInstanceForURL(url_a2)); 515 browsing_instance->GetSiteInstanceForURL(url_a2));
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 EXPECT_FALSE(instance->HasWrongProcessForURL(GURL("http://evernote.com"))); 654 EXPECT_FALSE(instance->HasWrongProcessForURL(GURL("http://evernote.com")));
654 EXPECT_FALSE(instance->HasWrongProcessForURL( 655 EXPECT_FALSE(instance->HasWrongProcessForURL(
655 GURL("javascript:alert(document.location.href);"))); 656 GURL("javascript:alert(document.location.href);")));
656 657
657 EXPECT_TRUE(instance->HasWrongProcessForURL(GURL("chrome://settings"))); 658 EXPECT_TRUE(instance->HasWrongProcessForURL(GURL("chrome://settings")));
658 659
659 DrainMessageLoops(); 660 DrainMessageLoops();
660 } 661 }
661 662
662 } // namespace content 663 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/resource_loader.cc ('k') | content/browser/speech/endpointer/endpointer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698