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 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1158 OnAllDataSaved(total_bytes, std::move(secure_hash)); | 1158 OnAllDataSaved(total_bytes, std::move(secure_hash)); |
1159 MaybeCompleteDownload(); | 1159 MaybeCompleteDownload(); |
1160 } | 1160 } |
1161 | 1161 |
1162 // **** Download progression cascade | 1162 // **** Download progression cascade |
1163 | 1163 |
1164 void DownloadItemImpl::Init(bool active, | 1164 void DownloadItemImpl::Init(bool active, |
1165 DownloadType download_type) { | 1165 DownloadType download_type) { |
1166 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1166 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1167 | 1167 |
1168 if (active) | |
1169 RecordDownloadCount(START_COUNT); | |
1170 | |
1171 std::string file_name; | 1168 std::string file_name; |
1172 if (download_type == SRC_HISTORY_IMPORT) { | 1169 if (download_type == SRC_HISTORY_IMPORT) { |
1173 // target_path_ works for History and Save As versions. | 1170 // target_path_ works for History and Save As versions. |
1174 file_name = target_path_.AsUTF8Unsafe(); | 1171 file_name = target_path_.AsUTF8Unsafe(); |
1175 } else { | 1172 } else { |
1176 // See if it's set programmatically. | 1173 // See if it's set programmatically. |
1177 file_name = forced_file_path_.AsUTF8Unsafe(); | 1174 file_name = forced_file_path_.AsUTF8Unsafe(); |
1178 // Possibly has a 'download' attribute for the anchor. | 1175 // Possibly has a 'download' attribute for the anchor. |
1179 if (file_name.empty()) | 1176 if (file_name.empty()) |
1180 file_name = suggested_filename_; | 1177 file_name = suggested_filename_; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1258 | 1255 |
1259 // Otherwise, this was a resumption attempt which ended with an | 1256 // Otherwise, this was a resumption attempt which ended with an |
1260 // interruption. Continue with current target path. | 1257 // interruption. Continue with current target path. |
1261 TransitionTo(TARGET_RESOLVED_INTERNAL); | 1258 TransitionTo(TARGET_RESOLVED_INTERNAL); |
1262 InterruptWithPartialState( | 1259 InterruptWithPartialState( |
1263 offset, std::move(hash_state), new_create_info.result); | 1260 offset, std::move(hash_state), new_create_info.result); |
1264 UpdateObservers(); | 1261 UpdateObservers(); |
1265 return; | 1262 return; |
1266 } | 1263 } |
1267 | 1264 |
1265 if (state_ == INITIAL_INTERNAL) { | |
1266 RecordDownloadCount(START_COUNT); | |
asanka
2017/03/23 14:34:43
START_COUNT is probably better if recorded for all
shaktisahu
2017/03/23 15:33:28
Oh, I misunderstood the comments of Init() that |a
asanka
2017/03/23 16:23:45
Count of all resumptions = Count of (Download.Sour
shaktisahu
2017/03/23 23:05:34
Done.
| |
1267 RecordDownloadMimeType(mime_type_); | |
asanka
2017/03/23 14:34:43
Ditto here, but in this case it's probably easier
shaktisahu
2017/03/23 15:33:28
Are you saying it is okay to remove the old metric
asanka
2017/03/23 16:23:45
We need to keep the old one in histograms.xml sinc
shaktisahu
2017/03/23 23:05:34
Done.
| |
1268 if (!GetBrowserContext()->IsOffTheRecord()) { | |
1269 RecordDownloadCount(START_COUNT_NORMAL_PROFILE); | |
1270 RecordDownloadMimeTypeForNormalProfile(mime_type_); | |
1271 } | |
1272 } | |
1273 | |
1268 // Successful download start. | 1274 // Successful download start. |
1269 DCHECK(download_file_); | 1275 DCHECK(download_file_); |
1270 DCHECK(job_); | 1276 DCHECK(job_); |
1271 | 1277 |
1272 if (state_ == RESUMING_INTERNAL) | 1278 if (state_ == RESUMING_INTERNAL) |
1273 UpdateValidatorsOnResumption(new_create_info); | 1279 UpdateValidatorsOnResumption(new_create_info); |
1274 | 1280 |
1275 if (state_ == INITIAL_INTERNAL && job_->UsesParallelRequests()) | 1281 if (state_ == INITIAL_INTERNAL && job_->UsesParallelRequests()) |
1276 RecordDownloadCount(USES_PARALLEL_REQUESTS); | 1282 RecordDownloadCount(USES_PARALLEL_REQUESTS); |
1277 | 1283 |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1556 | 1562 |
1557 void DownloadItemImpl::Completed() { | 1563 void DownloadItemImpl::Completed() { |
1558 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1564 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1559 | 1565 |
1560 DVLOG(20) << __func__ << "() " << DebugString(false); | 1566 DVLOG(20) << __func__ << "() " << DebugString(false); |
1561 | 1567 |
1562 DCHECK(all_data_saved_); | 1568 DCHECK(all_data_saved_); |
1563 end_time_ = base::Time::Now(); | 1569 end_time_ = base::Time::Now(); |
1564 TransitionTo(COMPLETE_INTERNAL); | 1570 TransitionTo(COMPLETE_INTERNAL); |
1565 RecordDownloadCompleted(start_tick_, received_bytes_); | 1571 RecordDownloadCompleted(start_tick_, received_bytes_); |
1572 if (!GetBrowserContext()->IsOffTheRecord()) { | |
1573 RecordDownloadCount(COMPLETED_COUNT_NORMAL_PROFILE); | |
1574 } | |
1566 | 1575 |
1567 if (auto_opened_) { | 1576 if (auto_opened_) { |
1568 // If it was already handled by the delegate, do nothing. | 1577 // If it was already handled by the delegate, do nothing. |
1569 } else if (GetOpenWhenComplete() || | 1578 } else if (GetOpenWhenComplete() || |
1570 ShouldOpenFileBasedOnExtension() || | 1579 ShouldOpenFileBasedOnExtension() || |
1571 IsTemporary()) { | 1580 IsTemporary()) { |
1572 // If the download is temporary, like in drag-and-drop, do not open it but | 1581 // If the download is temporary, like in drag-and-drop, do not open it but |
1573 // we still need to set it auto-opened so that it can be removed from the | 1582 // we still need to set it auto-opened so that it can be removed from the |
1574 // download shelf. | 1583 // download shelf. |
1575 if (!IsTemporary()) | 1584 if (!IsTemporary()) |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2175 case RESUME_MODE_USER_CONTINUE: | 2184 case RESUME_MODE_USER_CONTINUE: |
2176 return "USER_CONTINUE"; | 2185 return "USER_CONTINUE"; |
2177 case RESUME_MODE_USER_RESTART: | 2186 case RESUME_MODE_USER_RESTART: |
2178 return "USER_RESTART"; | 2187 return "USER_RESTART"; |
2179 } | 2188 } |
2180 NOTREACHED() << "Unknown resume mode " << mode; | 2189 NOTREACHED() << "Unknown resume mode " << mode; |
2181 return "unknown"; | 2190 return "unknown"; |
2182 } | 2191 } |
2183 | 2192 |
2184 } // namespace content | 2193 } // namespace content |
OLD | NEW |