| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 ~DownloadItemFactoryImpl() override {} | 112 ~DownloadItemFactoryImpl() override {} |
| 113 | 113 |
| 114 DownloadItemImpl* CreatePersistedItem( | 114 DownloadItemImpl* CreatePersistedItem( |
| 115 DownloadItemImplDelegate* delegate, | 115 DownloadItemImplDelegate* delegate, |
| 116 const std::string& guid, | 116 const std::string& guid, |
| 117 uint32_t download_id, | 117 uint32_t download_id, |
| 118 const base::FilePath& current_path, | 118 const base::FilePath& current_path, |
| 119 const base::FilePath& target_path, | 119 const base::FilePath& target_path, |
| 120 const std::vector<GURL>& url_chain, | 120 const std::vector<GURL>& url_chain, |
| 121 const GURL& referrer_url, | 121 const GURL& referrer_url, |
| 122 const GURL& tab_url, |
| 123 const GURL& tab_refererr_url, |
| 122 const std::string& mime_type, | 124 const std::string& mime_type, |
| 123 const std::string& original_mime_type, | 125 const std::string& original_mime_type, |
| 124 const base::Time& start_time, | 126 const base::Time& start_time, |
| 125 const base::Time& end_time, | 127 const base::Time& end_time, |
| 126 const std::string& etag, | 128 const std::string& etag, |
| 127 const std::string& last_modified, | 129 const std::string& last_modified, |
| 128 int64_t received_bytes, | 130 int64_t received_bytes, |
| 129 int64_t total_bytes, | 131 int64_t total_bytes, |
| 130 const std::string& hash, | 132 const std::string& hash, |
| 131 DownloadItem::DownloadState state, | 133 DownloadItem::DownloadState state, |
| 132 DownloadDangerType danger_type, | 134 DownloadDangerType danger_type, |
| 133 DownloadInterruptReason interrupt_reason, | 135 DownloadInterruptReason interrupt_reason, |
| 134 bool opened, | 136 bool opened, |
| 135 const net::BoundNetLog& bound_net_log) override { | 137 const net::BoundNetLog& bound_net_log) override { |
| 136 return new DownloadItemImpl(delegate, | 138 return new DownloadItemImpl( |
| 137 guid, | 139 delegate, guid, download_id, current_path, target_path, url_chain, |
| 138 download_id, | 140 referrer_url, tab_url, tab_refererr_url, mime_type, original_mime_type, |
| 139 current_path, | 141 start_time, end_time, etag, last_modified, received_bytes, total_bytes, |
| 140 target_path, | 142 hash, state, danger_type, interrupt_reason, opened, bound_net_log); |
| 141 url_chain, | |
| 142 referrer_url, | |
| 143 mime_type, | |
| 144 original_mime_type, | |
| 145 start_time, | |
| 146 end_time, | |
| 147 etag, | |
| 148 last_modified, | |
| 149 received_bytes, | |
| 150 total_bytes, | |
| 151 hash, | |
| 152 state, | |
| 153 danger_type, | |
| 154 interrupt_reason, | |
| 155 opened, | |
| 156 bound_net_log); | |
| 157 } | 143 } |
| 158 | 144 |
| 159 DownloadItemImpl* CreateActiveItem( | 145 DownloadItemImpl* CreateActiveItem( |
| 160 DownloadItemImplDelegate* delegate, | 146 DownloadItemImplDelegate* delegate, |
| 161 uint32_t download_id, | 147 uint32_t download_id, |
| 162 const DownloadCreateInfo& info, | 148 const DownloadCreateInfo& info, |
| 163 const net::BoundNetLog& bound_net_log) override { | 149 const net::BoundNetLog& bound_net_log) override { |
| 164 return new DownloadItemImpl(delegate, download_id, info, bound_net_log); | 150 return new DownloadItemImpl(delegate, download_id, info, bound_net_log); |
| 165 } | 151 } |
| 166 | 152 |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 observers_.RemoveObserver(observer); | 596 observers_.RemoveObserver(observer); |
| 611 } | 597 } |
| 612 | 598 |
| 613 DownloadItem* DownloadManagerImpl::CreateDownloadItem( | 599 DownloadItem* DownloadManagerImpl::CreateDownloadItem( |
| 614 const std::string& guid, | 600 const std::string& guid, |
| 615 uint32_t id, | 601 uint32_t id, |
| 616 const base::FilePath& current_path, | 602 const base::FilePath& current_path, |
| 617 const base::FilePath& target_path, | 603 const base::FilePath& target_path, |
| 618 const std::vector<GURL>& url_chain, | 604 const std::vector<GURL>& url_chain, |
| 619 const GURL& referrer_url, | 605 const GURL& referrer_url, |
| 606 const GURL& tab_url, |
| 607 const GURL& tab_refererr_url, |
| 620 const std::string& mime_type, | 608 const std::string& mime_type, |
| 621 const std::string& original_mime_type, | 609 const std::string& original_mime_type, |
| 622 const base::Time& start_time, | 610 const base::Time& start_time, |
| 623 const base::Time& end_time, | 611 const base::Time& end_time, |
| 624 const std::string& etag, | 612 const std::string& etag, |
| 625 const std::string& last_modified, | 613 const std::string& last_modified, |
| 626 int64_t received_bytes, | 614 int64_t received_bytes, |
| 627 int64_t total_bytes, | 615 int64_t total_bytes, |
| 628 const std::string& hash, | 616 const std::string& hash, |
| 629 DownloadItem::DownloadState state, | 617 DownloadItem::DownloadState state, |
| 630 DownloadDangerType danger_type, | 618 DownloadDangerType danger_type, |
| 631 DownloadInterruptReason interrupt_reason, | 619 DownloadInterruptReason interrupt_reason, |
| 632 bool opened) { | 620 bool opened) { |
| 633 if (ContainsKey(downloads_, id)) { | 621 if (ContainsKey(downloads_, id)) { |
| 634 NOTREACHED(); | 622 NOTREACHED(); |
| 635 return NULL; | 623 return NULL; |
| 636 } | 624 } |
| 637 DCHECK(!ContainsKey(downloads_by_guid_, guid)); | 625 DCHECK(!ContainsKey(downloads_by_guid_, guid)); |
| 638 DownloadItemImpl* item = item_factory_->CreatePersistedItem( | 626 DownloadItemImpl* item = item_factory_->CreatePersistedItem( |
| 639 this, | 627 this, guid, id, current_path, target_path, url_chain, referrer_url, |
| 640 guid, | 628 tab_url, tab_refererr_url, mime_type, original_mime_type, start_time, |
| 641 id, | 629 end_time, etag, last_modified, received_bytes, total_bytes, hash, state, |
| 642 current_path, | 630 danger_type, interrupt_reason, opened, |
| 643 target_path, | |
| 644 url_chain, | |
| 645 referrer_url, | |
| 646 mime_type, | |
| 647 original_mime_type, | |
| 648 start_time, | |
| 649 end_time, | |
| 650 etag, | |
| 651 last_modified, | |
| 652 received_bytes, | |
| 653 total_bytes, | |
| 654 hash, | |
| 655 state, | |
| 656 danger_type, | |
| 657 interrupt_reason, | |
| 658 opened, | |
| 659 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD)); | 631 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD)); |
| 660 downloads_[id] = item; | 632 downloads_[id] = item; |
| 661 downloads_by_guid_[guid] = item; | 633 downloads_by_guid_[guid] = item; |
| 662 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadCreated(this, item)); | 634 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadCreated(this, item)); |
| 663 DVLOG(20) << __FUNCTION__ << "() download = " << item->DebugString(true); | 635 DVLOG(20) << __FUNCTION__ << "() download = " << item->DebugString(true); |
| 664 return item; | 636 return item; |
| 665 } | 637 } |
| 666 | 638 |
| 667 int DownloadManagerImpl::InProgressCount() const { | 639 int DownloadManagerImpl::InProgressCount() const { |
| 668 int count = 0; | 640 int count = 0; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 if (delegate_) | 690 if (delegate_) |
| 719 delegate_->OpenDownload(download); | 691 delegate_->OpenDownload(download); |
| 720 } | 692 } |
| 721 | 693 |
| 722 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { | 694 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { |
| 723 if (delegate_) | 695 if (delegate_) |
| 724 delegate_->ShowDownloadInShell(download); | 696 delegate_->ShowDownloadInShell(download); |
| 725 } | 697 } |
| 726 | 698 |
| 727 } // namespace content | 699 } // namespace content |
| OLD | NEW |