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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 const base::Time& end_time, | 138 const base::Time& end_time, |
139 const std::string& etag, | 139 const std::string& etag, |
140 const std::string& last_modified, | 140 const std::string& last_modified, |
141 int64_t received_bytes, | 141 int64_t received_bytes, |
142 int64_t total_bytes, | 142 int64_t total_bytes, |
143 const std::string& hash, | 143 const std::string& hash, |
144 DownloadItem::DownloadState state, | 144 DownloadItem::DownloadState state, |
145 DownloadDangerType danger_type, | 145 DownloadDangerType danger_type, |
146 DownloadInterruptReason interrupt_reason, | 146 DownloadInterruptReason interrupt_reason, |
147 bool opened, | 147 bool opened, |
| 148 const base::Time& last_access_time, |
148 const std::vector<DownloadItem::ReceivedSlice>& received_slices, | 149 const std::vector<DownloadItem::ReceivedSlice>& received_slices, |
149 const net::NetLogWithSource& net_log) | 150 const net::NetLogWithSource& net_log) |
150 : guid_(base::ToUpperASCII(guid)), | 151 : guid_(base::ToUpperASCII(guid)), |
151 download_id_(download_id), | 152 download_id_(download_id), |
152 target_path_(target_path), | 153 target_path_(target_path), |
153 url_chain_(url_chain), | 154 url_chain_(url_chain), |
154 referrer_url_(referrer_url), | 155 referrer_url_(referrer_url), |
155 site_url_(site_url), | 156 site_url_(site_url), |
156 tab_url_(tab_url), | 157 tab_url_(tab_url), |
157 tab_referrer_url_(tab_refererr_url), | 158 tab_referrer_url_(tab_refererr_url), |
158 mime_type_(mime_type), | 159 mime_type_(mime_type), |
159 original_mime_type_(original_mime_type), | 160 original_mime_type_(original_mime_type), |
160 total_bytes_(total_bytes), | 161 total_bytes_(total_bytes), |
161 last_reason_(interrupt_reason), | 162 last_reason_(interrupt_reason), |
162 start_tick_(base::TimeTicks()), | 163 start_tick_(base::TimeTicks()), |
163 state_(ExternalToInternalState(state)), | 164 state_(ExternalToInternalState(state)), |
164 danger_type_(danger_type), | 165 danger_type_(danger_type), |
165 start_time_(start_time), | 166 start_time_(start_time), |
166 end_time_(end_time), | 167 end_time_(end_time), |
167 delegate_(delegate), | 168 delegate_(delegate), |
168 opened_(opened), | 169 opened_(opened), |
| 170 last_access_time_(last_access_time), |
169 current_path_(current_path), | 171 current_path_(current_path), |
170 received_bytes_(received_bytes), | 172 received_bytes_(received_bytes), |
171 all_data_saved_(state == COMPLETE), | 173 all_data_saved_(state == COMPLETE), |
172 hash_(hash), | 174 hash_(hash), |
173 last_modified_time_(last_modified), | 175 last_modified_time_(last_modified), |
174 etag_(etag), | 176 etag_(etag), |
175 received_slices_(received_slices), | 177 received_slices_(received_slices), |
176 net_log_(net_log), | 178 net_log_(net_log), |
177 weak_ptr_factory_(this) { | 179 weak_ptr_factory_(this) { |
178 delegate_->Attach(); | 180 delegate_->Attach(); |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 if (state_ != COMPLETE_INTERNAL || file_externally_removed_) | 453 if (state_ != COMPLETE_INTERNAL || file_externally_removed_) |
452 return; | 454 return; |
453 | 455 |
454 // Ideally, we want to detect errors in opening and report them, but we | 456 // Ideally, we want to detect errors in opening and report them, but we |
455 // don't generally have the proper interface for that to the external | 457 // don't generally have the proper interface for that to the external |
456 // program that opens the file. So instead we spawn a check to update | 458 // program that opens the file. So instead we spawn a check to update |
457 // the UI if the file has been deleted in parallel with the open. | 459 // the UI if the file has been deleted in parallel with the open. |
458 delegate_->CheckForFileRemoval(this); | 460 delegate_->CheckForFileRemoval(this); |
459 RecordOpen(GetEndTime(), !GetOpened()); | 461 RecordOpen(GetEndTime(), !GetOpened()); |
460 opened_ = true; | 462 opened_ = true; |
| 463 last_access_time_ = base::Time::Now(); |
461 for (auto& observer : observers_) | 464 for (auto& observer : observers_) |
462 observer.OnDownloadOpened(this); | 465 observer.OnDownloadOpened(this); |
463 delegate_->OpenDownload(this); | 466 delegate_->OpenDownload(this); |
464 } | 467 } |
465 | 468 |
466 void DownloadItemImpl::ShowDownloadInShell() { | 469 void DownloadItemImpl::ShowDownloadInShell() { |
467 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 470 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
468 | 471 |
469 delegate_->ShowDownloadInShell(this); | 472 delegate_->ShowDownloadInShell(this); |
470 } | 473 } |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 } | 767 } |
765 | 768 |
766 bool DownloadItemImpl::GetAutoOpened() { | 769 bool DownloadItemImpl::GetAutoOpened() { |
767 return auto_opened_; | 770 return auto_opened_; |
768 } | 771 } |
769 | 772 |
770 bool DownloadItemImpl::GetOpened() const { | 773 bool DownloadItemImpl::GetOpened() const { |
771 return opened_; | 774 return opened_; |
772 } | 775 } |
773 | 776 |
| 777 base::Time DownloadItemImpl::GetLastAccessTime() const { |
| 778 return last_access_time_; |
| 779 } |
| 780 |
774 BrowserContext* DownloadItemImpl::GetBrowserContext() const { | 781 BrowserContext* DownloadItemImpl::GetBrowserContext() const { |
775 return delegate_->GetBrowserContext(); | 782 return delegate_->GetBrowserContext(); |
776 } | 783 } |
777 | 784 |
778 WebContents* DownloadItemImpl::GetWebContents() const { | 785 WebContents* DownloadItemImpl::GetWebContents() const { |
779 // TODO(rdsmith): Remove null check after removing GetWebContents() from | 786 // TODO(rdsmith): Remove null check after removing GetWebContents() from |
780 // paths that might be used by DownloadItems created from history import. | 787 // paths that might be used by DownloadItems created from history import. |
781 // Currently such items have null request_handle_s, where other items | 788 // Currently such items have null request_handle_s, where other items |
782 // (regular and SavePackage downloads) have actual objects off the pointer. | 789 // (regular and SavePackage downloads) have actual objects off the pointer. |
783 if (request_handle_) | 790 if (request_handle_) |
(...skipping 19 matching lines...) Expand all Loading... |
803 } | 810 } |
804 | 811 |
805 void DownloadItemImpl::SetOpenWhenComplete(bool open) { | 812 void DownloadItemImpl::SetOpenWhenComplete(bool open) { |
806 open_when_complete_ = open; | 813 open_when_complete_ = open; |
807 } | 814 } |
808 | 815 |
809 void DownloadItemImpl::SetOpened(bool opened) { | 816 void DownloadItemImpl::SetOpened(bool opened) { |
810 opened_ = opened; | 817 opened_ = opened; |
811 } | 818 } |
812 | 819 |
| 820 void DownloadItemImpl::SetLastAccessTime(const base::Time& last_access_time) { |
| 821 last_access_time_ = last_access_time; |
| 822 UpdateObservers(); |
| 823 } |
| 824 |
813 void DownloadItemImpl::SetDisplayName(const base::FilePath& name) { | 825 void DownloadItemImpl::SetDisplayName(const base::FilePath& name) { |
814 display_name_ = name; | 826 display_name_ = name; |
815 } | 827 } |
816 | 828 |
817 std::string DownloadItemImpl::DebugString(bool verbose) const { | 829 std::string DownloadItemImpl::DebugString(bool verbose) const { |
818 std::string description = | 830 std::string description = |
819 base::StringPrintf("{ id = %d" | 831 base::StringPrintf("{ id = %d" |
820 " state = %s", | 832 " state = %s", |
821 download_id_, | 833 download_id_, |
822 DebugDownloadStateString(state_)); | 834 DebugDownloadStateString(state_)); |
(...skipping 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2128 case RESUME_MODE_USER_CONTINUE: | 2140 case RESUME_MODE_USER_CONTINUE: |
2129 return "USER_CONTINUE"; | 2141 return "USER_CONTINUE"; |
2130 case RESUME_MODE_USER_RESTART: | 2142 case RESUME_MODE_USER_RESTART: |
2131 return "USER_RESTART"; | 2143 return "USER_RESTART"; |
2132 } | 2144 } |
2133 NOTREACHED() << "Unknown resume mode " << mode; | 2145 NOTREACHED() << "Unknown resume mode " << mode; |
2134 return "unknown"; | 2146 return "unknown"; |
2135 } | 2147 } |
2136 | 2148 |
2137 } // namespace content | 2149 } // namespace content |
OLD | NEW |