Chromium Code Reviews| Index: content/browser/download/download_request_handle.cc |
| diff --git a/content/browser/download/download_request_handle.cc b/content/browser/download/download_request_handle.cc |
| index 8a46917023b20b0f809a214688cbd2cee67d2290..693200cb9154e9244e1ad7c869a5f17d59932aea 100644 |
| --- a/content/browser/download/download_request_handle.cc |
| +++ b/content/browser/download/download_request_handle.cc |
| @@ -6,13 +6,9 @@ |
| #include "base/bind.h" |
| #include "base/strings/stringprintf.h" |
| -#include "content/browser/frame_host/navigator.h" |
| -#include "content/browser/frame_host/render_frame_host_impl.h" |
| -#include "content/browser/renderer_host/render_view_host_impl.h" |
| #include "content/browser/web_contents/web_contents_impl.h" |
| #include "content/public/browser/browser_context.h" |
| #include "content/public/browser/browser_thread.h" |
| -#include "content/public/common/browser_side_navigation_policy.h" |
| namespace content { |
| @@ -24,73 +20,26 @@ DownloadRequestHandle::DownloadRequestHandle( |
| DownloadRequestHandle::~DownloadRequestHandle() {} |
| DownloadRequestHandle::DownloadRequestHandle() |
| - : child_id_(-1), |
| - render_view_id_(-1), |
| - request_id_(-1), |
| - frame_tree_node_id_(-1) { |
| -} |
| + : web_contents_getter_(content::ResourceRequestInfo::WebContentsGetter()) {} |
|
asanka
2016/02/25 16:19:10
Nit: Don't explicitly initialize this. You want th
Charlie Harrison
2016/02/25 16:53:58
Done.
|
| DownloadRequestHandle::DownloadRequestHandle( |
| const base::WeakPtr<DownloadResourceHandler>& handler, |
| - int child_id, |
| - int render_view_id, |
| - int request_id, |
| - int frame_tree_node_id) |
| - : handler_(handler), |
| - child_id_(child_id), |
| - render_view_id_(render_view_id), |
| - request_id_(request_id), |
| - frame_tree_node_id_(frame_tree_node_id) { |
| + const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter) |
| + : handler_(handler), web_contents_getter_(web_contents_getter) { |
| DCHECK(handler_.get()); |
| } |
| WebContents* DownloadRequestHandle::GetWebContents() const { |
| - // PlzNavigate: if a FrameTreeNodeId was provided, use it to return the |
| - // WebContents. |
| - // TODO(davidben): This logic should be abstracted within the ResourceLoader |
| - // stack. https://crbug.com/376003 |
| - if (IsBrowserSideNavigationEnabled()) { |
| - FrameTreeNode* frame_tree_node = |
| - FrameTreeNode::GloballyFindByID(frame_tree_node_id_); |
| - if (frame_tree_node) { |
| - return WebContentsImpl::FromFrameTreeNode(frame_tree_node); |
| - } |
| - } |
| - |
| - RenderViewHostImpl* render_view_host = |
| - RenderViewHostImpl::FromID(child_id_, render_view_id_); |
| - if (!render_view_host) |
| - return nullptr; |
| - |
| - return render_view_host->GetDelegate()->GetAsWebContents(); |
| + return web_contents_getter_.is_null() ? nullptr : web_contents_getter_.Run(); |
| } |
| DownloadManager* DownloadRequestHandle::GetDownloadManager() const { |
| - // PlzNavigate: if a FrameTreeNodeId was provided, use it to return the |
| - // DownloadManager. |
| - // TODO(davidben): This logic should be abstracted within the ResourceLoader |
| - // stack. https://crbug.com/376003 |
| - if (IsBrowserSideNavigationEnabled()) { |
| - FrameTreeNode* frame_tree_node = |
| - FrameTreeNode::GloballyFindByID(frame_tree_node_id_); |
| - if (frame_tree_node) { |
| - BrowserContext* context = |
| - frame_tree_node->navigator()->GetController()->GetBrowserContext(); |
| - if (context) |
| - return BrowserContext::GetDownloadManager(context); |
| - } |
| - } |
| - |
| - RenderViewHostImpl* rvh = RenderViewHostImpl::FromID( |
| - child_id_, render_view_id_); |
| - if (rvh == NULL) |
| - return NULL; |
| - RenderProcessHost* rph = rvh->GetProcess(); |
| - if (rph == NULL) |
| - return NULL; |
| - BrowserContext* context = rph->GetBrowserContext(); |
| - if (context == NULL) |
| - return NULL; |
| + WebContents* web_contents = GetWebContents(); |
| + if (web_contents == nullptr) |
| + return nullptr; |
| + BrowserContext* context = web_contents->GetBrowserContext(); |
| + if (context == nullptr) |
| + return nullptr; |
| return BrowserContext::GetDownloadManager(context); |
| } |
| @@ -112,15 +61,4 @@ void DownloadRequestHandle::CancelRequest() const { |
| base::Bind(&DownloadResourceHandler::CancelRequest, handler_)); |
| } |
| -std::string DownloadRequestHandle::DebugString() const { |
| - return base::StringPrintf("{" |
| - " child_id = %d" |
| - " render_view_id = %d" |
| - " request_id = %d" |
| - "}", |
| - child_id_, |
| - render_view_id_, |
| - request_id_); |
| -} |
| - |
| } // namespace content |