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

Unified Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 2758993002: Move the functions which block, resume and cancel requests for a frame route id out of ResourceDisp… (Closed)
Patch Set: Rebased to tip Created 3 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/frame_host/render_frame_host_impl.cc
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc
index 4d73732c949fd49f38fec6ac333519fa26e84b05..adebd804260082216297409176ce40fb7b18b67f 100644
--- a/content/browser/frame_host/render_frame_host_impl.cc
+++ b/content/browser/frame_host/render_frame_host_impl.cc
@@ -253,6 +253,50 @@ void IgnoreInterfaceRequest(mojo::InterfaceRequest<Interface> request) {
// Intentionally ignore the interface request.
}
+// The following functions simplify code paths where the UI thread notifies the
+// ResourceDispatcherHostImpl of information pertaining to loading behavior of
+// frame hosts.
+void NotifyRouteChangesOnIO(
+ base::Callback<void(ResourceDispatcherHostImpl*,
+ const GlobalFrameRoutingId&)> frame_callback,
+ std::unique_ptr<std::set<GlobalFrameRoutingId>> routing_ids) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get();
+ if (!rdh)
+ return;
+ for (const auto& routing_id : *routing_ids)
+ frame_callback.Run(rdh, routing_id);
+}
+
+void NotifyForEachFrameFromUI(
+ RenderFrameHost* root_frame_host,
+ base::Callback<void(ResourceDispatcherHostImpl*,
+ const GlobalFrameRoutingId&)> frame_callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ FrameTree* frame_tree = static_cast<RenderFrameHostImpl*>(root_frame_host)
+ ->frame_tree_node()
+ ->frame_tree();
+ DCHECK_EQ(root_frame_host, frame_tree->GetMainFrame());
+
+ std::unique_ptr<std::set<GlobalFrameRoutingId>> routing_ids(
+ new std::set<GlobalFrameRoutingId>());
+ for (FrameTreeNode* node : frame_tree->Nodes()) {
+ RenderFrameHostImpl* frame_host = node->current_frame_host();
+ RenderFrameHostImpl* pending_frame_host =
+ IsBrowserSideNavigationEnabled()
+ ? node->render_manager()->speculative_frame_host()
+ : node->render_manager()->pending_frame_host();
+ if (frame_host)
+ routing_ids->insert(frame_host->GetGlobalFrameRoutingId());
+ if (pending_frame_host)
+ routing_ids->insert(pending_frame_host->GetGlobalFrameRoutingId());
+ }
+ BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
+ base::Bind(&NotifyRouteChangesOnIO, frame_callback,
+ base::Passed(std::move(routing_ids))));
+}
+
} // namespace
// static
@@ -1003,7 +1047,7 @@ void RenderFrameHostImpl::SetRenderFrameCreated(bool created) {
}
void RenderFrameHostImpl::Init() {
- ResourceDispatcherHost::ResumeBlockedRequestsForFrameFromUI(this);
+ ResumeBlockedRequestsForFrame();
if (!waiting_for_init_)
return;
@@ -1835,6 +1879,25 @@ int RenderFrameHostImpl::GetEnabledBindings() const {
return enabled_bindings_;
}
+void RenderFrameHostImpl::BlockRequestsForFrame() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ NotifyForEachFrameFromUI(
+ this, base::Bind(&ResourceDispatcherHostImpl::BlockRequestsForRoute));
+}
+
+void RenderFrameHostImpl::ResumeBlockedRequestsForFrame() {
+ NotifyForEachFrameFromUI(
+ this,
+ base::Bind(&ResourceDispatcherHostImpl::ResumeBlockedRequestsForRoute));
+}
+
+void RenderFrameHostImpl::CancelBlockedRequestsForFrame() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ NotifyForEachFrameFromUI(
+ this,
+ base::Bind(&ResourceDispatcherHostImpl::CancelBlockedRequestsForRoute));
+}
+
void RenderFrameHostImpl::OnDidAccessInitialDocument() {
delegate_->DidAccessInitialDocument();
}
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.h ('k') | content/browser/loader/resource_dispatcher_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698