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

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: 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 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 OnDragSourceSystemDragEnded) 1117 OnDragSourceSystemDragEnded)
1118 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings) 1118 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings)
1119 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) 1119 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus)
1120 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) 1120 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck)
1121 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) 1121 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences)
1122 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, 1122 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse,
1123 OnEnumerateDirectoryResponse) 1123 OnEnumerateDirectoryResponse)
1124 IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) 1124 IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse)
1125 IPC_MESSAGE_HANDLER(ViewMsg_SuppressDialogsUntilSwapOut, 1125 IPC_MESSAGE_HANDLER(ViewMsg_SuppressDialogsUntilSwapOut,
1126 OnSuppressDialogsUntilSwapOut) 1126 OnSuppressDialogsUntilSwapOut)
1127 IPC_MESSAGE_HANDLER(ViewMsg_SwapOut, OnSwapOut)
1128 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) 1127 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage)
1129 IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged) 1128 IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged)
1130 IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) 1129 IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted)
1131 IPC_MESSAGE_HANDLER(ViewMsg_ClearFocusedElement, OnClearFocusedElement) 1130 IPC_MESSAGE_HANDLER(ViewMsg_ClearFocusedElement, OnClearFocusedElement)
1132 IPC_MESSAGE_HANDLER(ViewMsg_SetBackground, OnSetBackground) 1131 IPC_MESSAGE_HANDLER(ViewMsg_SetBackground, OnSetBackground)
1133 IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode, 1132 IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode,
1134 OnEnablePreferredSizeChangedMode) 1133 OnEnablePreferredSizeChangedMode)
1135 IPC_MESSAGE_HANDLER(ViewMsg_EnableAutoResize, OnEnableAutoResize) 1134 IPC_MESSAGE_HANDLER(ViewMsg_EnableAutoResize, OnEnableAutoResize)
1136 IPC_MESSAGE_HANDLER(ViewMsg_DisableAutoResize, OnDisableAutoResize) 1135 IPC_MESSAGE_HANDLER(ViewMsg_DisableAutoResize, OnDisableAutoResize)
1137 IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows, 1136 IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows,
(...skipping 2827 matching lines...) Expand 10 before | Expand all | Expand 10 after
3965 WebPageSerializer::serialize(webview()->mainFrame(), true, this, weburl_links, 3964 WebPageSerializer::serialize(webview()->mainFrame(), true, this, weburl_links,
3966 webstring_paths, 3965 webstring_paths,
3967 local_directory_name.AsUTF16Unsafe()); 3966 local_directory_name.AsUTF16Unsafe());
3968 } 3967 }
3969 3968
3970 void RenderViewImpl::OnSuppressDialogsUntilSwapOut() { 3969 void RenderViewImpl::OnSuppressDialogsUntilSwapOut() {
3971 // Don't show any more dialogs until we finish OnSwapOut. 3970 // Don't show any more dialogs until we finish OnSwapOut.
3972 suppress_dialogs_until_swap_out_ = true; 3971 suppress_dialogs_until_swap_out_ = true;
3973 } 3972 }
3974 3973
3975 void RenderViewImpl::OnSwapOut() {
3976 // Only run unload if we're not swapped out yet, but send the ack either way.
3977 if (!is_swapped_out_) {
3978 // Swap this RenderView out so the tab can navigate to a page rendered by a
3979 // different process. This involves running the unload handler and clearing
3980 // the page. Once WasSwappedOut is called, we also allow this process to
3981 // exit if there are no other active RenderViews in it.
3982
3983 // Send an UpdateState message before we get swapped out.
3984 SyncNavigationState();
3985
3986 // Synchronously run the unload handler before sending the ACK.
3987 webview()->dispatchUnloadEvent();
3988
3989 // Swap out and stop sending any IPC messages that are not ACKs.
3990 SetSwappedOut(true);
3991
3992 // Now that we're swapped out and filtering IPC messages, stop loading to
3993 // ensure that no other in-progress navigation continues. We do this here
3994 // to avoid sending a DidStopLoading message to the browser process.
3995 OnStop();
3996
3997 // Replace the page with a blank dummy URL. The unload handler will not be
3998 // run a second time, thanks to a check in FrameLoader::stopLoading.
3999 // TODO(creis): Need to add a better way to do this that avoids running the
4000 // beforeunload handler. For now, we just run it a second time silently.
4001 NavigateToSwappedOutURL(webview()->mainFrame());
4002
4003 // Let WebKit know that this view is hidden so it can drop resources and
4004 // stop compositing.
4005 webview()->setVisibilityState(blink::WebPageVisibilityStateHidden, false);
4006 }
4007
4008 // It is now safe to show modal dialogs again.
4009 suppress_dialogs_until_swap_out_ = false;
4010
4011 Send(new ViewHostMsg_SwapOut_ACK(routing_id_));
4012 }
4013
4014 void RenderViewImpl::NavigateToSwappedOutURL(blink::WebFrame* frame) { 3974 void RenderViewImpl::NavigateToSwappedOutURL(blink::WebFrame* frame) {
4015 // We use loadRequest instead of loadHTMLString because the former commits 3975 // We use loadRequest instead of loadHTMLString because the former commits
4016 // synchronously. Otherwise a new navigation can interrupt the navigation 3976 // synchronously. Otherwise a new navigation can interrupt the navigation
4017 // to kSwappedOutURL. If that happens to be to the page we had been 3977 // to kSwappedOutURL. If that happens to be to the page we had been
4018 // showing, then WebKit will never send a commit and we'll be left spinning. 3978 // showing, then WebKit will never send a commit and we'll be left spinning.
4019 // TODO(creis): Until we move this to RenderFrame, we may call this from a 3979 // TODO(creis): Until we move this to RenderFrame, we may call this from a
4020 // swapped out RenderFrame while our own is_swapped_out_ is false. 3980 // swapped out RenderFrame while our own is_swapped_out_ is false.
4021 RenderFrameImpl* rf = RenderFrameImpl::FromWebFrame(frame); 3981 RenderFrameImpl* rf = RenderFrameImpl::FromWebFrame(frame);
4022 CHECK(is_swapped_out_ || rf->is_swapped_out()); 3982 CHECK(is_swapped_out_ || rf->is_swapped_out());
4023 GURL swappedOutURL(kSwappedOutURL); 3983 GURL swappedOutURL(kSwappedOutURL);
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after
5127 std::vector<gfx::Size> sizes(icon_urls[i].sizes().size()); 5087 std::vector<gfx::Size> sizes(icon_urls[i].sizes().size());
5128 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); 5088 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes);
5129 if (!url.isEmpty()) 5089 if (!url.isEmpty())
5130 urls.push_back( 5090 urls.push_back(
5131 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); 5091 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes));
5132 } 5092 }
5133 SendUpdateFaviconURL(urls); 5093 SendUpdateFaviconURL(urls);
5134 } 5094 }
5135 5095
5136 } // namespace content 5096 } // namespace content
OLDNEW
« content/browser/web_contents/web_contents_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