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 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 } | 174 } |
175 }; | 175 }; |
176 | 176 |
177 } // namespace | 177 } // namespace |
178 | 178 |
179 DownloadManagerImpl::DownloadManagerImpl(net::NetLog* net_log, | 179 DownloadManagerImpl::DownloadManagerImpl(net::NetLog* net_log, |
180 BrowserContext* browser_context) | 180 BrowserContext* browser_context) |
181 : item_factory_(new DownloadItemFactoryImpl()), | 181 : item_factory_(new DownloadItemFactoryImpl()), |
182 file_factory_(new DownloadFileFactory()), | 182 file_factory_(new DownloadFileFactory()), |
183 shutdown_needed_(true), | 183 shutdown_needed_(true), |
| 184 initialized_(false), |
184 browser_context_(browser_context), | 185 browser_context_(browser_context), |
185 delegate_(nullptr), | 186 delegate_(nullptr), |
186 net_log_(net_log), | 187 net_log_(net_log), |
187 weak_factory_(this) { | 188 weak_factory_(this) { |
188 DCHECK(browser_context); | 189 DCHECK(browser_context); |
189 } | 190 } |
190 | 191 |
191 DownloadManagerImpl::~DownloadManagerImpl() { | 192 DownloadManagerImpl::~DownloadManagerImpl() { |
192 DCHECK(!shutdown_needed_); | 193 DCHECK(!shutdown_needed_); |
193 } | 194 } |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 transient, received_slices, | 668 transient, received_slices, |
668 net::NetLogWithSource::Make(net_log_, net::NetLogSourceType::DOWNLOAD)); | 669 net::NetLogWithSource::Make(net_log_, net::NetLogSourceType::DOWNLOAD)); |
669 downloads_[id] = base::WrapUnique(item); | 670 downloads_[id] = base::WrapUnique(item); |
670 downloads_by_guid_[guid] = item; | 671 downloads_by_guid_[guid] = item; |
671 for (auto& observer : observers_) | 672 for (auto& observer : observers_) |
672 observer.OnDownloadCreated(this, item); | 673 observer.OnDownloadCreated(this, item); |
673 DVLOG(20) << __func__ << "() download = " << item->DebugString(true); | 674 DVLOG(20) << __func__ << "() download = " << item->DebugString(true); |
674 return item; | 675 return item; |
675 } | 676 } |
676 | 677 |
| 678 void DownloadManagerImpl::PostInitialization() { |
| 679 DCHECK(!initialized_); |
| 680 initialized_ = true; |
| 681 for (auto& observer : observers_) |
| 682 observer.OnManagerInitialized(); |
| 683 } |
| 684 |
| 685 bool DownloadManagerImpl::IsManagerInitialized() const { |
| 686 return initialized_; |
| 687 } |
| 688 |
677 int DownloadManagerImpl::InProgressCount() const { | 689 int DownloadManagerImpl::InProgressCount() const { |
678 int count = 0; | 690 int count = 0; |
679 for (const auto& it : downloads_) { | 691 for (const auto& it : downloads_) { |
680 if (it.second->GetState() == DownloadItem::IN_PROGRESS) | 692 if (it.second->GetState() == DownloadItem::IN_PROGRESS) |
681 ++count; | 693 ++count; |
682 } | 694 } |
683 return count; | 695 return count; |
684 } | 696 } |
685 | 697 |
686 int DownloadManagerImpl::NonMaliciousInProgressCount() const { | 698 int DownloadManagerImpl::NonMaliciousInProgressCount() const { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 if (delegate_) | 759 if (delegate_) |
748 delegate_->OpenDownload(download); | 760 delegate_->OpenDownload(download); |
749 } | 761 } |
750 | 762 |
751 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { | 763 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { |
752 if (delegate_) | 764 if (delegate_) |
753 delegate_->ShowDownloadInShell(download); | 765 delegate_->ShowDownloadInShell(download); |
754 } | 766 } |
755 | 767 |
756 } // namespace content | 768 } // namespace content |
OLD | NEW |