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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 | 232 |
233 DownloadManagerImpl::DownloadManagerImpl( | 233 DownloadManagerImpl::DownloadManagerImpl( |
234 net::NetLog* net_log, | 234 net::NetLog* net_log, |
235 BrowserContext* browser_context) | 235 BrowserContext* browser_context) |
236 : item_factory_(new DownloadItemFactoryImpl()), | 236 : item_factory_(new DownloadItemFactoryImpl()), |
237 file_factory_(new DownloadFileFactory()), | 237 file_factory_(new DownloadFileFactory()), |
238 history_size_(0), | 238 history_size_(0), |
239 shutdown_needed_(true), | 239 shutdown_needed_(true), |
240 browser_context_(browser_context), | 240 browser_context_(browser_context), |
241 delegate_(NULL), | 241 delegate_(NULL), |
242 net_log_(net_log) { | 242 net_log_(net_log), |
| 243 weak_factory_(this) { |
243 DCHECK(browser_context); | 244 DCHECK(browser_context); |
244 } | 245 } |
245 | 246 |
246 DownloadManagerImpl::~DownloadManagerImpl() { | 247 DownloadManagerImpl::~DownloadManagerImpl() { |
247 DCHECK(!shutdown_needed_); | 248 DCHECK(!shutdown_needed_); |
248 } | 249 } |
249 | 250 |
250 DownloadItemImpl* DownloadManagerImpl::CreateActiveItem( | 251 DownloadItemImpl* DownloadManagerImpl::CreateActiveItem( |
251 DownloadId id, const DownloadCreateInfo& info) { | 252 DownloadId id, const DownloadCreateInfo& info) { |
252 net::BoundNetLog bound_net_log = | 253 net::BoundNetLog bound_net_log = |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 } | 441 } |
441 | 442 |
442 void DownloadManagerImpl::CheckForFileRemoval(DownloadItemImpl* download_item) { | 443 void DownloadManagerImpl::CheckForFileRemoval(DownloadItemImpl* download_item) { |
443 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 444 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
444 if (download_item->IsComplete() && | 445 if (download_item->IsComplete() && |
445 !download_item->GetFileExternallyRemoved() && | 446 !download_item->GetFileExternallyRemoved() && |
446 delegate_) { | 447 delegate_) { |
447 delegate_->CheckForFileExistence( | 448 delegate_->CheckForFileExistence( |
448 download_item, | 449 download_item, |
449 base::Bind(&DownloadManagerImpl::OnFileExistenceChecked, | 450 base::Bind(&DownloadManagerImpl::OnFileExistenceChecked, |
450 this, download_item->GetId())); | 451 weak_factory_.GetWeakPtr(), download_item->GetId())); |
451 } | 452 } |
452 } | 453 } |
453 | 454 |
454 void DownloadManagerImpl::OnFileExistenceChecked(int32 download_id, | 455 void DownloadManagerImpl::OnFileExistenceChecked(int32 download_id, |
455 bool result) { | 456 bool result) { |
456 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 457 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
457 if (!result) { // File does not exist. | 458 if (!result) { // File does not exist. |
458 if (ContainsKey(downloads_, download_id)) | 459 if (ContainsKey(downloads_, download_id)) |
459 downloads_[download_id]->OnDownloadedFileRemoved(); | 460 downloads_[download_id]->OnDownloadedFileRemoved(); |
460 } | 461 } |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 if (delegate_) | 664 if (delegate_) |
664 delegate_->OpenDownload(download); | 665 delegate_->OpenDownload(download); |
665 } | 666 } |
666 | 667 |
667 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { | 668 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { |
668 if (delegate_) | 669 if (delegate_) |
669 delegate_->ShowDownloadInShell(download); | 670 delegate_->ShowDownloadInShell(download); |
670 } | 671 } |
671 | 672 |
672 } // namespace content | 673 } // namespace content |
OLD | NEW |