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

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

Issue 208243019: Move SwapOut methods to RenderFrameHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Nasko's comment 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 "content/browser/frame_host/render_frame_host_impl.h" 5 #include "content/browser/frame_host/render_frame_host_impl.h"
6 6
7 #include "base/containers/hash_tables.h" 7 #include "base/containers/hash_tables.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/metrics/user_metrics_action.h" 9 #include "base/metrics/user_metrics_action.h"
10 #include "content/browser/child_process_security_policy_impl.h" 10 #include "content/browser/child_process_security_policy_impl.h"
11 #include "content/browser/frame_host/cross_process_frame_connector.h" 11 #include "content/browser/frame_host/cross_process_frame_connector.h"
12 #include "content/browser/frame_host/cross_site_transferring_request.h" 12 #include "content/browser/frame_host/cross_site_transferring_request.h"
13 #include "content/browser/frame_host/frame_tree.h" 13 #include "content/browser/frame_host/frame_tree.h"
14 #include "content/browser/frame_host/frame_tree_node.h" 14 #include "content/browser/frame_host/frame_tree_node.h"
15 #include "content/browser/frame_host/navigator.h" 15 #include "content/browser/frame_host/navigator.h"
16 #include "content/browser/frame_host/render_frame_host_delegate.h" 16 #include "content/browser/frame_host/render_frame_host_delegate.h"
17 #include "content/browser/renderer_host/input/input_router.h" 17 #include "content/browser/renderer_host/input/input_router.h"
18 #include "content/browser/renderer_host/input/timeout_monitor.h"
18 #include "content/browser/renderer_host/render_view_host_impl.h" 19 #include "content/browser/renderer_host/render_view_host_impl.h"
19 #include "content/common/frame_messages.h" 20 #include "content/common/frame_messages.h"
20 #include "content/common/input_messages.h" 21 #include "content/common/input_messages.h"
21 #include "content/common/inter_process_time_ticks_converter.h" 22 #include "content/common/inter_process_time_ticks_converter.h"
22 #include "content/common/swapped_out_messages.h" 23 #include "content/common/swapped_out_messages.h"
23 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
24 #include "content/public/browser/content_browser_client.h" 25 #include "content/public/browser/content_browser_client.h"
25 #include "content/public/browser/render_process_host.h" 26 #include "content/public/browser/render_process_host.h"
26 #include "content/public/browser/render_widget_host_view.h" 27 #include "content/public/browser/render_widget_host_view.h"
27 #include "content/public/browser/user_metrics.h" 28 #include "content/public/browser/user_metrics.h"
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 const Referrer& referrer, 490 const Referrer& referrer,
490 PageTransition page_transition, 491 PageTransition page_transition,
491 bool should_replace_current_entry) { 492 bool should_replace_current_entry) {
492 frame_tree_node_->render_manager()->OnCrossSiteResponse( 493 frame_tree_node_->render_manager()->OnCrossSiteResponse(
493 this, global_request_id, cross_site_transferring_request.Pass(), 494 this, global_request_id, cross_site_transferring_request.Pass(),
494 transfer_url_chain, referrer, page_transition, 495 transfer_url_chain, referrer, page_transition,
495 should_replace_current_entry); 496 should_replace_current_entry);
496 } 497 }
497 498
498 void RenderFrameHostImpl::SwapOut() { 499 void RenderFrameHostImpl::SwapOut() {
499 if (render_view_host_->IsRenderViewLive()) { 500 // TODO(creis): Move swapped out state to RFH. Until then, only update it
501 // when swapping out the main frame.
502 if (!GetParent()) {
503 // If this RenderViewHost is not in the default state, it must have already
504 // gone through this, therefore just return.
505 if (render_view_host_->rvh_state_ != RenderViewHostImpl::STATE_DEFAULT)
506 return;
507
508 render_view_host_->SetState(
509 RenderViewHostImpl::STATE_WAITING_FOR_UNLOAD_ACK);
510 render_view_host_->unload_event_monitor_timeout_->Start(
511 base::TimeDelta::FromMilliseconds(
512 RenderViewHostImpl::kUnloadTimeoutMS));
513 }
514
515 if (render_view_host_->IsRenderViewLive())
500 Send(new FrameMsg_SwapOut(routing_id_)); 516 Send(new FrameMsg_SwapOut(routing_id_));
501 } else { 517
502 // Our RenderViewHost doesn't have a live renderer, so just skip the unload 518 if (!GetParent())
503 // event. 519 delegate_->SwappedOut(this);
504 OnSwappedOut(true); 520
505 } 521 // Allow the navigation to proceed.
522 frame_tree_node_->render_manager()->SwappedOut(this);
506 } 523 }
507 524
508 void RenderFrameHostImpl::OnDidStartLoading() { 525 void RenderFrameHostImpl::OnDidStartLoading() {
509 delegate_->DidStartLoading(this); 526 delegate_->DidStartLoading(this);
510 } 527 }
511 528
512 void RenderFrameHostImpl::OnDidStopLoading() { 529 void RenderFrameHostImpl::OnDidStopLoading() {
513 delegate_->DidStopLoading(this); 530 delegate_->DidStopLoading(this);
514 } 531 }
515 532
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 // If canceled, notify the delegate to cancel its pending navigation entry. 577 // If canceled, notify the delegate to cancel its pending navigation entry.
561 if (!proceed) 578 if (!proceed)
562 render_view_host_->GetDelegate()->DidCancelLoading(); 579 render_view_host_->GetDelegate()->DidCancelLoading();
563 } 580 }
564 581
565 void RenderFrameHostImpl::OnSwapOutACK() { 582 void RenderFrameHostImpl::OnSwapOutACK() {
566 OnSwappedOut(false); 583 OnSwappedOut(false);
567 } 584 }
568 585
569 void RenderFrameHostImpl::OnSwappedOut(bool timed_out) { 586 void RenderFrameHostImpl::OnSwappedOut(bool timed_out) {
570 frame_tree_node_->render_manager()->SwappedOutFrame(this); 587 // For now, we only need to update the RVH state machine for top-level swaps.
588 // Subframe swaps (in --site-per-process) can just continue via RFHM.
589 if (!GetParent())
590 render_view_host_->OnSwappedOut(timed_out);
591 else
592 frame_tree_node_->render_manager()->SwappedOut(this);
571 } 593 }
572 594
573 void RenderFrameHostImpl::OnContextMenu(const ContextMenuParams& params) { 595 void RenderFrameHostImpl::OnContextMenu(const ContextMenuParams& params) {
574 // Validate the URLs in |params|. If the renderer can't request the URLs 596 // Validate the URLs in |params|. If the renderer can't request the URLs
575 // directly, don't show them in the context menu. 597 // directly, don't show them in the context menu.
576 ContextMenuParams validated_params(params); 598 ContextMenuParams validated_params(params);
577 RenderProcessHost* process = GetProcess(); 599 RenderProcessHost* process = GetProcess();
578 600
579 // We don't validate |unfiltered_link_url| so that this field can be used 601 // We don't validate |unfiltered_link_url| so that this field can be used
580 // when users want to copy the original link URL. 602 // when users want to copy the original link URL.
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 700 params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
679 Navigate(params); 701 Navigate(params);
680 } 702 }
681 703
682 void RenderFrameHostImpl::SelectRange(const gfx::Point& start, 704 void RenderFrameHostImpl::SelectRange(const gfx::Point& start,
683 const gfx::Point& end) { 705 const gfx::Point& end) {
684 Send(new InputMsg_SelectRange(routing_id_, start, end)); 706 Send(new InputMsg_SelectRange(routing_id_, start, end));
685 } 707 }
686 708
687 } // namespace content 709 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.h ('k') | content/browser/frame_host/render_frame_host_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698