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

Side by Side Diff: content/browser/frame_host/render_frame_host_manager_unittest.cc

Issue 208243019: Move SwapOut methods to RenderFrameHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 9 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 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/strings/utf_string_conversions.h" 5 #include "base/strings/utf_string_conversions.h"
6 #include "content/browser/frame_host/cross_site_transferring_request.h" 6 #include "content/browser/frame_host/cross_site_transferring_request.h"
7 #include "content/browser/frame_host/navigation_controller_impl.h" 7 #include "content/browser/frame_host/navigation_controller_impl.h"
8 #include "content/browser/frame_host/navigation_entry_impl.h" 8 #include "content/browser/frame_host/navigation_entry_impl.h"
9 #include "content/browser/frame_host/navigator.h" 9 #include "content/browser/frame_host/navigator.h"
10 #include "content/browser/frame_host/render_frame_host_manager.h" 10 #include "content/browser/frame_host/render_frame_host_manager.h"
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 EXPECT_TRUE(test_process_host->sink().GetUniqueMessageMatching( 768 EXPECT_TRUE(test_process_host->sink().GetUniqueMessageMatching(
769 FrameMsg_BeforeUnload::ID)); 769 FrameMsg_BeforeUnload::ID));
770 test_host->SendBeforeUnloadACK(true); 770 test_host->SendBeforeUnloadACK(true);
771 771
772 // CrossSiteResourceHandler::StartCrossSiteTransition triggers a 772 // CrossSiteResourceHandler::StartCrossSiteTransition triggers a
773 // call of RenderFrameHostManager::SwapOutOldPage before 773 // call of RenderFrameHostManager::SwapOutOldPage before
774 // RenderFrameHostManager::DidNavigateFrame is called. 774 // RenderFrameHostManager::DidNavigateFrame is called.
775 // The RVH is swapped out after receiving the unload ack. 775 // The RVH is swapped out after receiving the unload ack.
776 manager->SwapOutOldPage(); 776 manager->SwapOutOldPage();
777 EXPECT_TRUE(test_process_host->sink().GetUniqueMessageMatching( 777 EXPECT_TRUE(test_process_host->sink().GetUniqueMessageMatching(
778 ViewMsg_SwapOut::ID)); 778 FrameMsg_SwapOut::ID));
779 test_host->OnSwappedOut(false); 779 test_host->OnSwappedOut(false);
780 780
781 EXPECT_EQ(host, manager->current_frame_host()); 781 EXPECT_EQ(host, manager->current_frame_host());
782 EXPECT_FALSE(manager->current_frame_host()->is_swapped_out()); 782 EXPECT_FALSE(manager->current_frame_host()->is_swapped_out());
783 EXPECT_EQ(host2, manager->pending_frame_host()); 783 EXPECT_EQ(host2, manager->pending_frame_host());
784 // There should be still no navigation messages being sent. 784 // There should be still no navigation messages being sent.
785 EXPECT_FALSE(test_process_host2->sink().GetUniqueMessageMatching( 785 EXPECT_FALSE(test_process_host2->sink().GetUniqueMessageMatching(
786 FrameMsg_Navigate::ID)); 786 FrameMsg_Navigate::ID));
787 787
788 // 3) Cross-site navigate to next site before 2) has committed. -------------- 788 // 3) Cross-site navigate to next site before 2) has committed. --------------
(...skipping 20 matching lines...) Expand all
809 // Simulate a response to the second beforeunload request. 809 // Simulate a response to the second beforeunload request.
810 EXPECT_TRUE(test_process_host->sink().GetUniqueMessageMatching( 810 EXPECT_TRUE(test_process_host->sink().GetUniqueMessageMatching(
811 FrameMsg_BeforeUnload::ID)); 811 FrameMsg_BeforeUnload::ID));
812 test_host->SendBeforeUnloadACK(true); 812 test_host->SendBeforeUnloadACK(true);
813 813
814 // CrossSiteResourceHandler::StartCrossSiteTransition triggers a 814 // CrossSiteResourceHandler::StartCrossSiteTransition triggers a
815 // call of RenderFrameHostManager::SwapOutOldPage before 815 // call of RenderFrameHostManager::SwapOutOldPage before
816 // RenderFrameHostManager::DidNavigateFrame is called. 816 // RenderFrameHostManager::DidNavigateFrame is called.
817 manager->SwapOutOldPage(); 817 manager->SwapOutOldPage();
818 EXPECT_TRUE(test_process_host->sink().GetUniqueMessageMatching( 818 EXPECT_TRUE(test_process_host->sink().GetUniqueMessageMatching(
819 ViewMsg_SwapOut::ID)); 819 FrameMsg_SwapOut::ID));
820 test_host->OnSwappedOut(false); 820 test_host->OnSwappedOut(false);
821 821
822 // Commit. 822 // Commit.
823 manager->DidNavigateFrame(host3); 823 manager->DidNavigateFrame(host3);
824 EXPECT_TRUE(host3 == manager->current_frame_host()); 824 EXPECT_TRUE(host3 == manager->current_frame_host());
825 ASSERT_TRUE(host3); 825 ASSERT_TRUE(host3);
826 EXPECT_TRUE(static_cast<SiteInstanceImpl*>(host3->GetSiteInstance())-> 826 EXPECT_TRUE(static_cast<SiteInstanceImpl*>(host3->GetSiteInstance())->
827 HasSite()); 827 HasSite());
828 // Check the pending RenderFrameHost has been committed. 828 // Check the pending RenderFrameHost has been committed.
829 EXPECT_FALSE(manager->pending_frame_host()); 829 EXPECT_FALSE(manager->pending_frame_host());
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 static_cast<SiteInstanceImpl*>(rvh2->GetSiteInstance())-> 1022 static_cast<SiteInstanceImpl*>(rvh2->GetSiteInstance())->
1023 increment_active_view_count(); 1023 increment_active_view_count();
1024 1024
1025 // Now go back, but suppose the SwapOut_ACK isn't received. This shouldn't 1025 // Now go back, but suppose the SwapOut_ACK isn't received. This shouldn't
1026 // happen, but we have seen it when going back quickly across many entries 1026 // happen, but we have seen it when going back quickly across many entries
1027 // (http://crbug.com/93427). 1027 // (http://crbug.com/93427).
1028 contents()->GetController().GoBack(); 1028 contents()->GetController().GoBack();
1029 EXPECT_TRUE(rvh2->is_waiting_for_beforeunload_ack()); 1029 EXPECT_TRUE(rvh2->is_waiting_for_beforeunload_ack());
1030 contents()->ProceedWithCrossSiteNavigation(); 1030 contents()->ProceedWithCrossSiteNavigation();
1031 EXPECT_FALSE(rvh2->is_waiting_for_beforeunload_ack()); 1031 EXPECT_FALSE(rvh2->is_waiting_for_beforeunload_ack());
1032 rvh2->SwapOut(); 1032 static_cast<RenderFrameHostImpl*>(rvh2->GetMainFrame())->SwapOut();
1033 EXPECT_TRUE(rvh2->IsWaitingForUnloadACK()); 1033 EXPECT_TRUE(rvh2->IsWaitingForUnloadACK());
1034 1034
1035 // The back navigation commits. 1035 // The back navigation commits.
1036 const NavigationEntry* entry1 = contents()->GetController().GetPendingEntry(); 1036 const NavigationEntry* entry1 = contents()->GetController().GetPendingEntry();
1037 rvh1->SendNavigate(entry1->GetPageID(), entry1->GetURL()); 1037 rvh1->SendNavigate(entry1->GetPageID(), entry1->GetURL());
1038 EXPECT_EQ(RenderViewHostImpl::STATE_PENDING_SWAP_OUT, rvh2->rvh_state()); 1038 EXPECT_EQ(RenderViewHostImpl::STATE_PENDING_SWAP_OUT, rvh2->rvh_state());
1039 1039
1040 // We should be able to navigate forward. 1040 // We should be able to navigate forward.
1041 contents()->GetController().GoForward(); 1041 contents()->GetController().GoForward();
1042 contents()->ProceedWithCrossSiteNavigation(); 1042 contents()->ProceedWithCrossSiteNavigation();
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
1573 1573
1574 // Simulate the swap out ack. 1574 // Simulate the swap out ack.
1575 rvh1->OnSwappedOut(false); 1575 rvh1->OnSwappedOut(false);
1576 1576
1577 // rvh1 should be swapped out. 1577 // rvh1 should be swapped out.
1578 EXPECT_FALSE(destruction_observer.rvh_deleted()); 1578 EXPECT_FALSE(destruction_observer.rvh_deleted());
1579 EXPECT_TRUE(rvh1->IsSwappedOut()); 1579 EXPECT_TRUE(rvh1->IsSwappedOut());
1580 } 1580 }
1581 1581
1582 } // namespace content 1582 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698