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

Side by Side Diff: content/renderer/render_view_browsertest.cc

Issue 15682009: Eliminate SwapOut message parameters, keeping state in RVHM instead. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to get Android build fix Created 7 years, 6 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
« no previous file with comments | « content/public/test/mock_render_process_host.cc ('k') | content/renderer/render_view_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/basictypes.h" 5 #include "base/basictypes.h"
6 6
7 #include "base/shared_memory.h" 7 #include "base/shared_memory.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/common/view_messages.h" 10 #include "content/common/view_messages.h"
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 new_view->Release(); 418 new_view->Release();
419 } 419 }
420 420
421 // Ensure the RenderViewImpl sends an ACK to a SwapOut request, even if it is 421 // Ensure the RenderViewImpl sends an ACK to a SwapOut request, even if it is
422 // already swapped out. http://crbug.com/93427. 422 // already swapped out. http://crbug.com/93427.
423 TEST_F(RenderViewImplTest, SendSwapOutACK) { 423 TEST_F(RenderViewImplTest, SendSwapOutACK) {
424 LoadHTML("<div>Page A</div>"); 424 LoadHTML("<div>Page A</div>");
425 int initial_page_id = view()->GetPageId(); 425 int initial_page_id = view()->GetPageId();
426 426
427 // Respond to a swap out request. 427 // Respond to a swap out request.
428 ViewMsg_SwapOut_Params params; 428 view()->OnSwapOut();
429 params.closing_process_id = 10;
430 params.closing_route_id = 11;
431 params.new_render_process_host_id = 12;
432 params.new_request_id = 13;
433 view()->OnSwapOut(params);
434 429
435 // Ensure the swap out commits synchronously. 430 // Ensure the swap out commits synchronously.
436 EXPECT_NE(initial_page_id, view()->GetPageId()); 431 EXPECT_NE(initial_page_id, view()->GetPageId());
437 432
438 // Check for a valid OnSwapOutACK with echoed params. 433 // Check for a valid OnSwapOutACK.
439 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( 434 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching(
440 ViewHostMsg_SwapOut_ACK::ID); 435 ViewHostMsg_SwapOut_ACK::ID);
441 ASSERT_TRUE(msg); 436 ASSERT_TRUE(msg);
442 ViewHostMsg_SwapOut_ACK::Param reply_params;
443 ViewHostMsg_SwapOut_ACK::Read(msg, &reply_params);
444 EXPECT_EQ(params.closing_process_id, reply_params.a.closing_process_id);
445 EXPECT_EQ(params.closing_route_id, reply_params.a.closing_route_id);
446 EXPECT_EQ(params.new_render_process_host_id,
447 reply_params.a.new_render_process_host_id);
448 EXPECT_EQ(params.new_request_id, reply_params.a.new_request_id);
449 437
450 // It is possible to get another swap out request. Ensure that we send 438 // It is possible to get another swap out request. Ensure that we send
451 // an ACK, even if we don't have to do anything else. 439 // an ACK, even if we don't have to do anything else.
452 render_thread_->sink().ClearMessages(); 440 render_thread_->sink().ClearMessages();
453 view()->OnSwapOut(params); 441 view()->OnSwapOut();
454 const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching( 442 const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching(
455 ViewHostMsg_SwapOut_ACK::ID); 443 ViewHostMsg_SwapOut_ACK::ID);
456 ASSERT_TRUE(msg2); 444 ASSERT_TRUE(msg2);
457 445
458 // If we navigate back to this RenderView, ensure we don't send a state 446 // If we navigate back to this RenderView, ensure we don't send a state
459 // update for the swapped out URL. (http://crbug.com/72235) 447 // update for the swapped out URL. (http://crbug.com/72235)
460 ViewMsg_Navigate_Params nav_params; 448 ViewMsg_Navigate_Params nav_params;
461 nav_params.url = GURL("data:text/html,<div>Page B</div>"); 449 nav_params.url = GURL("data:text/html,<div>Page B</div>");
462 nav_params.navigation_type = ViewMsg_Navigate_Type::NORMAL; 450 nav_params.navigation_type = ViewMsg_Navigate_Type::NORMAL;
463 nav_params.transition = PAGE_TRANSITION_TYPED; 451 nav_params.transition = PAGE_TRANSITION_TYPED;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 params_A.transition = PAGE_TRANSITION_FORWARD_BACK; 486 params_A.transition = PAGE_TRANSITION_FORWARD_BACK;
499 params_A.current_history_list_length = 2; 487 params_A.current_history_list_length = 2;
500 params_A.current_history_list_offset = 1; 488 params_A.current_history_list_offset = 1;
501 params_A.pending_history_list_offset = 0; 489 params_A.pending_history_list_offset = 0;
502 params_A.page_id = 1; 490 params_A.page_id = 1;
503 params_A.page_state = state_A; 491 params_A.page_state = state_A;
504 view()->OnNavigate(params_A); 492 view()->OnNavigate(params_A);
505 ProcessPendingMessages(); 493 ProcessPendingMessages();
506 494
507 // Respond to a swap out request. 495 // Respond to a swap out request.
508 ViewMsg_SwapOut_Params params; 496 view()->OnSwapOut();
509 params.closing_process_id = 10;
510 params.closing_route_id = 11;
511 params.new_render_process_host_id = 12;
512 params.new_request_id = 13;
513 view()->OnSwapOut(params);
514 497
515 // Check for a OnSwapOutACK. 498 // Check for a OnSwapOutACK.
516 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( 499 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching(
517 ViewHostMsg_SwapOut_ACK::ID); 500 ViewHostMsg_SwapOut_ACK::ID);
518 ASSERT_TRUE(msg); 501 ASSERT_TRUE(msg);
519 render_thread_->sink().ClearMessages(); 502 render_thread_->sink().ClearMessages();
520 503
521 // It is possible to get a reload request at this point, containing the 504 // It is possible to get a reload request at this point, containing the
522 // params.page_state of the initial page (e.g., if the new page fails the 505 // params.page_state of the initial page (e.g., if the new page fails the
523 // provisional load in the renderer process, after we unload the old page). 506 // provisional load in the renderer process, after we unload the old page).
(...skipping 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1861 EXPECT_EQ(output, L"hello \n\nworld"); 1844 EXPECT_EQ(output, L"hello \n\nworld");
1862 } 1845 }
1863 1846
1864 // This test ensures that a RenderFrame object is created for the top level 1847 // This test ensures that a RenderFrame object is created for the top level
1865 // frame in the RenderView. 1848 // frame in the RenderView.
1866 TEST_F(RenderViewImplTest, BasicRenderFrame) { 1849 TEST_F(RenderViewImplTest, BasicRenderFrame) {
1867 EXPECT_TRUE(view()->main_render_frame_.get()); 1850 EXPECT_TRUE(view()->main_render_frame_.get());
1868 } 1851 }
1869 1852
1870 } // namespace content 1853 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/mock_render_process_host.cc ('k') | content/renderer/render_view_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698