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

Side by Side Diff: content/renderer/render_view_impl.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 (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 "content/renderer/render_view_impl.h" 5 #include "content/renderer/render_view_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 OnDragSourceSystemDragEnded) 1103 OnDragSourceSystemDragEnded)
1104 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings) 1104 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings)
1105 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) 1105 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus)
1106 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) 1106 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck)
1107 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) 1107 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences)
1108 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, 1108 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse,
1109 OnEnumerateDirectoryResponse) 1109 OnEnumerateDirectoryResponse)
1110 IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) 1110 IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse)
1111 IPC_MESSAGE_HANDLER(ViewMsg_SuppressDialogsUntilSwapOut, 1111 IPC_MESSAGE_HANDLER(ViewMsg_SuppressDialogsUntilSwapOut,
1112 OnSuppressDialogsUntilSwapOut) 1112 OnSuppressDialogsUntilSwapOut)
1113 IPC_MESSAGE_HANDLER(ViewMsg_SwapOut, OnSwapOut)
1114 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) 1113 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage)
1115 IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged) 1114 IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged)
1116 IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) 1115 IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted)
1117 IPC_MESSAGE_HANDLER(ViewMsg_ClearFocusedElement, OnClearFocusedElement) 1116 IPC_MESSAGE_HANDLER(ViewMsg_ClearFocusedElement, OnClearFocusedElement)
1118 IPC_MESSAGE_HANDLER(ViewMsg_SetBackground, OnSetBackground) 1117 IPC_MESSAGE_HANDLER(ViewMsg_SetBackground, OnSetBackground)
1119 IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode, 1118 IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode,
1120 OnEnablePreferredSizeChangedMode) 1119 OnEnablePreferredSizeChangedMode)
1121 IPC_MESSAGE_HANDLER(ViewMsg_EnableAutoResize, OnEnableAutoResize) 1120 IPC_MESSAGE_HANDLER(ViewMsg_EnableAutoResize, OnEnableAutoResize)
1122 IPC_MESSAGE_HANDLER(ViewMsg_DisableAutoResize, OnDisableAutoResize) 1121 IPC_MESSAGE_HANDLER(ViewMsg_DisableAutoResize, OnDisableAutoResize)
1123 IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows, 1122 IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows,
(...skipping 2662 matching lines...) Expand 10 before | Expand all | Expand 10 after
3786 WebPageSerializer::serialize(webview()->mainFrame(), true, this, weburl_links, 3785 WebPageSerializer::serialize(webview()->mainFrame(), true, this, weburl_links,
3787 webstring_paths, 3786 webstring_paths,
3788 local_directory_name.AsUTF16Unsafe()); 3787 local_directory_name.AsUTF16Unsafe());
3789 } 3788 }
3790 3789
3791 void RenderViewImpl::OnSuppressDialogsUntilSwapOut() { 3790 void RenderViewImpl::OnSuppressDialogsUntilSwapOut() {
3792 // Don't show any more dialogs until we finish OnSwapOut. 3791 // Don't show any more dialogs until we finish OnSwapOut.
3793 suppress_dialogs_until_swap_out_ = true; 3792 suppress_dialogs_until_swap_out_ = true;
3794 } 3793 }
3795 3794
3796 void RenderViewImpl::OnSwapOut() {
3797 // Only run unload if we're not swapped out yet, but send the ack either way.
3798 if (!is_swapped_out_) {
3799 // Swap this RenderView out so the tab can navigate to a page rendered by a
3800 // different process. This involves running the unload handler and clearing
3801 // the page. Once WasSwappedOut is called, we also allow this process to
3802 // exit if there are no other active RenderViews in it.
3803
3804 // Send an UpdateState message before we get swapped out.
3805 SyncNavigationState();
3806
3807 // Synchronously run the unload handler before sending the ACK.
3808 webview()->dispatchUnloadEvent();
3809
3810 // Swap out and stop sending any IPC messages that are not ACKs.
3811 SetSwappedOut(true);
3812
3813 // Now that we're swapped out and filtering IPC messages, stop loading to
3814 // ensure that no other in-progress navigation continues. We do this here
3815 // to avoid sending a DidStopLoading message to the browser process.
3816 OnStop();
3817
3818 // Replace the page with a blank dummy URL. The unload handler will not be
3819 // run a second time, thanks to a check in FrameLoader::stopLoading.
3820 // TODO(creis): Need to add a better way to do this that avoids running the
3821 // beforeunload handler. For now, we just run it a second time silently.
3822 NavigateToSwappedOutURL(webview()->mainFrame());
3823
3824 // Let WebKit know that this view is hidden so it can drop resources and
3825 // stop compositing.
3826 webview()->setVisibilityState(blink::WebPageVisibilityStateHidden, false);
3827 }
3828
3829 // It is now safe to show modal dialogs again.
3830 suppress_dialogs_until_swap_out_ = false;
3831
3832 Send(new ViewHostMsg_SwapOut_ACK(routing_id_));
3833 }
3834
3835 void RenderViewImpl::NavigateToSwappedOutURL(blink::WebFrame* frame) { 3795 void RenderViewImpl::NavigateToSwappedOutURL(blink::WebFrame* frame) {
3836 // We use loadRequest instead of loadHTMLString because the former commits 3796 // We use loadRequest instead of loadHTMLString because the former commits
3837 // synchronously. Otherwise a new navigation can interrupt the navigation 3797 // synchronously. Otherwise a new navigation can interrupt the navigation
3838 // to kSwappedOutURL. If that happens to be to the page we had been 3798 // to kSwappedOutURL. If that happens to be to the page we had been
3839 // showing, then WebKit will never send a commit and we'll be left spinning. 3799 // showing, then WebKit will never send a commit and we'll be left spinning.
3840 // TODO(creis): Until we move this to RenderFrame, we may call this from a 3800 // TODO(creis): Until we move this to RenderFrame, we may call this from a
3841 // swapped out RenderFrame while our own is_swapped_out_ is false. 3801 // swapped out RenderFrame while our own is_swapped_out_ is false.
3842 RenderFrameImpl* rf = RenderFrameImpl::FromWebFrame(frame); 3802 RenderFrameImpl* rf = RenderFrameImpl::FromWebFrame(frame);
3843 CHECK(is_swapped_out_ || rf->is_swapped_out()); 3803 CHECK(is_swapped_out_ || rf->is_swapped_out());
3844 GURL swappedOutURL(kSwappedOutURL); 3804 GURL swappedOutURL(kSwappedOutURL);
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after
4948 std::vector<gfx::Size> sizes(icon_urls[i].sizes().size()); 4908 std::vector<gfx::Size> sizes(icon_urls[i].sizes().size());
4949 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); 4909 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes);
4950 if (!url.isEmpty()) 4910 if (!url.isEmpty())
4951 urls.push_back( 4911 urls.push_back(
4952 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); 4912 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes));
4953 } 4913 }
4954 SendUpdateFaviconURL(urls); 4914 SendUpdateFaviconURL(urls);
4955 } 4915 }
4956 4916
4957 } // namespace content 4917 } // namespace content
OLDNEW
« content/renderer/render_frame_impl.cc ('K') | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698