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

Side by Side Diff: content/browser/web_contents/render_view_host_manager_unittest.cc

Issue 10575014: Move process-per-site logic from BrowsingInstance to RenderProcessHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix review comment. Created 8 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 unified diff | Download patch | Annotate | Revision Log
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/utf_string_conversions.h" 5 #include "base/utf_string_conversions.h"
6 #include "content/browser/browser_thread_impl.h" 6 #include "content/browser/browser_thread_impl.h"
7 #include "content/browser/renderer_host/test_render_view_host.h" 7 #include "content/browser/renderer_host/test_render_view_host.h"
8 #include "content/browser/site_instance_impl.h" 8 #include "content/browser/site_instance_impl.h"
9 #include "content/browser/web_contents/navigation_controller_impl.h" 9 #include "content/browser/web_contents/navigation_controller_impl.h"
10 #include "content/browser/web_contents/navigation_entry_impl.h" 10 #include "content/browser/web_contents/navigation_entry_impl.h"
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 dest_rvh2->SendNavigate(101, kDestUrl); 231 dest_rvh2->SendNavigate(101, kDestUrl);
232 ntp_rvh2->OnSwapOutACK(); 232 ntp_rvh2->OnSwapOutACK();
233 233
234 // The two RVH's should be different in every way. 234 // The two RVH's should be different in every way.
235 EXPECT_NE(active_rvh()->GetProcess(), dest_rvh2->GetProcess()); 235 EXPECT_NE(active_rvh()->GetProcess(), dest_rvh2->GetProcess());
236 EXPECT_NE(active_rvh()->GetSiteInstance(), dest_rvh2->GetSiteInstance()); 236 EXPECT_NE(active_rvh()->GetSiteInstance(), dest_rvh2->GetSiteInstance());
237 EXPECT_FALSE(active_rvh()->GetSiteInstance()->IsRelatedSiteInstance( 237 EXPECT_FALSE(active_rvh()->GetSiteInstance()->IsRelatedSiteInstance(
238 dest_rvh2->GetSiteInstance())); 238 dest_rvh2->GetSiteInstance()));
239 239
240 // Navigate both to the new tab page, and verify that they share a 240 // Navigate both to the new tab page, and verify that they share a
241 // SiteInstance. 241 // RenderProcessHost (not a SiteInstance).
242 NavigateActiveAndCommit(kNtpUrl); 242 NavigateActiveAndCommit(kNtpUrl);
243 243
244 contents2.GetController().LoadURL( 244 contents2.GetController().LoadURL(
245 kNtpUrl, content::Referrer(), content::PAGE_TRANSITION_LINK, 245 kNtpUrl, content::Referrer(), content::PAGE_TRANSITION_LINK,
246 std::string()); 246 std::string());
247 dest_rvh2->SendShouldCloseACK(true); 247 dest_rvh2->SendShouldCloseACK(true);
248 static_cast<TestRenderViewHost*>(contents2.GetRenderManagerForTesting()-> 248 static_cast<TestRenderViewHost*>(contents2.GetRenderManagerForTesting()->
249 pending_render_view_host())->SendNavigate(102, kNtpUrl); 249 pending_render_view_host())->SendNavigate(102, kNtpUrl);
250 dest_rvh2->OnSwapOutACK(); 250 dest_rvh2->OnSwapOutACK();
251 251
252 EXPECT_EQ(active_rvh()->GetSiteInstance(), 252 EXPECT_NE(active_rvh()->GetSiteInstance(),
253 contents2.GetRenderViewHost()->GetSiteInstance()); 253 contents2.GetRenderViewHost()->GetSiteInstance());
254 EXPECT_EQ(active_rvh()->GetSiteInstance()->GetProcess(),
255 contents2.GetRenderViewHost()->GetSiteInstance()->GetProcess());
254 } 256 }
255 257
256 // Ensure that the browser ignores most IPC messages that arrive from a 258 // Ensure that the browser ignores most IPC messages that arrive from a
257 // RenderViewHost that has been swapped out. We do not want to take 259 // RenderViewHost that has been swapped out. We do not want to take
258 // action on requests from a non-active renderer. The main exception is 260 // action on requests from a non-active renderer. The main exception is
259 // for synchronous messages, which cannot be ignored without leaving the 261 // for synchronous messages, which cannot be ignored without leaving the
260 // renderer in a stuck state. See http://crbug.com/93427. 262 // renderer in a stuck state. See http://crbug.com/93427.
261 TEST_F(RenderViewHostManagerTest, FilterMessagesWhileSwappedOut) { 263 TEST_F(RenderViewHostManagerTest, FilterMessagesWhileSwappedOut) {
262 BrowserThreadImpl ui_thread(BrowserThread::UI, MessageLoop::current()); 264 BrowserThreadImpl ui_thread(BrowserThread::UI, MessageLoop::current());
263 const GURL kNtpUrl(chrome::kTestNewTabURL); 265 const GURL kNtpUrl(chrome::kTestNewTabURL);
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 EXPECT_FALSE(manager.pending_render_view_host()); 929 EXPECT_FALSE(manager.pending_render_view_host());
928 930
929 // Commit. 931 // Commit.
930 manager.DidNavigateMainFrame(host); 932 manager.DidNavigateMainFrame(host);
931 EXPECT_EQ(host, manager.current_host()); 933 EXPECT_EQ(host, manager.current_host());
932 ASSERT_TRUE(host); 934 ASSERT_TRUE(host);
933 EXPECT_EQ(static_cast<SiteInstanceImpl*>(host->GetSiteInstance()), 935 EXPECT_EQ(static_cast<SiteInstanceImpl*>(host->GetSiteInstance()),
934 instance); 936 instance);
935 937
936 } 938 }
OLDNEW
« no previous file with comments | « content/browser/web_contents/render_view_host_manager.cc ('k') | content/public/common/content_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698