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

Side by Side Diff: content/renderer/render_frame_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, 8 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/renderer/render_frame_impl.h ('k') | content/renderer/render_view_browsertest.cc » ('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 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/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); 783 base::TimeTicks before_unload_start_time = base::TimeTicks::Now();
784 bool proceed = render_view_->webview()->dispatchBeforeUnloadEvent(); 784 bool proceed = render_view_->webview()->dispatchBeforeUnloadEvent();
785 base::TimeTicks before_unload_end_time = base::TimeTicks::Now(); 785 base::TimeTicks before_unload_end_time = base::TimeTicks::Now();
786 Send(new FrameHostMsg_BeforeUnload_ACK(routing_id_, proceed, 786 Send(new FrameHostMsg_BeforeUnload_ACK(routing_id_, proceed,
787 before_unload_start_time, 787 before_unload_start_time,
788 before_unload_end_time)); 788 before_unload_end_time));
789 } 789 }
790 790
791 void RenderFrameImpl::OnSwapOut() { 791 void RenderFrameImpl::OnSwapOut() {
792 // Only run unload if we're not swapped out yet, but send the ack either way. 792 // Only run unload if we're not swapped out yet, but send the ack either way.
793 if (!is_swapped_out_) { 793 if (!is_swapped_out_ || !render_view_->is_swapped_out_) {
794 // Swap this RenderView out so the tab can navigate to a page rendered by a 794 // Swap this RenderFrame out so the frame can navigate to a page rendered by
795 // different process. This involves running the unload handler and clearing 795 // a different process. This involves running the unload handler and
796 // the page. Once WasSwappedOut is called, we also allow this process to 796 // clearing the page. Once WasSwappedOut is called, we also allow this
797 // exit if there are no other active RenderViews in it. 797 // process to exit if there are no other active RenderFrames in it.
798 798
799 // Send an UpdateState message before we get swapped out. 799 // Send an UpdateState message before we get swapped out.
800 render_view_->SyncNavigationState(); 800 render_view_->SyncNavigationState();
801 801
802 // Synchronously run the unload handler before sending the ACK. 802 // Synchronously run the unload handler before sending the ACK.
803 // TODO(creis): Add a WebFrame::dispatchUnloadEvent and call it here. 803 // TODO(creis): Move WebView::dispatchUnloadEvent to WebFrame and call it
804 // here to support unload on subframes as well.
805 if (!frame_->parent())
806 render_view_->webview()->dispatchUnloadEvent();
804 807
805 // Swap out and stop sending any IPC messages that are not ACKs. 808 // Swap out and stop sending any IPC messages that are not ACKs.
809 if (!frame_->parent())
810 render_view_->SetSwappedOut(true);
806 is_swapped_out_ = true; 811 is_swapped_out_ = true;
807 812
808 // Now that we're swapped out and filtering IPC messages, stop loading to 813 // Now that we're swapped out and filtering IPC messages, stop loading to
809 // ensure that no other in-progress navigation continues. We do this here 814 // ensure that no other in-progress navigation continues. We do this here
810 // to avoid sending a DidStopLoading message to the browser process. 815 // to avoid sending a DidStopLoading message to the browser process.
811 // TODO(creis): Should we be stopping all frames here and using 816 // TODO(creis): Should we be stopping all frames here and using
812 // StopAltErrorPageFetcher with RenderView::OnStop, or just stopping this 817 // StopAltErrorPageFetcher with RenderView::OnStop, or just stopping this
813 // frame? 818 // frame?
814 frame_->stopLoading(); 819 if (!frame_->parent())
820 render_view_->OnStop();
821 else
822 frame_->stopLoading();
815 823
816 frame_->setIsRemote(true); 824 // Let subframes know that the frame is now rendered remotely, for the
825 // purposes of compositing and input events.
826 if (frame_->parent())
827 frame_->setIsRemote(true);
817 828
818 // Replace the page with a blank dummy URL. The unload handler will not be 829 // Replace the page with a blank dummy URL. The unload handler will not be
819 // run a second time, thanks to a check in FrameLoader::stopLoading. 830 // run a second time, thanks to a check in FrameLoader::stopLoading.
820 // TODO(creis): Need to add a better way to do this that avoids running the 831 // TODO(creis): Need to add a better way to do this that avoids running the
821 // beforeunload handler. For now, we just run it a second time silently. 832 // beforeunload handler. For now, we just run it a second time silently.
822 render_view_->NavigateToSwappedOutURL(frame_); 833 render_view_->NavigateToSwappedOutURL(frame_);
823 834
824 render_view_->RegisterSwappedOutChildFrame(this); 835 if (frame_->parent())
836 render_view_->RegisterSwappedOutChildFrame(this);
837
838 // Let WebKit know that this view is hidden so it can drop resources and
839 // stop compositing.
840 // TODO(creis): Support this for subframes as well.
841 if (!frame_->parent()) {
842 render_view_->webview()->setVisibilityState(
843 blink::WebPageVisibilityStateHidden, false);
844 }
825 } 845 }
826 846
847 // It is now safe to show modal dialogs again.
848 // TODO(creis): Deal with modal dialogs from subframes.
849 if (!frame_->parent())
850 render_view_->suppress_dialogs_until_swap_out_ = false;
851
827 Send(new FrameHostMsg_SwapOut_ACK(routing_id_)); 852 Send(new FrameHostMsg_SwapOut_ACK(routing_id_));
828 } 853 }
829 854
830 void RenderFrameImpl::OnBuffersSwapped( 855 void RenderFrameImpl::OnBuffersSwapped(
831 const FrameMsg_BuffersSwapped_Params& params) { 856 const FrameMsg_BuffersSwapped_Params& params) {
832 if (!compositing_helper_.get()) { 857 if (!compositing_helper_.get()) {
833 compositing_helper_ = 858 compositing_helper_ =
834 ChildFrameCompositingHelper::CreateCompositingHelperForRenderFrame( 859 ChildFrameCompositingHelper::CreateCompositingHelperForRenderFrame(
835 frame_, this, routing_id_); 860 frame_, this, routing_id_);
836 compositing_helper_->EnableCompositing(true); 861 compositing_helper_->EnableCompositing(true);
(...skipping 2082 matching lines...) Expand 10 before | Expand all | Expand 10 after
2919 selection_text_offset_ = offset; 2944 selection_text_offset_ = offset;
2920 selection_range_ = range; 2945 selection_range_ = range;
2921 // This IPC is dispatched by RenderWidetHost, so use its routing ID. 2946 // This IPC is dispatched by RenderWidetHost, so use its routing ID.
2922 Send(new ViewHostMsg_SelectionChanged( 2947 Send(new ViewHostMsg_SelectionChanged(
2923 GetRenderWidget()->routing_id(), text, offset, range)); 2948 GetRenderWidget()->routing_id(), text, offset, range));
2924 } 2949 }
2925 GetRenderWidget()->UpdateSelectionBounds(); 2950 GetRenderWidget()->UpdateSelectionBounds();
2926 } 2951 }
2927 2952
2928 } // namespace content 2953 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/renderer/render_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698