Chromium Code Reviews| Index: content/browser/loader/resource_request_info_impl.cc |
| diff --git a/content/browser/loader/resource_request_info_impl.cc b/content/browser/loader/resource_request_info_impl.cc |
| index 26f99f962d81854780ef20d550cacf4ea594b216..c6873ab8813c8c84be95ec04df9fe52c4246fbbe 100644 |
| --- a/content/browser/loader/resource_request_info_impl.cc |
| +++ b/content/browser/loader/resource_request_info_impl.cc |
| @@ -4,15 +4,43 @@ |
| #include "content/browser/loader/resource_request_info_impl.h" |
| +#include "content/browser/frame_host/frame_tree_node.h" |
| #include "content/browser/loader/global_routing_id.h" |
| #include "content/browser/loader/resource_message_filter.h" |
| +#include "content/browser/web_contents/web_contents_impl.h" |
| #include "content/common/net/url_request_user_data.h" |
| +#include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/global_request_id.h" |
| #include "content/public/common/process_type.h" |
| #include "net/url_request/url_request.h" |
| namespace content { |
| +namespace { |
| + |
| +WebContents* GetWebContentsFromFTNID(int frame_tree_node_id) { |
| + DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| + FrameTreeNode* frame_tree_node = |
| + FrameTreeNode::GloballyFindByID(frame_tree_node_id); |
| + if (!frame_tree_node) |
| + return nullptr; |
| + |
| + return WebContentsImpl::FromFrameTreeNode(frame_tree_node); |
| +} |
| + |
| +WebContents* GetWebContentsFromRFHID(int render_process_id, |
| + int render_frame_id) { |
| + DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| + RenderFrameHost* render_frame_host = |
| + RenderFrameHost::FromID(render_process_id, render_frame_id); |
| + if (!render_frame_host) |
| + return nullptr; |
| + |
| + return WebContents::FromRenderFrameHost(render_frame_host); |
| +} |
| + |
| +} // namespace |
| + |
| // ---------------------------------------------------------------------------- |
| // ResourceRequestInfo |
| @@ -168,6 +196,20 @@ ResourceRequestInfoImpl::ResourceRequestInfoImpl( |
| ResourceRequestInfoImpl::~ResourceRequestInfoImpl() { |
| } |
| +ResourceRequestInfo::WebContentsGetterOnUI |
| +ResourceRequestInfoImpl::GetWebContentsForRequest() { |
|
davidben
2015/11/19 17:46:13
This probably wants to comment to explain why ther
clamy
2015/11/20 13:50:42
Done.
|
| + if (frame_tree_node_id_ != -1) |
| + return base::Bind(&GetWebContentsFromFTNID, frame_tree_node_id_); |
| + |
| + int render_process_host_id = -1; |
| + int render_frame_host_id = -1; |
| + if (!GetAssociatedRenderFrame(&render_process_host_id, &render_frame_host_id)) |
| + NOTREACHED(); |
| + |
| + return base::Bind(&GetWebContentsFromRFHID, render_process_host_id, |
| + render_frame_host_id); |
| +} |
| + |
| ResourceContext* ResourceRequestInfoImpl::GetContext() const { |
| return context_; |
| } |