OLD | NEW |
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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 // Ensure the RenderViewImpl sends an ACK to a SwapOut request, even if it is | 539 // Ensure the RenderViewImpl sends an ACK to a SwapOut request, even if it is |
540 // already swapped out. http://crbug.com/93427. | 540 // already swapped out. http://crbug.com/93427. |
541 TEST_F(RenderViewImplTest, SendSwapOutACK) { | 541 TEST_F(RenderViewImplTest, SendSwapOutACK) { |
542 LoadHTML("<div>Page A</div>"); | 542 LoadHTML("<div>Page A</div>"); |
543 int initial_page_id = view_page_id(); | 543 int initial_page_id = view_page_id(); |
544 | 544 |
545 // Increment the ref count so that we don't exit when swapping out. | 545 // Increment the ref count so that we don't exit when swapping out. |
546 RenderProcess::current()->AddRefProcess(); | 546 RenderProcess::current()->AddRefProcess(); |
547 | 547 |
548 // Respond to a swap out request. | 548 // Respond to a swap out request. |
549 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId); | 549 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId, |
| 550 content::FrameReplicationState()); |
550 | 551 |
551 // Ensure the swap out commits synchronously. | 552 // Ensure the swap out commits synchronously. |
552 EXPECT_NE(initial_page_id, view_page_id()); | 553 EXPECT_NE(initial_page_id, view_page_id()); |
553 | 554 |
554 // Check for a valid OnSwapOutACK. | 555 // Check for a valid OnSwapOutACK. |
555 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( | 556 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( |
556 FrameHostMsg_SwapOut_ACK::ID); | 557 FrameHostMsg_SwapOut_ACK::ID); |
557 ASSERT_TRUE(msg); | 558 ASSERT_TRUE(msg); |
558 | 559 |
559 // It is possible to get another swap out request. Ensure that we send | 560 // It is possible to get another swap out request. Ensure that we send |
560 // an ACK, even if we don't have to do anything else. | 561 // an ACK, even if we don't have to do anything else. |
561 render_thread_->sink().ClearMessages(); | 562 render_thread_->sink().ClearMessages(); |
562 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId); | 563 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId, |
| 564 content::FrameReplicationState()); |
563 const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching( | 565 const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching( |
564 FrameHostMsg_SwapOut_ACK::ID); | 566 FrameHostMsg_SwapOut_ACK::ID); |
565 ASSERT_TRUE(msg2); | 567 ASSERT_TRUE(msg2); |
566 | 568 |
567 // If we navigate back to this RenderView, ensure we don't send a state | 569 // If we navigate back to this RenderView, ensure we don't send a state |
568 // update for the swapped out URL. (http://crbug.com/72235) | 570 // update for the swapped out URL. (http://crbug.com/72235) |
569 FrameMsg_Navigate_Params nav_params; | 571 FrameMsg_Navigate_Params nav_params; |
570 nav_params.common_params.url = GURL("data:text/html,<div>Page B</div>"); | 572 nav_params.common_params.url = GURL("data:text/html,<div>Page B</div>"); |
571 nav_params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 573 nav_params.common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
572 nav_params.common_params.transition = ui::PAGE_TRANSITION_TYPED; | 574 nav_params.common_params.transition = ui::PAGE_TRANSITION_TYPED; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 params_A.current_history_list_offset = 1; | 614 params_A.current_history_list_offset = 1; |
613 params_A.pending_history_list_offset = 0; | 615 params_A.pending_history_list_offset = 0; |
614 params_A.page_id = 1; | 616 params_A.page_id = 1; |
615 params_A.commit_params.page_state = state_A; | 617 params_A.commit_params.page_state = state_A; |
616 params_A.commit_params.browser_navigation_start = | 618 params_A.commit_params.browser_navigation_start = |
617 base::TimeTicks::FromInternalValue(1); | 619 base::TimeTicks::FromInternalValue(1); |
618 frame()->OnNavigate(params_A); | 620 frame()->OnNavigate(params_A); |
619 ProcessPendingMessages(); | 621 ProcessPendingMessages(); |
620 | 622 |
621 // Respond to a swap out request. | 623 // Respond to a swap out request. |
622 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId); | 624 view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId, |
| 625 content::FrameReplicationState()); |
623 | 626 |
624 // Check for a OnSwapOutACK. | 627 // Check for a OnSwapOutACK. |
625 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( | 628 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( |
626 FrameHostMsg_SwapOut_ACK::ID); | 629 FrameHostMsg_SwapOut_ACK::ID); |
627 ASSERT_TRUE(msg); | 630 ASSERT_TRUE(msg); |
628 render_thread_->sink().ClearMessages(); | 631 render_thread_->sink().ClearMessages(); |
629 | 632 |
630 // It is possible to get a reload request at this point, containing the | 633 // It is possible to get a reload request at this point, containing the |
631 // params.page_state of the initial page (e.g., if the new page fails the | 634 // params.page_state of the initial page (e.g., if the new page fails the |
632 // provisional load in the renderer process, after we unload the old page). | 635 // provisional load in the renderer process, after we unload the old page). |
(...skipping 1855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2488 ProcessPendingMessages(); | 2491 ProcessPendingMessages(); |
2489 base::Time after_navigation = | 2492 base::Time after_navigation = |
2490 base::Time::Now() + base::TimeDelta::FromDays(1); | 2493 base::Time::Now() + base::TimeDelta::FromDays(1); |
2491 | 2494 |
2492 base::Time late_nav_reported_start = | 2495 base::Time late_nav_reported_start = |
2493 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); | 2496 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); |
2494 EXPECT_LE(late_nav_reported_start, after_navigation); | 2497 EXPECT_LE(late_nav_reported_start, after_navigation); |
2495 } | 2498 } |
2496 | 2499 |
2497 } // namespace content | 2500 } // namespace content |
OLD | NEW |