| 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/site_instance_impl.h" | 5 #include "content/browser/site_instance_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 | 806 |
| 807 std::unique_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); | 807 std::unique_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); |
| 808 scoped_refptr<SiteInstanceImpl> main_instance = | 808 scoped_refptr<SiteInstanceImpl> main_instance = |
| 809 SiteInstanceImpl::Create(browser_context.get()); | 809 SiteInstanceImpl::Create(browser_context.get()); |
| 810 scoped_refptr<SiteInstanceImpl> subframe_instance = | 810 scoped_refptr<SiteInstanceImpl> subframe_instance = |
| 811 main_instance->GetDefaultSubframeSiteInstance(); | 811 main_instance->GetDefaultSubframeSiteInstance(); |
| 812 int subframe_instance_id = subframe_instance->GetId(); | 812 int subframe_instance_id = subframe_instance->GetId(); |
| 813 | 813 |
| 814 EXPECT_NE(main_instance, subframe_instance); | 814 EXPECT_NE(main_instance, subframe_instance); |
| 815 EXPECT_EQ(subframe_instance, main_instance->GetDefaultSubframeSiteInstance()); | 815 EXPECT_EQ(subframe_instance, main_instance->GetDefaultSubframeSiteInstance()); |
| 816 EXPECT_FALSE(main_instance->is_default_subframe_site_instance()); | 816 EXPECT_FALSE(main_instance->IsDefaultSubframeSiteInstance()); |
| 817 EXPECT_TRUE(subframe_instance->is_default_subframe_site_instance()); | 817 EXPECT_TRUE(subframe_instance->IsDefaultSubframeSiteInstance()); |
| 818 | 818 |
| 819 EXPECT_EQ(0, browser_client()->GetAndClearSiteInstanceDeleteCount()); | 819 EXPECT_EQ(0, browser_client()->GetAndClearSiteInstanceDeleteCount()); |
| 820 EXPECT_EQ(0, browser_client()->GetAndClearBrowsingInstanceDeleteCount()); | 820 EXPECT_EQ(0, browser_client()->GetAndClearBrowsingInstanceDeleteCount()); |
| 821 | 821 |
| 822 // Free the subframe instance. | 822 // Free the subframe instance. |
| 823 subframe_instance = nullptr; | 823 subframe_instance = nullptr; |
| 824 EXPECT_EQ(1, browser_client()->GetAndClearSiteInstanceDeleteCount()); | 824 EXPECT_EQ(1, browser_client()->GetAndClearSiteInstanceDeleteCount()); |
| 825 EXPECT_EQ(0, browser_client()->GetAndClearBrowsingInstanceDeleteCount()); | 825 EXPECT_EQ(0, browser_client()->GetAndClearBrowsingInstanceDeleteCount()); |
| 826 | 826 |
| 827 // Calling GetDefaultSubframeSiteInstance again should return a new | 827 // Calling GetDefaultSubframeSiteInstance again should return a new |
| 828 // SiteInstance with a different ID from the original. | 828 // SiteInstance with a different ID from the original. |
| 829 subframe_instance = main_instance->GetDefaultSubframeSiteInstance(); | 829 subframe_instance = main_instance->GetDefaultSubframeSiteInstance(); |
| 830 EXPECT_NE(subframe_instance->GetId(), subframe_instance_id); | 830 EXPECT_NE(subframe_instance->GetId(), subframe_instance_id); |
| 831 EXPECT_FALSE(main_instance->is_default_subframe_site_instance()); | 831 EXPECT_FALSE(main_instance->IsDefaultSubframeSiteInstance()); |
| 832 EXPECT_TRUE(subframe_instance->is_default_subframe_site_instance()); | 832 EXPECT_TRUE(subframe_instance->IsDefaultSubframeSiteInstance()); |
| 833 EXPECT_EQ(subframe_instance->GetDefaultSubframeSiteInstance(), | 833 EXPECT_EQ(subframe_instance->GetDefaultSubframeSiteInstance(), |
| 834 subframe_instance); | 834 subframe_instance); |
| 835 EXPECT_EQ(0, browser_client()->GetAndClearSiteInstanceDeleteCount()); | 835 EXPECT_EQ(0, browser_client()->GetAndClearSiteInstanceDeleteCount()); |
| 836 EXPECT_EQ(0, browser_client()->GetAndClearBrowsingInstanceDeleteCount()); | 836 EXPECT_EQ(0, browser_client()->GetAndClearBrowsingInstanceDeleteCount()); |
| 837 | 837 |
| 838 // Free the main instance. | 838 // Free the main instance. |
| 839 main_instance = nullptr; | 839 main_instance = nullptr; |
| 840 EXPECT_EQ(1, browser_client()->GetAndClearSiteInstanceDeleteCount()); | 840 EXPECT_EQ(1, browser_client()->GetAndClearSiteInstanceDeleteCount()); |
| 841 EXPECT_EQ(0, browser_client()->GetAndClearBrowsingInstanceDeleteCount()); | 841 EXPECT_EQ(0, browser_client()->GetAndClearBrowsingInstanceDeleteCount()); |
| 842 | 842 |
| 843 // Free the subframe instance, which should free the browsing instance. | 843 // Free the subframe instance, which should free the browsing instance. |
| 844 subframe_instance = nullptr; | 844 subframe_instance = nullptr; |
| 845 EXPECT_EQ(1, browser_client()->GetAndClearSiteInstanceDeleteCount()); | 845 EXPECT_EQ(1, browser_client()->GetAndClearSiteInstanceDeleteCount()); |
| 846 EXPECT_EQ(1, browser_client()->GetAndClearBrowsingInstanceDeleteCount()); | 846 EXPECT_EQ(1, browser_client()->GetAndClearBrowsingInstanceDeleteCount()); |
| 847 } | 847 } |
| 848 | 848 |
| 849 } // namespace content | 849 } // namespace content |
| OLD | NEW |