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

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: 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_view_impl.h ('k') | no next file » | 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 "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 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 OnDragSourceSystemDragEnded) 1108 OnDragSourceSystemDragEnded)
1109 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings) 1109 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings)
1110 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) 1110 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus)
1111 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) 1111 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck)
1112 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) 1112 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences)
1113 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, 1113 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse,
1114 OnEnumerateDirectoryResponse) 1114 OnEnumerateDirectoryResponse)
1115 IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) 1115 IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse)
1116 IPC_MESSAGE_HANDLER(ViewMsg_SuppressDialogsUntilSwapOut, 1116 IPC_MESSAGE_HANDLER(ViewMsg_SuppressDialogsUntilSwapOut,
1117 OnSuppressDialogsUntilSwapOut) 1117 OnSuppressDialogsUntilSwapOut)
1118 IPC_MESSAGE_HANDLER(ViewMsg_SwapOut, OnSwapOut)
1119 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) 1118 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage)
1120 IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged) 1119 IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged)
1121 IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) 1120 IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted)
1122 IPC_MESSAGE_HANDLER(ViewMsg_ClearFocusedElement, OnClearFocusedElement) 1121 IPC_MESSAGE_HANDLER(ViewMsg_ClearFocusedElement, OnClearFocusedElement)
1123 IPC_MESSAGE_HANDLER(ViewMsg_SetBackground, OnSetBackground) 1122 IPC_MESSAGE_HANDLER(ViewMsg_SetBackground, OnSetBackground)
1124 IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode, 1123 IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode,
1125 OnEnablePreferredSizeChangedMode) 1124 OnEnablePreferredSizeChangedMode)
1126 IPC_MESSAGE_HANDLER(ViewMsg_EnableAutoResize, OnEnableAutoResize) 1125 IPC_MESSAGE_HANDLER(ViewMsg_EnableAutoResize, OnEnableAutoResize)
1127 IPC_MESSAGE_HANDLER(ViewMsg_DisableAutoResize, OnDisableAutoResize) 1126 IPC_MESSAGE_HANDLER(ViewMsg_DisableAutoResize, OnDisableAutoResize)
1128 IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows, 1127 IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows,
(...skipping 2676 matching lines...) Expand 10 before | Expand all | Expand 10 after
3805 WebPageSerializer::serialize(webview()->mainFrame(), true, this, weburl_links, 3804 WebPageSerializer::serialize(webview()->mainFrame(), true, this, weburl_links,
3806 webstring_paths, 3805 webstring_paths,
3807 local_directory_name.AsUTF16Unsafe()); 3806 local_directory_name.AsUTF16Unsafe());
3808 } 3807 }
3809 3808
3810 void RenderViewImpl::OnSuppressDialogsUntilSwapOut() { 3809 void RenderViewImpl::OnSuppressDialogsUntilSwapOut() {
3811 // Don't show any more dialogs until we finish OnSwapOut. 3810 // Don't show any more dialogs until we finish OnSwapOut.
3812 suppress_dialogs_until_swap_out_ = true; 3811 suppress_dialogs_until_swap_out_ = true;
3813 } 3812 }
3814 3813
3815 void RenderViewImpl::OnSwapOut() {
3816 // Only run unload if we're not swapped out yet, but send the ack either way.
3817 if (!is_swapped_out_) {
3818 // Swap this RenderView out so the tab can navigate to a page rendered by a
3819 // different process. This involves running the unload handler and clearing
3820 // the page. Once WasSwappedOut is called, we also allow this process to
3821 // exit if there are no other active RenderViews in it.
3822
3823 // Send an UpdateState message before we get swapped out.
3824 SyncNavigationState();
3825
3826 // Synchronously run the unload handler before sending the ACK.
3827 webview()->dispatchUnloadEvent();
3828
3829 // Swap out and stop sending any IPC messages that are not ACKs.
3830 SetSwappedOut(true);
3831
3832 // Now that we're swapped out and filtering IPC messages, stop loading to
3833 // ensure that no other in-progress navigation continues. We do this here
3834 // to avoid sending a DidStopLoading message to the browser process.
3835 OnStop();
3836
3837 // Replace the page with a blank dummy URL. The unload handler will not be
3838 // run a second time, thanks to a check in FrameLoader::stopLoading.
3839 // TODO(creis): Need to add a better way to do this that avoids running the
3840 // beforeunload handler. For now, we just run it a second time silently.
3841 NavigateToSwappedOutURL(webview()->mainFrame());
3842
3843 // Let WebKit know that this view is hidden so it can drop resources and
3844 // stop compositing.
3845 webview()->setVisibilityState(blink::WebPageVisibilityStateHidden, false);
3846 }
3847
3848 // It is now safe to show modal dialogs again.
3849 suppress_dialogs_until_swap_out_ = false;
3850
3851 Send(new ViewHostMsg_SwapOut_ACK(routing_id_));
3852 }
3853
3854 void RenderViewImpl::NavigateToSwappedOutURL(blink::WebFrame* frame) { 3814 void RenderViewImpl::NavigateToSwappedOutURL(blink::WebFrame* frame) {
3855 // We use loadRequest instead of loadHTMLString because the former commits 3815 // We use loadRequest instead of loadHTMLString because the former commits
3856 // synchronously. Otherwise a new navigation can interrupt the navigation 3816 // synchronously. Otherwise a new navigation can interrupt the navigation
3857 // to kSwappedOutURL. If that happens to be to the page we had been 3817 // to kSwappedOutURL. If that happens to be to the page we had been
3858 // showing, then WebKit will never send a commit and we'll be left spinning. 3818 // showing, then WebKit will never send a commit and we'll be left spinning.
3859 // TODO(creis): Until we move this to RenderFrame, we may call this from a 3819 // TODO(creis): Until we move this to RenderFrame, we may call this from a
3860 // swapped out RenderFrame while our own is_swapped_out_ is false. 3820 // swapped out RenderFrame while our own is_swapped_out_ is false.
3861 RenderFrameImpl* rf = RenderFrameImpl::FromWebFrame(frame); 3821 RenderFrameImpl* rf = RenderFrameImpl::FromWebFrame(frame);
3862 CHECK(is_swapped_out_ || rf->is_swapped_out()); 3822 CHECK(is_swapped_out_ || rf->is_swapped_out());
3863 GURL swappedOutURL(kSwappedOutURL); 3823 GURL swappedOutURL(kSwappedOutURL);
(...skipping 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after
4969 std::vector<gfx::Size> sizes(icon_urls[i].sizes().size()); 4929 std::vector<gfx::Size> sizes(icon_urls[i].sizes().size());
4970 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); 4930 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes);
4971 if (!url.isEmpty()) 4931 if (!url.isEmpty())
4972 urls.push_back( 4932 urls.push_back(
4973 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); 4933 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes));
4974 } 4934 }
4975 SendUpdateFaviconURL(urls); 4935 SendUpdateFaviconURL(urls);
4976 } 4936 }
4977 4937
4978 } // namespace content 4938 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698