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