Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "chrome/browser/download/download_file.h" | 5 #include "chrome/browser/download/download_file.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| 11 #include "chrome/browser/download/download_manager.h" | 11 #include "chrome/browser/download/download_manager.h" |
| 12 #include "chrome/browser/download/download_util.h" | 12 #include "chrome/browser/download/download_util.h" |
| 13 #include "chrome/browser/history/download_create_info.h" | 13 #include "chrome/browser/history/download_create_info.h" |
| 14 #include "content/browser/browser_thread.h" | 14 #include "content/browser/browser_thread.h" |
| 15 | 15 |
| 16 DownloadFile::DownloadFile(const DownloadCreateInfo* info, | 16 DownloadFile::DownloadFile(const DownloadCreateInfo* info, |
| 17 DownloadManager* download_manager) | 17 DownloadManager* download_manager) |
| 18 : BaseFile(info->save_info.file_path, | 18 : BaseFile(info->save_info.file_path, |
| 19 info->url(), | 19 info->url(), |
| 20 info->referrer_url, | 20 info->referrer_url, |
| 21 info->received_bytes, | 21 info->received_bytes, |
| 22 info->save_info.file_stream), | 22 info->save_info.file_stream), |
| 23 id_(info->download_id), | 23 id_(info->download_id), |
| 24 child_id_(info->child_id), | 24 process_handle_(info->process_handle), |
| 25 request_id_(info->request_id), | |
| 26 download_manager_(download_manager) { | 25 download_manager_(download_manager) { |
| 27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 28 | 27 |
| 29 } | 28 } |
| 30 | 29 |
| 31 DownloadFile::~DownloadFile() { | 30 DownloadFile::~DownloadFile() { |
| 32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 33 } | 32 } |
| 34 | 33 |
| 35 void DownloadFile::CancelDownloadRequest(ResourceDispatcherHost* rdh) { | 34 void DownloadFile::CancelDownloadRequest(ResourceDispatcherHost* rdh) { |
|
Paweł Hajdan Jr.
2011/05/06 18:04:42
nit: Please restore the BrowserThread DCHECK.
ahendrickson
2011/05/09 15:57:31
It doesn't matter what thread this is called from,
Paweł Hajdan Jr.
2011/05/09 19:47:30
Agreed, but it's very important to ensure that Dow
ahendrickson
2011/05/10 18:04:43
Done.
| |
| 36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 35 download_util::CancelDownloadRequest(rdh, process_handle_); |
|
Randy Smith (Not in Mondays)
2011/05/09 00:57:45
I don't want to put more stuff into download_util.
Paweł Hajdan Jr.
2011/05/09 19:47:30
Wait, what's wrong with this change? We're not add
Randy Smith (Not in Mondays)
2011/05/09 21:42:20
Ah, whoops, I see. Quite right. I rescind my obj
| |
| 37 BrowserThread::PostTask( | |
| 38 BrowserThread::IO, FROM_HERE, | |
| 39 NewRunnableFunction(&download_util::CancelDownloadRequest, | |
| 40 rdh, | |
| 41 child_id_, | |
| 42 request_id_)); | |
| 43 } | 36 } |
| 44 | 37 |
| 45 DownloadManager* DownloadFile::GetDownloadManager() { | 38 DownloadManager* DownloadFile::GetDownloadManager() { |
| 46 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 47 return download_manager_.get(); | 40 return download_manager_.get(); |
| 48 } | 41 } |
| 49 | 42 |
| 50 std::string DownloadFile::DebugString() const { | 43 std::string DownloadFile::DebugString() const { |
| 51 return base::StringPrintf("{" | 44 return base::StringPrintf("{" |
| 52 " full_path_ = " "\"%s\"" | |
| 53 " id_ = " "%d" | 45 " id_ = " "%d" |
| 54 " child_id_ = " "%d" | 46 " child_id = " "%d" |
| 55 " request_id_ = " "%d" | 47 " request_id = " "%d" |
| 48 " render_view_id = " "%d" | |
| 56 " Base File = %s" | 49 " Base File = %s" |
| 57 " }", | 50 " }", |
| 58 full_path_.value().c_str(), | |
| 59 id_, | 51 id_, |
| 60 child_id_, | 52 process_handle_.child_id(), |
| 61 request_id_, | 53 process_handle_.request_id(), |
| 54 process_handle_.render_view_id(), | |
| 62 BaseFile::DebugString().c_str()); | 55 BaseFile::DebugString().c_str()); |
| 63 } | 56 } |
| OLD | NEW |