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