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

Unified Diff: content/browser/renderer_host/render_process_host_unittest.cc

Issue 356453003: Don't share renderers between unrelated tabs on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address John(me)'s comments. Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_process_host_unittest.cc
diff --git a/content/browser/renderer_host/render_process_host_unittest.cc b/content/browser/renderer_host/render_process_host_unittest.cc
index 474a72bd166c310943037f2721e82280662f2e5c..ca497a397e5b52edbf29ce562602a51fe4d66f08 100644
--- a/content/browser/renderer_host/render_process_host_unittest.cc
+++ b/content/browser/renderer_host/render_process_host_unittest.cc
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <limits>
+
+#include "content/public/common/content_constants.h"
#include "content/public/test/mock_render_process_host.h"
#include "content/test/test_render_view_host.h"
@@ -26,4 +29,51 @@ TEST_F(RenderProcessHostUnitTest, GuestsAreNotSuitableHosts) {
RenderProcessHost::GetExistingProcessHost(browser_context(), test_url));
}
+#if !defined(OS_ANDROID)
+TEST_F(RenderProcessHostUnitTest, RendererProcessLimit) {
+ // Disable any overrides.
+ RenderProcessHostImpl::SetMaxRendererProcessCount(0);
+
+ // Verify that the limit is between 1 and kMaxRendererProcessCount.
+ EXPECT_GT(RenderProcessHostImpl::GetMaxRendererProcessCount(), 0u);
+ EXPECT_LE(RenderProcessHostImpl::GetMaxRendererProcessCount(),
+ kMaxRendererProcessCount);
+
+ // Add dummy process hosts to saturate the limit.
+ ASSERT_NE(0u, kMaxRendererProcessCount);
+ ScopedVector<MockRenderProcessHost> hosts;
+ for (size_t i = 0; i < kMaxRendererProcessCount; ++i) {
+ hosts.push_back(new MockRenderProcessHost(browser_context()));
+ }
+
+ // Verify that the renderer sharing will happen.
+ GURL test_url("http://foo.com");
+ EXPECT_TRUE(RenderProcessHostImpl::ShouldTryToUseExistingProcessHost(
+ browser_context(), test_url));
+}
+#endif
+
+#if defined(OS_ANDROID)
+TEST_F(RenderProcessHostUnitTest, NoRendererProcessLimitOnAndroid) {
+ // Disable any overrides.
+ RenderProcessHostImpl::SetMaxRendererProcessCount(0);
+
+ // Verify that by default the limit on Android returns max size_t.
+ EXPECT_EQ(std::numeric_limits<size_t>::max(),
+ RenderProcessHostImpl::GetMaxRendererProcessCount());
+
+ // Add a few dummy process hosts.
+ ASSERT_NE(0u, kMaxRendererProcessCount);
+ ScopedVector<MockRenderProcessHost> hosts;
+ for (size_t i = 0; i < kMaxRendererProcessCount; ++i) {
+ hosts.push_back(new MockRenderProcessHost(browser_context()));
+ }
+
+ // Verify that the renderer sharing still won't happen.
+ GURL test_url("http://foo.com");
+ EXPECT_FALSE(RenderProcessHostImpl::ShouldTryToUseExistingProcessHost(
+ browser_context(), test_url));
+}
+#endif
+
} // namespace content
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.cc ('k') | content/browser/site_instance_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698