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

Unified Diff: content/browser/download/download_request_handle.cc

Issue 1079163008: PlzNavigate: provide the FrameTreeNode ID to the network stack (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix-unittests
Patch Set: Now using FTN id or routing ID Created 5 years, 8 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/download/download_request_handle.cc
diff --git a/content/browser/download/download_request_handle.cc b/content/browser/download/download_request_handle.cc
index 32c5b987799d510d79fb6e12c4327784498fdd86..684f867d8e03a48e97ff4f166988fe5e91fcea5d 100644
--- a/content/browser/download/download_request_handle.cc
+++ b/content/browser/download/download_request_handle.cc
@@ -5,11 +5,15 @@
#include "content/browser/download/download_request_handle.h"
#include "base/bind.h"
+#include "base/command_line.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/content_switches.h"
namespace content {
@@ -19,22 +23,38 @@ DownloadRequestHandle::~DownloadRequestHandle() {
DownloadRequestHandle::DownloadRequestHandle()
: child_id_(-1),
render_view_id_(-1),
- request_id_(-1) {
+ request_id_(-1),
+ frame_tree_node_id_(-1) {
}
DownloadRequestHandle::DownloadRequestHandle(
const base::WeakPtr<DownloadResourceHandler>& handler,
int child_id,
int render_view_id,
- int request_id)
+ int request_id,
+ int64 frame_tree_node_id)
: handler_(handler),
child_id_(child_id),
render_view_id_(render_view_id),
- request_id_(request_id) {
+ request_id_(request_id),
+ frame_tree_node_id_(frame_tree_node_id) {
DCHECK(handler_.get());
}
WebContents* DownloadRequestHandle::GetWebContents() const {
+ // PlzNavigate: if a FrameTreeNodeID was provided, use it to return the
+ // WebContents.
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableBrowserSideNavigation)) {
+ FrameTreeNode* frame_tree_node =
+ FrameTreeNode::GloballyFindByID(frame_tree_node_id_);
+ if (frame_tree_node) {
+ return frame_tree_node->current_frame_host()
+ ->delegate()
+ ->GetAsWebContents();
nasko 2015/04/27 14:24:11 This method isn't very good and we should avoid us
clamy 2015/04/27 16:19:12 I created a WebContentsImpl::FromFrameTreeNode met
+ }
+ }
+
clamy 2015/04/27 14:34:44 If we use the FTN id, we still have to rely on the
RenderViewHostImpl* render_view_host =
RenderViewHostImpl::FromID(child_id_, render_view_id_);
if (!render_view_host)
@@ -44,6 +64,20 @@ WebContents* DownloadRequestHandle::GetWebContents() const {
}
DownloadManager* DownloadRequestHandle::GetDownloadManager() const {
+ // PlzNavigate: if a FrameTreeNodeID was provided, use it to return the
+ // DownloadManager.
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableBrowserSideNavigation)) {
+ 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)

Powered by Google App Engine
This is Rietveld 408576698