| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_manager_impl.h" | 5 #include "content/browser/download/download_manager_impl.h" |
| 6 | 6 |
| 7 #include <iterator> | 7 #include <iterator> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 DCHECK(browser_context); | 341 DCHECK(browser_context); |
| 342 DCHECK(!shutdown_needed_) << "DownloadManager already initialized."; | 342 DCHECK(!shutdown_needed_) << "DownloadManager already initialized."; |
| 343 shutdown_needed_ = true; | 343 shutdown_needed_ = true; |
| 344 | 344 |
| 345 browser_context_ = browser_context; | 345 browser_context_ = browser_context; |
| 346 | 346 |
| 347 return true; | 347 return true; |
| 348 } | 348 } |
| 349 | 349 |
| 350 // We have received a message from DownloadFileManager about a new download. | 350 // We have received a message from DownloadFileManager about a new download. |
| 351 content::DownloadId DownloadManagerImpl::StartDownload( | 351 DownloadItem* DownloadManagerImpl::StartDownload( |
| 352 scoped_ptr<DownloadCreateInfo> info, | 352 scoped_ptr<DownloadCreateInfo> info, |
| 353 scoped_ptr<content::ByteStreamReader> stream) { | 353 scoped_ptr<content::ByteStreamReader> stream) { |
| 354 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 354 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 355 | 355 |
| 356 // |bound_net_log| will be used for logging both the download item's and | 356 // |bound_net_log| will be used for logging both the download item's and |
| 357 // the download file's events. | 357 // the download file's events. |
| 358 net::BoundNetLog bound_net_log = CreateDownloadItem(info.get()); | 358 net::BoundNetLog bound_net_log = CreateDownloadItem(info.get()); |
| 359 | 359 |
| 360 // If info->download_id was unknown on entry to this function, it was | 360 // If info->download_id was unknown on entry to this function, it was |
| 361 // assigned in CreateDownloadItem. | 361 // assigned in CreateDownloadItem. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 373 this, download_id.local())); | 373 this, download_id.local())); |
| 374 | 374 |
| 375 BrowserThread::PostTask( | 375 BrowserThread::PostTask( |
| 376 BrowserThread::FILE, FROM_HERE, | 376 BrowserThread::FILE, FROM_HERE, |
| 377 base::Bind(&DownloadFileManager::CreateDownloadFile, | 377 base::Bind(&DownloadFileManager::CreateDownloadFile, |
| 378 file_manager_, base::Passed(info.Pass()), | 378 file_manager_, base::Passed(info.Pass()), |
| 379 base::Passed(stream.Pass()), make_scoped_refptr(this), | 379 base::Passed(stream.Pass()), make_scoped_refptr(this), |
| 380 (delegate_ && delegate_->GenerateFileHash()), bound_net_log, | 380 (delegate_ && delegate_->GenerateFileHash()), bound_net_log, |
| 381 callback)); | 381 callback)); |
| 382 | 382 |
| 383 return download_id; | 383 return GetDownload(download_id.local()); |
| 384 } | 384 } |
| 385 | 385 |
| 386 void DownloadManagerImpl::OnDownloadFileCreated( | 386 void DownloadManagerImpl::OnDownloadFileCreated( |
| 387 int32 download_id, content::DownloadInterruptReason reason) { | 387 int32 download_id, content::DownloadInterruptReason reason) { |
| 388 if (reason != content::DOWNLOAD_INTERRUPT_REASON_NONE) { | 388 if (reason != content::DOWNLOAD_INTERRUPT_REASON_NONE) { |
| 389 OnDownloadInterrupted(download_id, reason); | 389 OnDownloadInterrupted(download_id, reason); |
| 390 // TODO(rdsmith): It makes no sense to continue along the | 390 // TODO(rdsmith): It makes no sense to continue along the |
| 391 // regular download path after we've gotten an error. But it's | 391 // regular download path after we've gotten an error. But it's |
| 392 // the way the code has historically worked, and this allows us | 392 // the way the code has historically worked, and this allows us |
| 393 // to get the download persisted and observers of the download manager | 393 // to get the download persisted and observers of the download manager |
| (...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1039 void DownloadManagerImpl::DownloadRenamedToFinalName( | 1039 void DownloadManagerImpl::DownloadRenamedToFinalName( |
| 1040 DownloadItemImpl* download) { | 1040 DownloadItemImpl* download) { |
| 1041 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1041 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1042 // If the rename failed, we receive an OnDownloadInterrupted() call before we | 1042 // If the rename failed, we receive an OnDownloadInterrupted() call before we |
| 1043 // receive the DownloadRenamedToFinalName() call. | 1043 // receive the DownloadRenamedToFinalName() call. |
| 1044 if (delegate_) { | 1044 if (delegate_) { |
| 1045 delegate_->UpdatePathForItemInPersistentStore( | 1045 delegate_->UpdatePathForItemInPersistentStore( |
| 1046 download, download->GetFullPath()); | 1046 download, download->GetFullPath()); |
| 1047 } | 1047 } |
| 1048 } | 1048 } |
| OLD | NEW |