Index: chrome/browser/renderer_host/download_resource_handler.cc |
diff --git a/chrome/browser/renderer_host/download_resource_handler.cc b/chrome/browser/renderer_host/download_resource_handler.cc |
index f35d5e4166ce7a127ce62a813137ecc2081b24e6..53194d40eed5fe0985616c763edc4976f3cce10b 100644 |
--- a/chrome/browser/renderer_host/download_resource_handler.cc |
+++ b/chrome/browser/renderer_host/download_resource_handler.cc |
@@ -13,6 +13,8 @@ |
#include "chrome/browser/download/download_create_info.h" |
#include "chrome/browser/download/download_item.h" |
#include "chrome/browser/download/download_file_manager.h" |
+#include "chrome/browser/download/download_manager.h" |
+#include "chrome/browser/download/download_prefs.h" |
#include "chrome/browser/download/download_request_handle.h" |
#include "chrome/browser/download/download_util.h" |
#include "content/browser/browser_thread.h" |
@@ -77,7 +79,6 @@ bool DownloadResourceHandler::OnResponseStarted(int request_id, |
const ResourceDispatcherHostRequestInfo* request_info = |
ResourceDispatcherHost::InfoForRequest(request_); |
- download_id_ = download_file_manager_->GetNextId(); |
// Deleted in DownloadManager. |
DownloadCreateInfo* info = new DownloadCreateInfo; |
@@ -87,7 +88,6 @@ bool DownloadResourceHandler::OnResponseStarted(int request_id, |
info->received_bytes = 0; |
info->total_bytes = content_length_; |
info->state = DownloadItem::IN_PROGRESS; |
- info->download_id = download_id_; |
info->has_user_gesture = request_info->has_user_gesture(); |
info->request_handle = DownloadRequestHandle(rdh_, |
global_id_.child_id, |
@@ -108,10 +108,8 @@ bool DownloadResourceHandler::OnResponseStarted(int request_id, |
save_as_ && save_info_.file_path.empty(); |
info->referrer_charset = request_->context()->referrer_charset(); |
info->save_info = save_info_; |
- BrowserThread::PostTask( |
- BrowserThread::UI, FROM_HERE, |
- NewRunnableMethod( |
- download_file_manager_, &DownloadFileManager::StartDownload, info)); |
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, NewRunnableMethod( |
+ this, &DownloadResourceHandler::StartDownloadOnUIThread, info)); |
// We can't start saving the data before we create the file on disk. |
// The request will be un-paused in DownloadFileManager::CreateDownloadFile. |
@@ -120,6 +118,16 @@ bool DownloadResourceHandler::OnResponseStarted(int request_id, |
return true; |
} |
+void DownloadResourceHandler::StartDownloadOnUIThread( |
+ DownloadCreateInfo* info) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ download_id_ = info->request_handle.GetDownloadManager()->download_prefs()-> |
Randy Smith (Not in Mondays)
2011/07/10 23:49:55
I'm concerned about this line--it's setting a valu
benjhayden
2011/07/11 15:57:50
Ah, I see it now.
The primary reason that I moved
Randy Smith (Not in Mondays)
2011/07/12 18:12:52
I think DownloadPrefs is a UI thread object, and I
|
+ GetNextId(); |
+ VLOG(20) << __PRETTY_FUNCTION__ << " " << download_id_; |
+ info->download_id = download_id_; |
+ download_file_manager_->StartDownload(info); |
+} |
+ |
bool DownloadResourceHandler::OnWillStart(int request_id, |
const GURL& url, |
bool* defer) { |