diff options
author | nasko <nasko@chromium.org> | 2016-03-17 17:21:49 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-18 00:24:34 +0000 |
commit | 13c44c5c329fedc0a2c765edaf652747e5059be5 (patch) | |
tree | 0245422f4c5005454f857b2a3d4e0bde2b12d5f0 | |
parent | ebfb928267b08b8b2552b6ece3cb705208cbd4ca (diff) | |
download | chromium_src-13c44c5c329fedc0a2c765edaf652747e5059be5.zip chromium_src-13c44c5c329fedc0a2c765edaf652747e5059be5.tar.gz chromium_src-13c44c5c329fedc0a2c765edaf652747e5059be5.tar.bz2 |
Remove swapped out state from RenderFrameImpl.
BUG=357747
Review URL: https://codereview.chromium.org/1807893002
Cr-Commit-Position: refs/heads/master@{#381846}
-rw-r--r-- | content/renderer/accessibility/renderer_accessibility.cc | 3 | ||||
-rw-r--r-- | content/renderer/render_frame_impl.cc | 221 | ||||
-rw-r--r-- | content/renderer/render_frame_impl.h | 10 | ||||
-rw-r--r-- | content/renderer/render_view_impl.cc | 5 |
4 files changed, 56 insertions, 183 deletions
diff --git a/content/renderer/accessibility/renderer_accessibility.cc b/content/renderer/accessibility/renderer_accessibility.cc index a6922a8c..34f1c45 100644 --- a/content/renderer/accessibility/renderer_accessibility.cc +++ b/content/renderer/accessibility/renderer_accessibility.cc @@ -238,9 +238,6 @@ void RendererAccessibility::SendPendingAccessibilityEvents() { if (pending_events_.empty()) return; - if (render_frame_->is_swapped_out()) - return; - ack_pending_ = true; // Make a copy of the events, because it's possible that diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc index bc076029..83e7b05 100644 --- a/content/renderer/render_frame_impl.cc +++ b/content/renderer/render_frame_impl.cc @@ -978,7 +978,6 @@ RenderFrameImpl::RenderFrameImpl(const CreateParams& params) in_frame_tree_(false), render_view_(params.render_view->AsWeakPtr()), routing_id_(params.routing_id), - is_swapped_out_(false), render_frame_proxy_(NULL), is_detaching_(false), proxy_routing_id_(MSG_ROUTING_NONE), @@ -1097,7 +1096,7 @@ void RenderFrameImpl::Initialize() { #endif new SharedWorkerRepository(this); - if (IsLocalRoot() && !is_swapped_out_) { + if (IsLocalRoot()) { // DevToolsAgent is a RenderFrameObserver, and will destruct itself // when |this| is deleted. devtools_agent_ = new DevToolsAgent(this); @@ -1312,12 +1311,6 @@ bool RenderFrameImpl::Send(IPC::Message* message) { delete message; return false; } - if (is_swapped_out_) { - if (!SwappedOutMessages::CanSendWhileSwappedOut(message)) { - delete message; - return false; - } - } return RenderThread::Get()->Send(message); } @@ -1471,19 +1464,6 @@ void RenderFrameImpl::OnNavigate( scoped_ptr<StreamOverrideParameters>()); } -void RenderFrameImpl::NavigateToSwappedOutURL() { - // We use loadRequest instead of loadHTMLString because the former commits - // synchronously. Otherwise a new navigation can interrupt the navigation - // to kSwappedOutURL. If that happens to be to the page we had been - // showing, then WebKit will never send a commit and we'll be left spinning. - // Set the is_swapped_out_ bit to true, so IPC filtering is in effect and - // the navigation to swappedout:// is not announced to the browser side. - is_swapped_out_ = true; - GURL swappedOutURL(kSwappedOutURL); - WebURLRequest request(swappedOutURL); - frame_->loadRequest(request); -} - void RenderFrameImpl::BindServiceRegistry( mojo::shell::mojom::InterfaceProviderRequest services, mojo::shell::mojom::InterfaceProviderPtr exposed_services) { @@ -1526,55 +1506,51 @@ void RenderFrameImpl::OnSwapOut( // This codepath should only be hit for subframes when in --site-per-process. CHECK(is_main_frame_ || SiteIsolationPolicy::AreCrossProcessFramesPossible()); - // Only run unload if we're not swapped out yet, but send the ack either way. - if (!is_swapped_out_) { - // Swap this RenderFrame out so the frame can navigate to a page rendered by - // a different process. This involves running the unload handler and - // clearing the page. We also allow this process to exit if there are no - // other active RenderFrames in it. + // Swap this RenderFrame out so the frame can navigate to a page rendered by + // a different process. This involves running the unload handler and + // clearing the page. We also allow this process to exit if there are no + // other active RenderFrames in it. - // Send an UpdateState message before we get swapped out. - if (SiteIsolationPolicy::UseSubframeNavigationEntries()) - SendUpdateState(); - else - render_view_->SendUpdateState(); + // Send an UpdateState message before we get deleted. + if (SiteIsolationPolicy::UseSubframeNavigationEntries()) + SendUpdateState(); + else + render_view_->SendUpdateState(); - // If we need a proxy to replace this, create it now so its routing id is - // registered for receiving IPC messages. - if (proxy_routing_id != MSG_ROUTING_NONE) { - proxy = RenderFrameProxy::CreateProxyToReplaceFrame( - this, proxy_routing_id, replicated_frame_state.scope); - } + // If we need a proxy to replace this, create it now so its routing id is + // registered for receiving IPC messages. + if (proxy_routing_id != MSG_ROUTING_NONE) { + proxy = RenderFrameProxy::CreateProxyToReplaceFrame( + this, proxy_routing_id, replicated_frame_state.scope); + } - // Synchronously run the unload handler before sending the ACK. - // TODO(creis): Call dispatchUnloadEvent unconditionally here to support - // unload on subframes as well. - if (is_main_frame_) - frame_->dispatchUnloadEvent(); - - // Swap out and stop sending any IPC messages that are not ACKs. - if (is_main_frame_) - render_view_->SetSwappedOut(true); - is_swapped_out_ = true; - - // Set the proxy here, since OnStop() below could cause an onload event - // handler to execute, which could trigger code such as - // willCheckAndDispatchMessageEvent() that needs the proxy. - if (proxy) - set_render_frame_proxy(proxy); - - // Transfer settings such as initial drawing parameters to the remote frame, - // if one is created, that will replace this frame. - if (!is_main_frame_ && proxy) - proxy->web_frame()->initializeFromFrame(frame_); - - // Let WebKit know that this view is hidden so it can drop resources and - // stop compositing. - // TODO(creis): Support this for subframes as well. - if (is_main_frame_) { - render_view_->webview()->setVisibilityState( - blink::WebPageVisibilityStateHidden, false); - } + // Synchronously run the unload handler before sending the ACK. + // TODO(creis): Call dispatchUnloadEvent unconditionally here to support + // unload on subframes as well. + if (is_main_frame_) + frame_->dispatchUnloadEvent(); + + // Swap out and stop sending any IPC messages that are not ACKs. + if (is_main_frame_) + render_view_->SetSwappedOut(true); + + // Set the proxy here, since OnStop() below could cause an onload event + // handler to execute, which could trigger code such as + // willCheckAndDispatchMessageEvent() that needs the proxy. + if (proxy) + set_render_frame_proxy(proxy); + + // Transfer settings such as initial drawing parameters to the remote frame, + // if one is created, that will replace this frame. + if (!is_main_frame_ && proxy) + proxy->web_frame()->initializeFromFrame(frame_); + + // Let WebKit know that this view is hidden so it can drop resources and + // stop compositing. + // TODO(creis): Support this for subframes as well. + if (is_main_frame_) { + render_view_->webview()->setVisibilityState( + blink::WebPageVisibilityStateHidden, false); } // It is now safe to show modal dialogs again. @@ -2600,8 +2576,7 @@ blink::WebFrame* RenderFrameImpl::createChildFrame( Send(new FrameHostMsg_CreateChildFrame(params, &child_routing_id)); // Allocation of routing id failed, so we can't create a child frame. This can - // happen if this RenderFrameImpl's IPCs are being filtered when in swapped - // out state or synchronous IPC message above has failed. + // happen if the synchronous IPC message above has failed. if (child_routing_id == MSG_ROUTING_NONE) { NOTREACHED() << "Failed to allocate routing id for child frame."; return nullptr; @@ -2631,10 +2606,6 @@ blink::WebFrame* RenderFrameImpl::createChildFrame( } void RenderFrameImpl::didChangeOpener(blink::WebFrame* opener) { - // Only active frames are able to disown their opener. - if (!opener && is_swapped_out_) - return; - // Only a local frame should be able to update another frame's opener. DCHECK(!opener || opener->isWebLocalFrame()); @@ -2987,9 +2958,8 @@ void RenderFrameImpl::didStartProvisionalLoad(blink::WebLocalFrame* frame, "url", ds->request().url().string().utf8()); DocumentState* document_state = DocumentState::FromDataSource(ds); - // We should only navigate to swappedout:// when is_swapped_out_ is true. - CHECK(ds->request().url() != GURL(kSwappedOutURL) || is_swapped_out_) - << "Heard swappedout:// when not swapped out."; + // We should never navigate to swappedout://. + CHECK(ds->request().url() != GURL(kSwappedOutURL)) << "Heard swappedout://."; // Update the request time if WebKit has better knowledge of it. if (document_state->request_time().is_null() && @@ -3459,10 +3429,6 @@ void RenderFrameImpl::didFinishLoad(blink::WebLocalFrame* frame) { DidFinishLoad(frame)); FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidFinishLoad()); - // Don't send this message while the frame is swapped out. - if (is_swapped_out()) - return; - Send(new FrameHostMsg_DidFinishLoad(routing_id_, ds->request().url())); } @@ -3580,12 +3546,6 @@ bool RenderFrameImpl::runModalPromptDialog( } bool RenderFrameImpl::runModalBeforeUnloadDialog(bool is_reload) { - // If we are swapping out, we have already run the beforeunload handler. - // TODO(creis): Fix OnSwapOut to clear the frame without running beforeunload - // at all, to avoid running it twice. - if (is_swapped_out_) - return true; - // Don't allow further dialogs if we are waiting to swap out, since the // PageGroupLoadDeferrer in our stack prevents it. if (render_view()->suppress_dialogs_until_swap_out_) @@ -4093,19 +4053,9 @@ bool RenderFrameImpl::willCheckAndDispatchMessageEvent( blink::WebDOMMessageEvent event) { DCHECK(!frame_ || frame_ == target_frame); - // Currently, a postMessage that targets a cross-process frame can be plumbed - // either through this function or RenderFrameProxy::postMessageEvent. This - // function is used when the target cross-process frame is a top-level frame - // which has been swapped out. In that case, the corresponding WebLocalFrame - // currently remains in the frame tree even in site-per-process mode (see - // OnSwapOut). RenderFrameProxy::postMessageEvent is used in - // --site-per-process mode for all other cases. - // // TODO(alexmos, nasko): When swapped-out:// disappears, this should be // cleaned up so that RenderFrameProxy::postMessageEvent is the only path for // cross-process postMessages. - if (!is_swapped_out_) - return false; // It is possible to get here on a swapped-out frame without a // |render_frame_proxy_|. This happens when: @@ -4411,13 +4361,10 @@ void RenderFrameImpl::SendDidCommitProvisionalLoad( // RenderFrameProxies in other processes. // TODO(alexmos): Origins for URLs with non-standard schemes are excluded due // to https://crbug.com/439608 and will be replicated as unique origins. - if (!is_swapped_out_) { - std::string scheme = - frame->document().getSecurityOrigin().protocol().utf8(); - if (url::IsStandard(scheme.c_str(), - url::Component(0, static_cast<int>(scheme.length())))) { - params.origin = frame->document().getSecurityOrigin(); - } + std::string scheme = frame->document().getSecurityOrigin().protocol().utf8(); + if (url::IsStandard(scheme.c_str(), + url::Component(0, static_cast<int>(scheme.length())))) { + params.origin = frame->document().getSecurityOrigin(); } params.should_enforce_strict_mixed_content_checking = @@ -4429,8 +4376,6 @@ void RenderFrameImpl::SendDidCommitProvisionalLoad( // Set the URL to be displayed in the browser UI to the user. params.url = GetLoadingUrl(); - DCHECK(!is_swapped_out_ || params.url == GURL(kSwappedOutURL)); - if (frame->document().baseURL() != params.url) params.base_url = frame->document().baseURL(); @@ -4552,12 +4497,6 @@ void RenderFrameImpl::SendDidCommitProvisionalLoad( frame->dataSource()->request().inputPerfMetricReportPolicy()); params.ui_timestamp = base::TimeTicks() + base::TimeDelta::FromSecondsD( frame->dataSource()->request().uiStartTime()); - - // This message needs to be sent before any of allowScripts(), - // allowImages(), allowPlugins() is called for the new page, so that when - // these functions send a ViewHostMsg_ContentBlocked message, it arrives - // after the FrameHostMsg_DidCommitProvisionalLoad message. - Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); } else { // Subframe navigation: the type depends on whether this navigation // generated a new session history entry. When they do generate a session @@ -4571,12 +4510,14 @@ void RenderFrameImpl::SendDidCommitProvisionalLoad( DCHECK(!navigation_state->request_params().should_clear_history_list); params.history_list_was_cleared = false; params.report_type = FrameMsg_UILoadMetricsReportType::NO_REPORT; - - // Don't send this message while the subframe is swapped out. - if (!is_swapped_out()) - Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); } + // This message needs to be sent before any of allowScripts(), + // allowImages(), allowPlugins() is called for the new page, so that when + // these functions send a ViewHostMsg_ContentBlocked message, it arrives + // after the FrameHostMsg_DidCommitProvisionalLoad message. + Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); + // If we end up reusing this WebRequest (for example, due to a #ref click), // we don't want the transition type to persist. Just clear it. navigation_state->set_transition_type(ui::PAGE_TRANSITION_LINK); @@ -4728,31 +4669,6 @@ WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation( Referrer referrer( RenderViewImpl::GetReferrerFromRequest(frame_, info.urlRequest)); - // TODO(nick): Is consulting |is_main_frame| here correct? - if (is_main_frame_ && is_swapped_out_) { - if (info.urlRequest.url() != GURL(kSwappedOutURL)) { - // Targeted links may try to navigate a swapped out frame. Allow the - // browser process to navigate the tab instead. Note that it is also - // possible for non-targeted navigations (from this view) to arrive - // here just after we are swapped out. It's ok to send them to the - // browser, as long as they're for the top level frame. - // TODO(creis): Ensure this supports targeted form submissions when - // fixing http://crbug.com/101395. - if (frame_->parent() == NULL) { - OpenURL(info.urlRequest.url(), referrer, info.defaultPolicy, - info.replacesCurrentHistoryItem, false); - return blink::WebNavigationPolicyIgnore; // Suppress the load here. - } - - // We should otherwise ignore in-process iframe navigations, if they - // arrive just after we are swapped out. - return blink::WebNavigationPolicyIgnore; - } - - // Allow kSwappedOutURL to complete. - return info.defaultPolicy; - } - // Webkit is asking whether to navigate to a new URL. // This is fine normally, except if we're showing UI from one security // context and they're trying to navigate to a different context. @@ -5620,31 +5536,6 @@ void RenderFrameImpl::PrepareRenderViewForNavigation( CHECK_EQ(-1, render_view_->history_list_offset_); CHECK_EQ(0, render_view_->history_list_length_); } - - if (!is_swapped_out_ || frame_->parent()) - return; - - // This is a swapped out main frame, so swap the renderer back in. - // We marked the view as hidden when swapping the view out, so be sure to - // reset the visibility state before navigating to the new URL. - render_view_->webview()->setVisibilityState( - render_view_->visibilityState(), false); - - // If this is an attempt to reload while we are swapped out, we should not - // reload swappedout://, but the previous page, which is stored in - // params.state. Setting is_reload to false will treat this like a back - // navigation to accomplish that. - *is_reload = false; - *cache_policy = WebURLRequest::ReloadIgnoringCacheData; - - // We refresh timezone when a view is swapped in since timezone - // can get out of sync when the system timezone is updated while - // the view is swapped out. - RenderThreadImpl::NotifyTimezoneChange(); - - render_view_->SetSwappedOut(false); - is_swapped_out_ = false; - return; } void RenderFrameImpl::BeginNavigation(blink::WebURLRequest* request, diff --git a/content/renderer/render_frame_impl.h b/content/renderer/render_frame_impl.h index 3c94254..a21024d 100644 --- a/content/renderer/render_frame_impl.h +++ b/content/renderer/render_frame_impl.h @@ -225,10 +225,6 @@ class CONTENT_EXPORT RenderFrameImpl ~RenderFrameImpl() override; - bool is_swapped_out() const { - return is_swapped_out_; - } - // TODO(nasko): This can be removed once we don't have a swapped out state on // RenderFrames. See https://crbug.com/357747. void set_render_frame_proxy(RenderFrameProxy* proxy) { @@ -626,10 +622,6 @@ class CONTENT_EXPORT RenderFrameImpl blink::WebFrameSerializerClient::FrameSerializationStatus status) override; - // Make this frame show an empty, unscriptable page. - // TODO(nasko): Remove this method once swapped out state is no longer used. - void NavigateToSwappedOutURL(); - // Binds this render frame's service registry. void BindServiceRegistry( mojo::shell::mojom::InterfaceProviderRequest services, @@ -1015,9 +1007,7 @@ class CONTENT_EXPORT RenderFrameImpl base::WeakPtr<RenderViewImpl> render_view_; int routing_id_; - bool is_swapped_out_; - // RenderFrameProxy exists only when is_swapped_out_ is true. // TODO(nasko): This can be removed once we don't have a swapped out state on // RenderFrame. See https://crbug.com/357747. RenderFrameProxy* render_frame_proxy_; diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index f5ccb9c..e95dd6e 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -807,11 +807,6 @@ void RenderViewImpl::Initialize(const ViewMsg_New_Params& params, webview()->mainFrame()->toWebLocalFrame()->forceSandboxFlags( params.replicated_frame_state.sandbox_flags); } - - // If we are initially swapped out, navigate to kSwappedOutURL. - // This ensures we are in a unique origin that others cannot script. - if (is_swapped_out_ && webview()->mainFrame()->isWebLocalFrame()) - main_render_frame_->NavigateToSwappedOutURL(); } RenderViewImpl::~RenderViewImpl() { |