| 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 // File method ordering: Methods in this file are in the same order as | 5 // File method ordering: Methods in this file are in the same order as |
| 6 // in download_item_impl.h, with the following exception: The public | 6 // in download_item_impl.h, with the following exception: The public |
| 7 // interface Start is placed in chronological order with the other | 7 // interface Start is placed in chronological order with the other |
| 8 // (private) routines that together define a DownloadItem's state | 8 // (private) routines that together define a DownloadItem's state |
| 9 // transitions as the download progresses. See "Download progression | 9 // transitions as the download progresses. See "Download progression |
| 10 // cascade" later in this file. | 10 // cascade" later in this file. |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 const base::Time& end_time, | 137 const base::Time& end_time, |
| 138 const std::string& etag, | 138 const std::string& etag, |
| 139 const std::string& last_modified, | 139 const std::string& last_modified, |
| 140 int64_t received_bytes, | 140 int64_t received_bytes, |
| 141 int64_t total_bytes, | 141 int64_t total_bytes, |
| 142 const std::string& hash, | 142 const std::string& hash, |
| 143 DownloadItem::DownloadState state, | 143 DownloadItem::DownloadState state, |
| 144 DownloadDangerType danger_type, | 144 DownloadDangerType danger_type, |
| 145 DownloadInterruptReason interrupt_reason, | 145 DownloadInterruptReason interrupt_reason, |
| 146 bool opened, | 146 bool opened, |
| 147 const base::Time& last_access_time, |
| 147 const net::NetLogWithSource& net_log) | 148 const net::NetLogWithSource& net_log) |
| 148 : guid_(base::ToUpperASCII(guid)), | 149 : guid_(base::ToUpperASCII(guid)), |
| 149 download_id_(download_id), | 150 download_id_(download_id), |
| 150 target_path_(target_path), | 151 target_path_(target_path), |
| 151 url_chain_(url_chain), | 152 url_chain_(url_chain), |
| 152 referrer_url_(referrer_url), | 153 referrer_url_(referrer_url), |
| 153 site_url_(site_url), | 154 site_url_(site_url), |
| 154 tab_url_(tab_url), | 155 tab_url_(tab_url), |
| 155 tab_referrer_url_(tab_refererr_url), | 156 tab_referrer_url_(tab_refererr_url), |
| 156 mime_type_(mime_type), | 157 mime_type_(mime_type), |
| 157 original_mime_type_(original_mime_type), | 158 original_mime_type_(original_mime_type), |
| 158 total_bytes_(total_bytes), | 159 total_bytes_(total_bytes), |
| 159 last_reason_(interrupt_reason), | 160 last_reason_(interrupt_reason), |
| 160 start_tick_(base::TimeTicks()), | 161 start_tick_(base::TimeTicks()), |
| 161 state_(ExternalToInternalState(state)), | 162 state_(ExternalToInternalState(state)), |
| 162 danger_type_(danger_type), | 163 danger_type_(danger_type), |
| 163 start_time_(start_time), | 164 start_time_(start_time), |
| 164 end_time_(end_time), | 165 end_time_(end_time), |
| 165 delegate_(delegate), | 166 delegate_(delegate), |
| 166 opened_(opened), | 167 opened_(opened), |
| 168 last_access_time_(last_access_time), |
| 167 current_path_(current_path), | 169 current_path_(current_path), |
| 168 received_bytes_(received_bytes), | 170 received_bytes_(received_bytes), |
| 169 all_data_saved_(state == COMPLETE), | 171 all_data_saved_(state == COMPLETE), |
| 170 hash_(hash), | 172 hash_(hash), |
| 171 last_modified_time_(last_modified), | 173 last_modified_time_(last_modified), |
| 172 etag_(etag), | 174 etag_(etag), |
| 173 net_log_(net_log), | 175 net_log_(net_log), |
| 174 weak_ptr_factory_(this) { | 176 weak_ptr_factory_(this) { |
| 175 delegate_->Attach(); | 177 delegate_->Attach(); |
| 176 DCHECK(state_ == COMPLETE_INTERNAL || state_ == INTERRUPTED_INTERNAL || | 178 DCHECK(state_ == COMPLETE_INTERNAL || state_ == INTERRUPTED_INTERNAL || |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 if (state_ != COMPLETE_INTERNAL || file_externally_removed_) | 450 if (state_ != COMPLETE_INTERNAL || file_externally_removed_) |
| 449 return; | 451 return; |
| 450 | 452 |
| 451 // Ideally, we want to detect errors in opening and report them, but we | 453 // Ideally, we want to detect errors in opening and report them, but we |
| 452 // don't generally have the proper interface for that to the external | 454 // don't generally have the proper interface for that to the external |
| 453 // program that opens the file. So instead we spawn a check to update | 455 // program that opens the file. So instead we spawn a check to update |
| 454 // the UI if the file has been deleted in parallel with the open. | 456 // the UI if the file has been deleted in parallel with the open. |
| 455 delegate_->CheckForFileRemoval(this); | 457 delegate_->CheckForFileRemoval(this); |
| 456 RecordOpen(GetEndTime(), !GetOpened()); | 458 RecordOpen(GetEndTime(), !GetOpened()); |
| 457 opened_ = true; | 459 opened_ = true; |
| 460 last_access_time_ = base::Time::Now(); |
| 458 for (auto& observer : observers_) | 461 for (auto& observer : observers_) |
| 459 observer.OnDownloadOpened(this); | 462 observer.OnDownloadOpened(this); |
| 460 delegate_->OpenDownload(this); | 463 delegate_->OpenDownload(this); |
| 461 } | 464 } |
| 462 | 465 |
| 463 void DownloadItemImpl::ShowDownloadInShell() { | 466 void DownloadItemImpl::ShowDownloadInShell() { |
| 464 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 467 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 465 | 468 |
| 466 delegate_->ShowDownloadInShell(this); | 469 delegate_->ShowDownloadInShell(this); |
| 467 } | 470 } |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 } | 759 } |
| 757 | 760 |
| 758 bool DownloadItemImpl::GetAutoOpened() { | 761 bool DownloadItemImpl::GetAutoOpened() { |
| 759 return auto_opened_; | 762 return auto_opened_; |
| 760 } | 763 } |
| 761 | 764 |
| 762 bool DownloadItemImpl::GetOpened() const { | 765 bool DownloadItemImpl::GetOpened() const { |
| 763 return opened_; | 766 return opened_; |
| 764 } | 767 } |
| 765 | 768 |
| 769 base::Time DownloadItemImpl::GetLastAccessTime() const { |
| 770 return last_access_time_; |
| 771 } |
| 772 |
| 766 BrowserContext* DownloadItemImpl::GetBrowserContext() const { | 773 BrowserContext* DownloadItemImpl::GetBrowserContext() const { |
| 767 return delegate_->GetBrowserContext(); | 774 return delegate_->GetBrowserContext(); |
| 768 } | 775 } |
| 769 | 776 |
| 770 WebContents* DownloadItemImpl::GetWebContents() const { | 777 WebContents* DownloadItemImpl::GetWebContents() const { |
| 771 // TODO(rdsmith): Remove null check after removing GetWebContents() from | 778 // TODO(rdsmith): Remove null check after removing GetWebContents() from |
| 772 // paths that might be used by DownloadItems created from history import. | 779 // paths that might be used by DownloadItems created from history import. |
| 773 // Currently such items have null request_handle_s, where other items | 780 // Currently such items have null request_handle_s, where other items |
| 774 // (regular and SavePackage downloads) have actual objects off the pointer. | 781 // (regular and SavePackage downloads) have actual objects off the pointer. |
| 775 if (request_handle_) | 782 if (request_handle_) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 795 } | 802 } |
| 796 | 803 |
| 797 void DownloadItemImpl::SetOpenWhenComplete(bool open) { | 804 void DownloadItemImpl::SetOpenWhenComplete(bool open) { |
| 798 open_when_complete_ = open; | 805 open_when_complete_ = open; |
| 799 } | 806 } |
| 800 | 807 |
| 801 void DownloadItemImpl::SetOpened(bool opened) { | 808 void DownloadItemImpl::SetOpened(bool opened) { |
| 802 opened_ = opened; | 809 opened_ = opened; |
| 803 } | 810 } |
| 804 | 811 |
| 812 void DownloadItemImpl::SetLastAccessTime(const base::Time& last_access_time) { |
| 813 last_access_time_ = last_access_time; |
| 814 UpdateObservers(); |
| 815 } |
| 816 |
| 805 void DownloadItemImpl::SetDisplayName(const base::FilePath& name) { | 817 void DownloadItemImpl::SetDisplayName(const base::FilePath& name) { |
| 806 display_name_ = name; | 818 display_name_ = name; |
| 807 } | 819 } |
| 808 | 820 |
| 809 std::string DownloadItemImpl::DebugString(bool verbose) const { | 821 std::string DownloadItemImpl::DebugString(bool verbose) const { |
| 810 std::string description = | 822 std::string description = |
| 811 base::StringPrintf("{ id = %d" | 823 base::StringPrintf("{ id = %d" |
| 812 " state = %s", | 824 " state = %s", |
| 813 download_id_, | 825 download_id_, |
| 814 DebugDownloadStateString(state_)); | 826 DebugDownloadStateString(state_)); |
| (...skipping 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2120 case RESUME_MODE_USER_CONTINUE: | 2132 case RESUME_MODE_USER_CONTINUE: |
| 2121 return "USER_CONTINUE"; | 2133 return "USER_CONTINUE"; |
| 2122 case RESUME_MODE_USER_RESTART: | 2134 case RESUME_MODE_USER_RESTART: |
| 2123 return "USER_RESTART"; | 2135 return "USER_RESTART"; |
| 2124 } | 2136 } |
| 2125 NOTREACHED() << "Unknown resume mode " << mode; | 2137 NOTREACHED() << "Unknown resume mode " << mode; |
| 2126 return "unknown"; | 2138 return "unknown"; |
| 2127 } | 2139 } |
| 2128 | 2140 |
| 2129 } // namespace content | 2141 } // namespace content |
| OLD | NEW |