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 26 matching lines...) Expand all Loading... | |
203 mime_type_(info.mime_type), | 205 mime_type_(info.mime_type), |
204 original_mime_type_(info.original_mime_type), | 206 original_mime_type_(info.original_mime_type), |
205 remote_address_(info.remote_address), | 207 remote_address_(info.remote_address), |
206 total_bytes_(info.total_bytes), | 208 total_bytes_(info.total_bytes), |
207 last_reason_(info.result), | 209 last_reason_(info.result), |
208 start_tick_(base::TimeTicks::Now()), | 210 start_tick_(base::TimeTicks::Now()), |
209 state_(INITIAL_INTERNAL), | 211 state_(INITIAL_INTERNAL), |
210 start_time_(info.start_time), | 212 start_time_(info.start_time), |
211 delegate_(delegate), | 213 delegate_(delegate), |
212 is_temporary_(!info.save_info->file_path.empty()), | 214 is_temporary_(!info.save_info->file_path.empty()), |
215 last_access_time_(base::Time()), | |
David Trainor- moved to gerrit
2017/02/22 05:56:03
Don't need this
shaktisahu
2017/02/23 06:55:48
Done.
| |
213 last_modified_time_(info.last_modified), | 216 last_modified_time_(info.last_modified), |
214 etag_(info.etag), | 217 etag_(info.etag), |
215 net_log_(net_log), | 218 net_log_(net_log), |
216 weak_ptr_factory_(this) { | 219 weak_ptr_factory_(this) { |
217 delegate_->Attach(); | 220 delegate_->Attach(); |
218 Init(true /* actively downloading */, SRC_ACTIVE_DOWNLOAD); | 221 Init(true /* actively downloading */, SRC_ACTIVE_DOWNLOAD); |
219 | 222 |
220 // Link the event sources. | 223 // Link the event sources. |
221 net_log_.AddEvent( | 224 net_log_.AddEvent( |
222 net::NetLogEventType::DOWNLOAD_URL_REQUEST, | 225 net::NetLogEventType::DOWNLOAD_URL_REQUEST, |
(...skipping 18 matching lines...) Expand all Loading... | |
241 guid_(base::ToUpperASCII(base::GenerateGUID())), | 244 guid_(base::ToUpperASCII(base::GenerateGUID())), |
242 download_id_(download_id), | 245 download_id_(download_id), |
243 target_path_(path), | 246 target_path_(path), |
244 url_chain_(1, url), | 247 url_chain_(1, url), |
245 mime_type_(mime_type), | 248 mime_type_(mime_type), |
246 original_mime_type_(mime_type), | 249 original_mime_type_(mime_type), |
247 start_tick_(base::TimeTicks::Now()), | 250 start_tick_(base::TimeTicks::Now()), |
248 state_(IN_PROGRESS_INTERNAL), | 251 state_(IN_PROGRESS_INTERNAL), |
249 start_time_(base::Time::Now()), | 252 start_time_(base::Time::Now()), |
250 delegate_(delegate), | 253 delegate_(delegate), |
254 last_access_time_(base::Time()), | |
David Trainor- moved to gerrit
2017/02/22 05:56:03
Don't need this
shaktisahu
2017/02/23 06:55:49
Done.
| |
251 current_path_(path), | 255 current_path_(path), |
252 net_log_(net_log), | 256 net_log_(net_log), |
253 weak_ptr_factory_(this) { | 257 weak_ptr_factory_(this) { |
254 delegate_->Attach(); | 258 delegate_->Attach(); |
255 Init(true /* actively downloading */, SRC_SAVE_PAGE_AS); | 259 Init(true /* actively downloading */, SRC_SAVE_PAGE_AS); |
256 } | 260 } |
257 | 261 |
258 DownloadItemImpl::~DownloadItemImpl() { | 262 DownloadItemImpl::~DownloadItemImpl() { |
259 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 263 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
260 | 264 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
448 if (state_ != COMPLETE_INTERNAL || file_externally_removed_) | 452 if (state_ != COMPLETE_INTERNAL || file_externally_removed_) |
449 return; | 453 return; |
450 | 454 |
451 // Ideally, we want to detect errors in opening and report them, but we | 455 // 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 | 456 // 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 | 457 // 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. | 458 // the UI if the file has been deleted in parallel with the open. |
455 delegate_->CheckForFileRemoval(this); | 459 delegate_->CheckForFileRemoval(this); |
456 RecordOpen(GetEndTime(), !GetOpened()); | 460 RecordOpen(GetEndTime(), !GetOpened()); |
457 opened_ = true; | 461 opened_ = true; |
462 last_access_time_ = base::Time::Now(); | |
458 for (auto& observer : observers_) | 463 for (auto& observer : observers_) |
459 observer.OnDownloadOpened(this); | 464 observer.OnDownloadOpened(this); |
460 delegate_->OpenDownload(this); | 465 delegate_->OpenDownload(this); |
461 } | 466 } |
462 | 467 |
463 void DownloadItemImpl::ShowDownloadInShell() { | 468 void DownloadItemImpl::ShowDownloadInShell() { |
464 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 469 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
465 | 470 |
466 delegate_->ShowDownloadInShell(this); | 471 delegate_->ShowDownloadInShell(this); |
467 } | 472 } |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
756 } | 761 } |
757 | 762 |
758 bool DownloadItemImpl::GetAutoOpened() { | 763 bool DownloadItemImpl::GetAutoOpened() { |
759 return auto_opened_; | 764 return auto_opened_; |
760 } | 765 } |
761 | 766 |
762 bool DownloadItemImpl::GetOpened() const { | 767 bool DownloadItemImpl::GetOpened() const { |
763 return opened_; | 768 return opened_; |
764 } | 769 } |
765 | 770 |
771 base::Time DownloadItemImpl::GetLastAccessTime() const { | |
772 return last_access_time_; | |
773 } | |
774 | |
766 BrowserContext* DownloadItemImpl::GetBrowserContext() const { | 775 BrowserContext* DownloadItemImpl::GetBrowserContext() const { |
767 return delegate_->GetBrowserContext(); | 776 return delegate_->GetBrowserContext(); |
768 } | 777 } |
769 | 778 |
770 WebContents* DownloadItemImpl::GetWebContents() const { | 779 WebContents* DownloadItemImpl::GetWebContents() const { |
771 // TODO(rdsmith): Remove null check after removing GetWebContents() from | 780 // TODO(rdsmith): Remove null check after removing GetWebContents() from |
772 // paths that might be used by DownloadItems created from history import. | 781 // paths that might be used by DownloadItems created from history import. |
773 // Currently such items have null request_handle_s, where other items | 782 // Currently such items have null request_handle_s, where other items |
774 // (regular and SavePackage downloads) have actual objects off the pointer. | 783 // (regular and SavePackage downloads) have actual objects off the pointer. |
775 if (request_handle_) | 784 if (request_handle_) |
(...skipping 19 matching lines...) Expand all Loading... | |
795 } | 804 } |
796 | 805 |
797 void DownloadItemImpl::SetOpenWhenComplete(bool open) { | 806 void DownloadItemImpl::SetOpenWhenComplete(bool open) { |
798 open_when_complete_ = open; | 807 open_when_complete_ = open; |
799 } | 808 } |
800 | 809 |
801 void DownloadItemImpl::SetOpened(bool opened) { | 810 void DownloadItemImpl::SetOpened(bool opened) { |
802 opened_ = opened; | 811 opened_ = opened; |
803 } | 812 } |
804 | 813 |
814 void DownloadItemImpl::UpdateLastAccessTime() { | |
815 last_access_time_ = base::Time::Now(); | |
816 UpdateObservers(); | |
817 } | |
818 | |
805 void DownloadItemImpl::SetDisplayName(const base::FilePath& name) { | 819 void DownloadItemImpl::SetDisplayName(const base::FilePath& name) { |
806 display_name_ = name; | 820 display_name_ = name; |
807 } | 821 } |
808 | 822 |
809 std::string DownloadItemImpl::DebugString(bool verbose) const { | 823 std::string DownloadItemImpl::DebugString(bool verbose) const { |
810 std::string description = | 824 std::string description = |
811 base::StringPrintf("{ id = %d" | 825 base::StringPrintf("{ id = %d" |
812 " state = %s", | 826 " state = %s", |
813 download_id_, | 827 download_id_, |
814 DebugDownloadStateString(state_)); | 828 DebugDownloadStateString(state_)); |
(...skipping 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2120 case RESUME_MODE_USER_CONTINUE: | 2134 case RESUME_MODE_USER_CONTINUE: |
2121 return "USER_CONTINUE"; | 2135 return "USER_CONTINUE"; |
2122 case RESUME_MODE_USER_RESTART: | 2136 case RESUME_MODE_USER_RESTART: |
2123 return "USER_RESTART"; | 2137 return "USER_RESTART"; |
2124 } | 2138 } |
2125 NOTREACHED() << "Unknown resume mode " << mode; | 2139 NOTREACHED() << "Unknown resume mode " << mode; |
2126 return "unknown"; | 2140 return "unknown"; |
2127 } | 2141 } |
2128 | 2142 |
2129 } // namespace content | 2143 } // namespace content |
OLD | NEW |