summaryrefslogtreecommitdiffstats
path: root/content/browser/download
diff options
context:
space:
mode:
authorrdsmith@chromium.org <rdsmith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-25 20:22:37 +0000
committerrdsmith@chromium.org <rdsmith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-25 20:22:37 +0000
commit725f019896f8d221a7a8733c4b06bcffa5d60476 (patch)
tree7299434526baa089063b011be1f58d1b339372d9 /content/browser/download
parent3461e9f3a68c1984b1fb04d3646ba74368463e00 (diff)
downloadchromium_src-725f019896f8d221a7a8733c4b06bcffa5d60476.zip
chromium_src-725f019896f8d221a7a8733c4b06bcffa5d60476.tar.gz
chromium_src-725f019896f8d221a7a8733c4b06bcffa5d60476.tar.bz2
Removed checks for NULL DownloadManager in DownloadFileImpl.
These never happen, so we can cleanup the code by putting in DCHECKs instead of tests. R=asanka@chromium.org Review URL: https://chromiumcodereview.appspot.com/10663005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143994 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/download')
-rw-r--r--content/browser/download/download_file_impl.cc43
-rw-r--r--content/browser/download/download_file_manager.cc9
2 files changed, 20 insertions, 32 deletions
diff --git a/content/browser/download/download_file_impl.cc b/content/browser/download/download_file_impl.cc
index f7f190a..59b26c2 100644
--- a/content/browser/download/download_file_impl.cc
+++ b/content/browser/download/download_file_impl.cc
@@ -52,6 +52,7 @@ DownloadFileImpl::DownloadFileImpl(
weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
power_save_blocker_(power_save_blocker.Pass()) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ DCHECK(download_manager.get());
}
DownloadFileImpl::~DownloadFileImpl() {
@@ -232,27 +233,23 @@ void DownloadFileImpl::StreamActive() {
// Our controller will clean us up.
stream_reader_->RegisterCallback(base::Closure());
weak_factory_.InvalidateWeakPtrs();
- if (download_manager_.get()) {
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&DownloadManager::OnDownloadInterrupted,
- download_manager_, id_.local(),
- BytesSoFar(), GetHashState(), reason));
- }
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&DownloadManager::OnDownloadInterrupted,
+ download_manager_, id_.local(),
+ BytesSoFar(), GetHashState(), reason));
} else if (state == content::ByteStreamReader::STREAM_COMPLETE) {
// Signal successful completion and shut down processing.
stream_reader_->RegisterCallback(base::Closure());
weak_factory_.InvalidateWeakPtrs();
- if (download_manager_.get()) {
- std::string hash;
- if (!GetHash(&hash) || file_.IsEmptyHash(hash))
- hash.clear();
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&DownloadManager::OnResponseCompleted,
- download_manager_, id_.local(),
- BytesSoFar(), hash));
- }
+ std::string hash;
+ if (!GetHash(&hash) || file_.IsEmptyHash(hash))
+ hash.clear();
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&DownloadManager::OnResponseCompleted,
+ download_manager_, id_.local(),
+ BytesSoFar(), hash));
}
if (bound_net_log_.IsLoggingAllEvents()) {
bound_net_log_.AddEvent(
@@ -263,11 +260,9 @@ void DownloadFileImpl::StreamActive() {
}
void DownloadFileImpl::SendUpdate() {
- if (download_manager_.get()) {
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&DownloadManager::UpdateDownload,
- download_manager_, id_.local(),
- BytesSoFar(), CurrentSpeed(), GetHashState()));
- }
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&DownloadManager::UpdateDownload,
+ download_manager_, id_.local(),
+ BytesSoFar(), CurrentSpeed(), GetHashState()));
}
diff --git a/content/browser/download/download_file_manager.cc b/content/browser/download/download_file_manager.cc
index cdc2be9..dda4332 100644
--- a/content/browser/download/download_file_manager.cc
+++ b/content/browser/download/download_file_manager.cc
@@ -301,14 +301,7 @@ void DownloadFileManager::CancelDownloadOnRename(
return;
DownloadManager* download_manager = download_file->GetDownloadManager();
- if (!download_manager) {
- // Without a download manager, we can't cancel the request normally, so we
- // need to do it here. The normal path will also update the download
- // history before canceling the request.
- download_file->CancelDownloadRequest();
- return;
- }
-
+ DCHECK(download_manager);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&DownloadManager::OnDownloadInterrupted,