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

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

Issue 2861433002: Implement ProcessReusePolicy for SiteInstances (Closed)
Patch Set: Fixed ChromeOS issue Created 3 years, 7 months 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
« no previous file with comments | « content/browser/site_instance_impl.cc ('k') | content/test/test_render_view_host_factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 class SiteInstanceTest : public testing::Test { 98 class SiteInstanceTest : public testing::Test {
99 public: 99 public:
100 SiteInstanceTest() : old_browser_client_(nullptr) {} 100 SiteInstanceTest() : old_browser_client_(nullptr) {}
101 101
102 void SetUp() override { 102 void SetUp() override {
103 old_browser_client_ = SetBrowserClientForTesting(&browser_client_); 103 old_browser_client_ = SetBrowserClientForTesting(&browser_client_);
104 url::AddStandardScheme(kPrivilegedScheme, url::SCHEME_WITHOUT_PORT); 104 url::AddStandardScheme(kPrivilegedScheme, url::SCHEME_WITHOUT_PORT);
105 url::AddStandardScheme(kChromeUIScheme, url::SCHEME_WITHOUT_PORT); 105 url::AddStandardScheme(kChromeUIScheme, url::SCHEME_WITHOUT_PORT);
106 106
107 SiteInstanceImpl::set_render_process_host_factory(&rph_factory_); 107 RenderProcessHostImpl::set_render_process_host_factory(&rph_factory_);
108 } 108 }
109 109
110 void TearDown() override { 110 void TearDown() override {
111 // Ensure that no RenderProcessHosts are left over after the tests. 111 // Ensure that no RenderProcessHosts are left over after the tests.
112 EXPECT_TRUE(RenderProcessHost::AllHostsIterator().IsAtEnd()); 112 EXPECT_TRUE(RenderProcessHost::AllHostsIterator().IsAtEnd());
113 113
114 SetBrowserClientForTesting(old_browser_client_); 114 SetBrowserClientForTesting(old_browser_client_);
115 SiteInstanceImpl::set_render_process_host_factory(nullptr); 115 RenderProcessHostImpl::set_render_process_host_factory(nullptr);
116 116
117 // http://crbug.com/143565 found SiteInstanceTest leaking an 117 // http://crbug.com/143565 found SiteInstanceTest leaking an
118 // AppCacheDatabase. This happens because some part of the test indirectly 118 // AppCacheDatabase. This happens because some part of the test indirectly
119 // calls StoragePartitionImplMap::PostCreateInitialization(), which posts 119 // calls StoragePartitionImplMap::PostCreateInitialization(), which posts
120 // a task to the IO thread to create the AppCacheDatabase. Since the 120 // a task to the IO thread to create the AppCacheDatabase. Since the
121 // message loop is not running, the AppCacheDatabase ends up getting 121 // message loop is not running, the AppCacheDatabase ends up getting
122 // created when DrainMessageLoop() gets called at the end of a test case. 122 // created when DrainMessageLoop() gets called at the end of a test case.
123 // Immediately after, the test case ends and the AppCacheDatabase gets 123 // Immediately after, the test case ends and the AppCacheDatabase gets
124 // scheduled for deletion. Here, call DrainMessageLoop() again so the 124 // scheduled for deletion. Here, call DrainMessageLoop() again so the
125 // AppCacheDatabase actually gets deleted. 125 // AppCacheDatabase actually gets deleted.
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 EXPECT_EQ(1, browser_client()->GetAndClearSiteInstanceDeleteCount()); 835 EXPECT_EQ(1, browser_client()->GetAndClearSiteInstanceDeleteCount());
836 EXPECT_EQ(0, browser_client()->GetAndClearBrowsingInstanceDeleteCount()); 836 EXPECT_EQ(0, browser_client()->GetAndClearBrowsingInstanceDeleteCount());
837 837
838 // Free the subframe instance, which should free the browsing instance. 838 // Free the subframe instance, which should free the browsing instance.
839 subframe_instance = nullptr; 839 subframe_instance = nullptr;
840 EXPECT_EQ(1, browser_client()->GetAndClearSiteInstanceDeleteCount()); 840 EXPECT_EQ(1, browser_client()->GetAndClearSiteInstanceDeleteCount());
841 EXPECT_EQ(1, browser_client()->GetAndClearBrowsingInstanceDeleteCount()); 841 EXPECT_EQ(1, browser_client()->GetAndClearBrowsingInstanceDeleteCount());
842 } 842 }
843 843
844 } // namespace content 844 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/site_instance_impl.cc ('k') | content/test/test_render_view_host_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698