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

Side by Side Diff: content/browser/download/download_request_handle.cc

Issue 8060042: Add downloads.onCreated apitest and fix a few bugs (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: " Created 9 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/download/download_request_handle.h" 5 #include "content/browser/download/download_request_handle.h"
6 6
7 #include "base/stringprintf.h" 7 #include "base/stringprintf.h"
8 #include "content/browser/browser_context.h" 8 #include "content/browser/browser_context.h"
9 #include "content/browser/browser_thread.h" 9 #include "content/browser/browser_thread.h"
10 #include "content/browser/renderer_host/render_view_host.h" 10 #include "content/browser/renderer_host/render_view_host.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 TabContents* DownloadRequestHandle::GetTabContents() const { 54 TabContents* DownloadRequestHandle::GetTabContents() const {
55 RenderViewHost* render_view_host = 55 RenderViewHost* render_view_host =
56 RenderViewHost::FromID(child_id_, render_view_id_); 56 RenderViewHost::FromID(child_id_, render_view_id_);
57 if (!render_view_host) 57 if (!render_view_host)
58 return NULL; 58 return NULL;
59 59
60 return render_view_host->delegate()->GetAsTabContents(); 60 return render_view_host->delegate()->GetAsTabContents();
61 } 61 }
62 62
63 DownloadManager* DownloadRequestHandle::GetDownloadManager() const { 63 DownloadManager* DownloadRequestHandle::GetDownloadManager() const {
64 TabContents* contents = GetTabContents(); 64 return RenderViewHost::FromID(child_id_, render_view_id_)->process()
65 if (!contents) 65 ->browser_context()->GetDownloadManager();
Randy Smith (Not in Mondays) 2011/10/17 17:39:56 Random thought that you're welcome to bounce as no
benjhayden 2011/10/17 17:54:29 I thought that we decided that that would be break
66 return NULL;
67
68 content::BrowserContext* browser_context = contents->browser_context();
69 if (!browser_context)
70 return NULL;
71
72 return browser_context->GetDownloadManager();
73 } 66 }
74 67
75 void DownloadRequestHandle::PauseRequest() const { 68 void DownloadRequestHandle::PauseRequest() const {
76 // The post is safe because ResourceDispatcherHost is guaranteed 69 // The post is safe because ResourceDispatcherHost is guaranteed
77 // to outlive the IO thread. 70 // to outlive the IO thread.
78 if (rdh_) { 71 if (rdh_) {
79 BrowserThread::PostTask( 72 BrowserThread::PostTask(
80 BrowserThread::IO, FROM_HERE, 73 BrowserThread::IO, FROM_HERE,
81 NewRunnableFunction(&ResourceDispatcherHostPauseRequest, 74 NewRunnableFunction(&ResourceDispatcherHostPauseRequest,
82 rdh_, child_id_, request_id_, true)); 75 rdh_, child_id_, request_id_, true));
(...skipping 25 matching lines...) Expand all
108 std::string DownloadRequestHandle::DebugString() const { 101 std::string DownloadRequestHandle::DebugString() const {
109 return base::StringPrintf("{" 102 return base::StringPrintf("{"
110 " child_id = %d" 103 " child_id = %d"
111 " render_view_id = %d" 104 " render_view_id = %d"
112 " request_id = %d" 105 " request_id = %d"
113 "}", 106 "}",
114 child_id_, 107 child_id_,
115 render_view_id_, 108 render_view_id_,
116 request_id_); 109 request_id_);
117 } 110 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698