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

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

Issue 1418663010: Adding WebContent-free Download (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing Mock for GetBrowserContext. Created 5 years, 1 month 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_resource_handler.cc
diff --git a/content/browser/download/download_resource_handler.cc b/content/browser/download/download_resource_handler.cc
index d806d9449330cbb7adce8c3f5743334936d37967..3837e5bee8e06926ba4d4032e16999cd78317d11 100644
--- a/content/browser/download/download_resource_handler.cc
+++ b/content/browser/download/download_resource_handler.cc
@@ -62,10 +62,12 @@ static void StartOnUIThread(
scoped_ptr<DownloadCreateInfo> info,
scoped_ptr<DownloadResourceHandler::DownloadTabInfo> tab_info,
scoped_ptr<ByteStreamReader> stream,
+ DownloadManager* download_manager,
const DownloadUrlParameters::OnStartedCallback& started_cb) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- DownloadManager* download_manager = info->request_handle.GetDownloadManager();
+ if (!download_manager)
+ download_manager = info->request_handle.GetDownloadManager();
if (!download_manager) {
// NULL in unittests or if the page closed right after starting the
// download.
@@ -248,10 +250,9 @@ bool DownloadResourceHandler::OnResponseStarted(
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- base::Bind(&StartOnUIThread,
- base::Passed(&info),
- base::Passed(&tab_info_),
- base::Passed(&stream_reader),
+ base::Bind(&StartOnUIThread, base::Passed(&info),
+ base::Passed(&tab_info_), base::Passed(&stream_reader),
+ download_manager_.get(),
asanka 2015/11/25 15:53:57 Can't de-reference a WeakPtr on a thread other tha
svaldez 2015/11/25 17:53:28 Yeah, found that out when testing. SHould be fixed
// Pass to StartOnUIThread so that variable
// access is always on IO thread but function
// is called on UI thread.

Powered by Google App Engine
This is Rietveld 408576698