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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 114 } |
115 | 115 |
116 } // namespace | 116 } // namespace |
117 | 117 |
118 const uint32_t DownloadItem::kInvalidId = 0; | 118 const uint32_t DownloadItem::kInvalidId = 0; |
119 | 119 |
120 // The maximum number of attempts we will make to resume automatically. | 120 // The maximum number of attempts we will make to resume automatically. |
121 const int DownloadItemImpl::kMaxAutoResumeAttempts = 5; | 121 const int DownloadItemImpl::kMaxAutoResumeAttempts = 5; |
122 | 122 |
123 // Constructor for reading from the history service. | 123 // Constructor for reading from the history service. |
124 DownloadItemImpl::DownloadItemImpl(DownloadItemImplDelegate* delegate, | 124 DownloadItemImpl::DownloadItemImpl( |
125 const std::string& guid, | 125 DownloadItemImplDelegate* delegate, |
126 uint32_t download_id, | 126 const std::string& guid, |
127 const base::FilePath& current_path, | 127 uint32_t download_id, |
128 const base::FilePath& target_path, | 128 const base::FilePath& current_path, |
129 const std::vector<GURL>& url_chain, | 129 const base::FilePath& target_path, |
130 const GURL& referrer_url, | 130 const std::vector<GURL>& url_chain, |
131 const GURL& site_url, | 131 const GURL& referrer_url, |
132 const GURL& tab_url, | 132 const GURL& site_url, |
133 const GURL& tab_refererr_url, | 133 const GURL& tab_url, |
134 const std::string& mime_type, | 134 const GURL& tab_refererr_url, |
135 const std::string& original_mime_type, | 135 const std::string& mime_type, |
136 const base::Time& start_time, | 136 const std::string& original_mime_type, |
137 const base::Time& end_time, | 137 const base::Time& start_time, |
138 const std::string& etag, | 138 const base::Time& end_time, |
139 const std::string& last_modified, | 139 const std::string& etag, |
140 int64_t received_bytes, | 140 const std::string& last_modified, |
141 int64_t total_bytes, | 141 int64_t received_bytes, |
142 const std::string& hash, | 142 int64_t total_bytes, |
143 DownloadItem::DownloadState state, | 143 const std::string& hash, |
144 DownloadDangerType danger_type, | 144 DownloadItem::DownloadState state, |
145 DownloadInterruptReason interrupt_reason, | 145 DownloadDangerType danger_type, |
146 bool opened, | 146 DownloadInterruptReason interrupt_reason, |
147 const net::NetLogWithSource& net_log) | 147 bool opened, |
| 148 const std::vector<DownloadItem::ReceivedSlice>& received_slices, |
| 149 const net::NetLogWithSource& net_log) |
148 : guid_(base::ToUpperASCII(guid)), | 150 : guid_(base::ToUpperASCII(guid)), |
149 download_id_(download_id), | 151 download_id_(download_id), |
150 target_path_(target_path), | 152 target_path_(target_path), |
151 url_chain_(url_chain), | 153 url_chain_(url_chain), |
152 referrer_url_(referrer_url), | 154 referrer_url_(referrer_url), |
153 site_url_(site_url), | 155 site_url_(site_url), |
154 tab_url_(tab_url), | 156 tab_url_(tab_url), |
155 tab_referrer_url_(tab_refererr_url), | 157 tab_referrer_url_(tab_refererr_url), |
156 mime_type_(mime_type), | 158 mime_type_(mime_type), |
157 original_mime_type_(original_mime_type), | 159 original_mime_type_(original_mime_type), |
158 total_bytes_(total_bytes), | 160 total_bytes_(total_bytes), |
159 last_reason_(interrupt_reason), | 161 last_reason_(interrupt_reason), |
160 start_tick_(base::TimeTicks()), | 162 start_tick_(base::TimeTicks()), |
161 state_(ExternalToInternalState(state)), | 163 state_(ExternalToInternalState(state)), |
162 danger_type_(danger_type), | 164 danger_type_(danger_type), |
163 start_time_(start_time), | 165 start_time_(start_time), |
164 end_time_(end_time), | 166 end_time_(end_time), |
165 delegate_(delegate), | 167 delegate_(delegate), |
166 opened_(opened), | 168 opened_(opened), |
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), |
| 175 received_slices_(received_slices), |
173 net_log_(net_log), | 176 net_log_(net_log), |
174 weak_ptr_factory_(this) { | 177 weak_ptr_factory_(this) { |
175 delegate_->Attach(); | 178 delegate_->Attach(); |
176 DCHECK(state_ == COMPLETE_INTERNAL || state_ == INTERRUPTED_INTERNAL || | 179 DCHECK(state_ == COMPLETE_INTERNAL || state_ == INTERRUPTED_INTERNAL || |
177 state_ == CANCELLED_INTERNAL); | 180 state_ == CANCELLED_INTERNAL); |
178 DCHECK(base::IsValidGUID(guid_)); | 181 DCHECK(base::IsValidGUID(guid_)); |
179 Init(false /* not actively downloading */, SRC_HISTORY_IMPORT); | 182 Init(false /* not actively downloading */, SRC_HISTORY_IMPORT); |
180 } | 183 } |
181 | 184 |
182 // Constructing for a regular download: | 185 // Constructing for a regular download: |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 } | 720 } |
718 | 721 |
719 int64_t DownloadItemImpl::GetTotalBytes() const { | 722 int64_t DownloadItemImpl::GetTotalBytes() const { |
720 return total_bytes_; | 723 return total_bytes_; |
721 } | 724 } |
722 | 725 |
723 int64_t DownloadItemImpl::GetReceivedBytes() const { | 726 int64_t DownloadItemImpl::GetReceivedBytes() const { |
724 return received_bytes_; | 727 return received_bytes_; |
725 } | 728 } |
726 | 729 |
| 730 const std::vector<DownloadItem::ReceivedSlice>& |
| 731 DownloadItemImpl::GetReceivedSlices() const { |
| 732 return received_slices_; |
| 733 } |
| 734 |
727 base::Time DownloadItemImpl::GetStartTime() const { | 735 base::Time DownloadItemImpl::GetStartTime() const { |
728 return start_time_; | 736 return start_time_; |
729 } | 737 } |
730 | 738 |
731 base::Time DownloadItemImpl::GetEndTime() const { | 739 base::Time DownloadItemImpl::GetEndTime() const { |
732 return end_time_; | 740 return end_time_; |
733 } | 741 } |
734 | 742 |
735 bool DownloadItemImpl::CanShowInFolder() { | 743 bool DownloadItemImpl::CanShowInFolder() { |
736 // A download can be shown in the folder if the downloaded file is in a known | 744 // A download can be shown in the folder if the downloaded file is in a known |
(...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2120 case RESUME_MODE_USER_CONTINUE: | 2128 case RESUME_MODE_USER_CONTINUE: |
2121 return "USER_CONTINUE"; | 2129 return "USER_CONTINUE"; |
2122 case RESUME_MODE_USER_RESTART: | 2130 case RESUME_MODE_USER_RESTART: |
2123 return "USER_RESTART"; | 2131 return "USER_RESTART"; |
2124 } | 2132 } |
2125 NOTREACHED() << "Unknown resume mode " << mode; | 2133 NOTREACHED() << "Unknown resume mode " << mode; |
2126 return "unknown"; | 2134 return "unknown"; |
2127 } | 2135 } |
2128 | 2136 |
2129 } // namespace content | 2137 } // namespace content |
OLD | NEW |