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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 161 } |
162 | 162 |
163 class DownloadItemFactoryImpl : public DownloadItemFactory { | 163 class DownloadItemFactoryImpl : public DownloadItemFactory { |
164 public: | 164 public: |
165 DownloadItemFactoryImpl() {} | 165 DownloadItemFactoryImpl() {} |
166 virtual ~DownloadItemFactoryImpl() {} | 166 virtual ~DownloadItemFactoryImpl() {} |
167 | 167 |
168 virtual DownloadItemImpl* CreatePersistedItem( | 168 virtual DownloadItemImpl* CreatePersistedItem( |
169 DownloadItemImplDelegate* delegate, | 169 DownloadItemImplDelegate* delegate, |
170 DownloadId download_id, | 170 DownloadId download_id, |
171 const FilePath& path, | 171 const FilePath& current_path, |
172 const GURL& url, | 172 const FilePath& target_path, |
| 173 const std::vector<GURL>& url_chain, |
173 const GURL& referrer_url, | 174 const GURL& referrer_url, |
174 const base::Time& start_time, | 175 const base::Time& start_time, |
175 const base::Time& end_time, | 176 const base::Time& end_time, |
176 int64 received_bytes, | 177 int64 received_bytes, |
177 int64 total_bytes, | 178 int64 total_bytes, |
178 DownloadItem::DownloadState state, | 179 DownloadItem::DownloadState state, |
| 180 DownloadDangerType danger_type, |
| 181 DownloadInterruptReason interrupt_reason, |
179 bool opened, | 182 bool opened, |
180 const net::BoundNetLog& bound_net_log) OVERRIDE { | 183 const net::BoundNetLog& bound_net_log) OVERRIDE { |
181 return new DownloadItemImpl( | 184 return new DownloadItemImpl( |
182 delegate, | 185 delegate, |
183 download_id, | 186 download_id, |
184 path, | 187 current_path, |
185 url, | 188 target_path, |
| 189 url_chain, |
186 referrer_url, | 190 referrer_url, |
187 start_time, | 191 start_time, |
188 end_time, | 192 end_time, |
189 received_bytes, | 193 received_bytes, |
190 total_bytes, | 194 total_bytes, |
191 state, | 195 state, |
| 196 danger_type, |
| 197 interrupt_reason, |
192 opened, | 198 opened, |
193 bound_net_log); | 199 bound_net_log); |
194 } | 200 } |
195 | 201 |
196 virtual DownloadItemImpl* CreateActiveItem( | 202 virtual DownloadItemImpl* CreateActiveItem( |
197 DownloadItemImplDelegate* delegate, | 203 DownloadItemImplDelegate* delegate, |
198 const DownloadCreateInfo& info, | 204 const DownloadCreateInfo& info, |
199 const net::BoundNetLog& bound_net_log) OVERRIDE { | 205 const net::BoundNetLog& bound_net_log) OVERRIDE { |
200 return new DownloadItemImpl(delegate, info, bound_net_log); | 206 return new DownloadItemImpl(delegate, info, bound_net_log); |
201 } | 207 } |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 | 589 |
584 void DownloadManagerImpl::AddObserver(Observer* observer) { | 590 void DownloadManagerImpl::AddObserver(Observer* observer) { |
585 observers_.AddObserver(observer); | 591 observers_.AddObserver(observer); |
586 } | 592 } |
587 | 593 |
588 void DownloadManagerImpl::RemoveObserver(Observer* observer) { | 594 void DownloadManagerImpl::RemoveObserver(Observer* observer) { |
589 observers_.RemoveObserver(observer); | 595 observers_.RemoveObserver(observer); |
590 } | 596 } |
591 | 597 |
592 DownloadItem* DownloadManagerImpl::CreateDownloadItem( | 598 DownloadItem* DownloadManagerImpl::CreateDownloadItem( |
593 const FilePath& path, | 599 const FilePath& current_path, |
594 const GURL& url, | 600 const FilePath& target_path, |
| 601 const std::vector<GURL>& url_chain, |
595 const GURL& referrer_url, | 602 const GURL& referrer_url, |
596 const base::Time& start_time, | 603 const base::Time& start_time, |
597 const base::Time& end_time, | 604 const base::Time& end_time, |
598 int64 received_bytes, | 605 int64 received_bytes, |
599 int64 total_bytes, | 606 int64 total_bytes, |
600 DownloadItem::DownloadState state, | 607 DownloadItem::DownloadState state, |
| 608 DownloadDangerType danger_type, |
| 609 DownloadInterruptReason interrupt_reason, |
601 bool opened) { | 610 bool opened) { |
602 DownloadItemImpl* item = item_factory_->CreatePersistedItem( | 611 DownloadItemImpl* item = item_factory_->CreatePersistedItem( |
603 this, | 612 this, |
604 GetNextId(), | 613 GetNextId(), |
605 path, | 614 current_path, |
606 url, | 615 target_path, |
| 616 url_chain, |
607 referrer_url, | 617 referrer_url, |
608 start_time, | 618 start_time, |
609 end_time, | 619 end_time, |
610 received_bytes, | 620 received_bytes, |
611 total_bytes, | 621 total_bytes, |
612 state, | 622 state, |
| 623 danger_type, |
| 624 interrupt_reason, |
613 opened, | 625 opened, |
614 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD)); | 626 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD)); |
615 DCHECK(!ContainsKey(downloads_, item->GetId())); | 627 DCHECK(!ContainsKey(downloads_, item->GetId())); |
616 downloads_[item->GetId()] = item; | 628 downloads_[item->GetId()] = item; |
617 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadCreated(this, item)); | 629 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadCreated(this, item)); |
618 VLOG(20) << __FUNCTION__ << "() download = " << item->DebugString(true); | 630 VLOG(20) << __FUNCTION__ << "() download = " << item->DebugString(true); |
619 return item; | 631 return item; |
620 } | 632 } |
621 | 633 |
622 // TODO(asanka) Move into an observer. | 634 // TODO(asanka) Move into an observer. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 if (delegate_) | 681 if (delegate_) |
670 delegate_->OpenDownload(download); | 682 delegate_->OpenDownload(download); |
671 } | 683 } |
672 | 684 |
673 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { | 685 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { |
674 if (delegate_) | 686 if (delegate_) |
675 delegate_->ShowDownloadInShell(download); | 687 delegate_->ShowDownloadInShell(download); |
676 } | 688 } |
677 | 689 |
678 } // namespace content | 690 } // namespace content |
OLD | NEW |