Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "base/test/histogram_tester.h" | 8 #include "base/test/histogram_tester.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "content/browser/frame_host/cross_site_transferring_request.h" | 10 #include "content/browser/frame_host/cross_site_transferring_request.h" |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 void set_should_create_webui(bool should_create_webui) { | 274 void set_should_create_webui(bool should_create_webui) { |
| 275 factory_.set_should_create_webui(should_create_webui); | 275 factory_.set_should_create_webui(should_create_webui); |
| 276 } | 276 } |
| 277 | 277 |
| 278 void NavigateActiveAndCommit(const GURL& url) { | 278 void NavigateActiveAndCommit(const GURL& url) { |
| 279 // Note: we navigate the active RenderFrameHost because previous navigations | 279 // Note: we navigate the active RenderFrameHost because previous navigations |
| 280 // won't have committed yet, so NavigateAndCommit does the wrong thing | 280 // won't have committed yet, so NavigateAndCommit does the wrong thing |
| 281 // for us. | 281 // for us. |
| 282 controller().LoadURL( | 282 controller().LoadURL( |
| 283 url, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); | 283 url, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); |
| 284 TestRenderViewHost* old_rvh = test_rvh(); | 284 TestRenderFrameHost* old_rfh = contents()->GetMainFrame(); |
| 285 TestRenderFrameHost* old_rfh = main_test_rfh(); | 285 TestRenderFrameHost* active_rfh = contents()->GetPendingMainFrame() |
| 286 TestRenderFrameHost* active_rfh = pending_main_rfh() ? | 286 ? contents()->GetPendingMainFrame() |
| 287 static_cast<TestRenderFrameHost*>(pending_main_rfh()) : | 287 : old_rfh; |
| 288 old_rfh; | |
| 289 | 288 |
| 290 // Simulate the BeforeUnload_ACK that is received from the current renderer | 289 // Simulate the BeforeUnload_ACK that is received from the current renderer |
| 291 // for a cross-site navigation. | 290 // for a cross-site navigation. |
| 292 if (old_rfh != active_rfh) { | 291 if (old_rfh != active_rfh) { |
| 293 old_rfh->SendBeforeUnloadACK(true); | 292 old_rfh->SendBeforeUnloadACK(true); |
| 294 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, old_rfh->rfh_state()); | 293 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, old_rfh->rfh_state()); |
| 295 } | 294 } |
| 296 | 295 |
| 297 // Commit the navigation with a new page ID. | 296 // Commit the navigation with a new page ID. |
| 298 int32 max_page_id = contents()->GetMaxPageIDForSiteInstance( | 297 int32 max_page_id = contents()->GetMaxPageIDForSiteInstance( |
| 299 active_rfh->GetSiteInstance()); | 298 active_rfh->GetSiteInstance()); |
| 300 | 299 |
| 301 // Use an observer to avoid accessing a deleted renderer later on when the | 300 // Use an observer to avoid accessing a deleted renderer later on when the |
| 302 // state is being checked. | 301 // state is being checked. |
| 303 RenderFrameHostDeletedObserver rfh_observer(old_rfh); | 302 RenderFrameHostDeletedObserver rfh_observer(old_rfh); |
| 304 RenderViewHostDeletedObserver rvh_observer(old_rvh); | 303 RenderViewHostDeletedObserver rvh_observer(old_rfh->GetRenderViewHost()); |
| 305 active_rfh->SendNavigate(max_page_id + 1, url); | 304 active_rfh->SendNavigate(max_page_id + 1, url); |
| 306 | 305 |
| 307 // Make sure that we start to run the unload handler at the time of commit. | 306 // Make sure that we start to run the unload handler at the time of commit. |
| 308 bool expecting_rfh_shutdown = false; | 307 bool expecting_rfh_shutdown = false; |
| 309 if (old_rfh != active_rfh && !rfh_observer.deleted()) { | 308 if (old_rfh != active_rfh && !rfh_observer.deleted()) { |
| 310 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, | 309 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, |
| 311 old_rfh->rfh_state()); | 310 old_rfh->rfh_state()); |
| 312 if (!old_rfh->GetSiteInstance()->active_frame_count()) { | 311 if (!old_rfh->GetSiteInstance()->active_frame_count()) { |
| 313 expecting_rfh_shutdown = true; | 312 expecting_rfh_shutdown = true; |
| 314 EXPECT_TRUE( | 313 EXPECT_TRUE( |
| 315 old_rfh->frame_tree_node()->render_manager()->IsPendingDeletion( | 314 old_rfh->frame_tree_node()->render_manager()->IsPendingDeletion( |
| 316 old_rfh)); | 315 old_rfh)); |
| 317 } | 316 } |
| 318 } | 317 } |
| 319 | 318 |
| 320 // Simulate the swap out ACK coming from the pending renderer. This should | 319 // Simulate the swap out ACK coming from the pending renderer. This should |
| 321 // either shut down the old RFH or leave it in a swapped out state. | 320 // either shut down the old RFH or leave it in a swapped out state. |
| 322 if (old_rfh != active_rfh) { | 321 if (old_rfh != active_rfh) { |
| 323 old_rfh->OnSwappedOut(); | 322 old_rfh->OnSwappedOut(); |
| 324 if (expecting_rfh_shutdown) { | 323 if (expecting_rfh_shutdown) { |
| 325 EXPECT_TRUE(rfh_observer.deleted()); | 324 EXPECT_TRUE(rfh_observer.deleted()); |
| 326 EXPECT_TRUE(rvh_observer.deleted()); | 325 EXPECT_TRUE(rvh_observer.deleted()); |
| 327 } else { | 326 } else { |
| 328 EXPECT_EQ(RenderFrameHostImpl::STATE_SWAPPED_OUT, | 327 EXPECT_EQ(RenderFrameHostImpl::STATE_SWAPPED_OUT, |
| 329 old_rfh->rfh_state()); | 328 old_rfh->rfh_state()); |
| 330 } | 329 } |
| 331 } | 330 } |
|
Charlie Reis
2014/10/08 17:41:55
Were you going to confirm that active_rfh is the c
ncarter (slow)
2014/10/08 22:39:28
Done.
| |
| 332 } | 331 } |
| 333 | 332 |
| 334 bool ShouldSwapProcesses(RenderFrameHostManager* manager, | 333 bool ShouldSwapProcesses(RenderFrameHostManager* manager, |
| 335 const NavigationEntryImpl* current_entry, | 334 const NavigationEntryImpl* current_entry, |
| 336 const NavigationEntryImpl* new_entry) const { | 335 const NavigationEntryImpl* new_entry) const { |
| 337 CHECK(new_entry); | 336 CHECK(new_entry); |
| 338 BrowserContext* browser_context = | 337 BrowserContext* browser_context = |
| 339 manager->delegate_->GetControllerForRenderManager().GetBrowserContext(); | 338 manager->delegate_->GetControllerForRenderManager().GetBrowserContext(); |
| 340 const GURL& current_effective_url = current_entry ? | 339 const GURL& current_effective_url = current_entry ? |
| 341 SiteInstanceImpl::GetEffectiveURL(browser_context, | 340 SiteInstanceImpl::GetEffectiveURL(browser_context, |
| (...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1692 pending_rfh->GetSiteInstance()->increment_active_frame_count(); | 1691 pending_rfh->GetSiteInstance()->increment_active_frame_count(); |
| 1693 | 1692 |
| 1694 contents()->GetMainFrame()->OnMessageReceived( | 1693 contents()->GetMainFrame()->OnMessageReceived( |
| 1695 FrameHostMsg_BeforeUnload_ACK(0, false, now, now)); | 1694 FrameHostMsg_BeforeUnload_ACK(0, false, now, now)); |
| 1696 EXPECT_FALSE(contents()->cross_navigation_pending()); | 1695 EXPECT_FALSE(contents()->cross_navigation_pending()); |
| 1697 EXPECT_FALSE(rfh_deleted_observer.deleted()); | 1696 EXPECT_FALSE(rfh_deleted_observer.deleted()); |
| 1698 } | 1697 } |
| 1699 } | 1698 } |
| 1700 | 1699 |
| 1701 } // namespace content | 1700 } // namespace content |
| OLD | NEW |