| 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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 | 318 |
| 319 void DownloadManagerImpl::SetDelegate(DownloadManagerDelegate* delegate) { | 319 void DownloadManagerImpl::SetDelegate(DownloadManagerDelegate* delegate) { |
| 320 delegate_ = delegate; | 320 delegate_ = delegate; |
| 321 } | 321 } |
| 322 | 322 |
| 323 DownloadManagerDelegate* DownloadManagerImpl::GetDelegate() const { | 323 DownloadManagerDelegate* DownloadManagerImpl::GetDelegate() const { |
| 324 return delegate_; | 324 return delegate_; |
| 325 } | 325 } |
| 326 | 326 |
| 327 void DownloadManagerImpl::Shutdown() { | 327 void DownloadManagerImpl::Shutdown() { |
| 328 VLOG(20) << __FUNCTION__ << "()" | 328 DVLOG(20) << __FUNCTION__ << "()" |
| 329 << " shutdown_needed_ = " << shutdown_needed_; | 329 << " shutdown_needed_ = " << shutdown_needed_; |
| 330 if (!shutdown_needed_) | 330 if (!shutdown_needed_) |
| 331 return; | 331 return; |
| 332 shutdown_needed_ = false; | 332 shutdown_needed_ = false; |
| 333 | 333 |
| 334 FOR_EACH_OBSERVER(Observer, observers_, ManagerGoingDown(this)); | 334 FOR_EACH_OBSERVER(Observer, observers_, ManagerGoingDown(this)); |
| 335 // TODO(benjhayden): Consider clearing observers_. | 335 // TODO(benjhayden): Consider clearing observers_. |
| 336 | 336 |
| 337 // If there are in-progress downloads, cancel them. This also goes for | 337 // If there are in-progress downloads, cancel them. This also goes for |
| 338 // dangerous downloads which will remain in history if they aren't explicitly | 338 // dangerous downloads which will remain in history if they aren't explicitly |
| 339 // accepted or discarded. Canceling will remove the intermediate download | 339 // accepted or discarded. Canceling will remove the intermediate download |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 last_modified, | 655 last_modified, |
| 656 received_bytes, | 656 received_bytes, |
| 657 total_bytes, | 657 total_bytes, |
| 658 state, | 658 state, |
| 659 danger_type, | 659 danger_type, |
| 660 interrupt_reason, | 660 interrupt_reason, |
| 661 opened, | 661 opened, |
| 662 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD)); | 662 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD)); |
| 663 downloads_[id] = item; | 663 downloads_[id] = item; |
| 664 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadCreated(this, item)); | 664 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadCreated(this, item)); |
| 665 VLOG(20) << __FUNCTION__ << "() download = " << item->DebugString(true); | 665 DVLOG(20) << __FUNCTION__ << "() download = " << item->DebugString(true); |
| 666 return item; | 666 return item; |
| 667 } | 667 } |
| 668 | 668 |
| 669 int DownloadManagerImpl::InProgressCount() const { | 669 int DownloadManagerImpl::InProgressCount() const { |
| 670 int count = 0; | 670 int count = 0; |
| 671 for (DownloadMap::const_iterator it = downloads_.begin(); | 671 for (DownloadMap::const_iterator it = downloads_.begin(); |
| 672 it != downloads_.end(); ++it) { | 672 it != downloads_.end(); ++it) { |
| 673 if (it->second->GetState() == DownloadItem::IN_PROGRESS) | 673 if (it->second->GetState() == DownloadItem::IN_PROGRESS) |
| 674 ++count; | 674 ++count; |
| 675 } | 675 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 if (delegate_) | 717 if (delegate_) |
| 718 delegate_->OpenDownload(download); | 718 delegate_->OpenDownload(download); |
| 719 } | 719 } |
| 720 | 720 |
| 721 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { | 721 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { |
| 722 if (delegate_) | 722 if (delegate_) |
| 723 delegate_->ShowDownloadInShell(download); | 723 delegate_->ShowDownloadInShell(download); |
| 724 } | 724 } |
| 725 | 725 |
| 726 } // namespace content | 726 } // namespace content |
| OLD | NEW |