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 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1209 std::unique_ptr<DownloadRequestHandleInterface> req_handle, | 1209 std::unique_ptr<DownloadRequestHandleInterface> req_handle, |
1210 const DownloadCreateInfo& new_create_info) { | 1210 const DownloadCreateInfo& new_create_info) { |
1211 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1211 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1212 DCHECK(!download_file_.get()); | 1212 DCHECK(!download_file_.get()); |
1213 DVLOG(20) << __func__ << "() this=" << DebugString(true); | 1213 DVLOG(20) << __func__ << "() this=" << DebugString(true); |
1214 RecordDownloadCount(START_COUNT); | 1214 RecordDownloadCount(START_COUNT); |
1215 | 1215 |
1216 download_file_ = std::move(file); | 1216 download_file_ = std::move(file); |
1217 job_ = DownloadJobFactory::CreateJob(this, std::move(req_handle), | 1217 job_ = DownloadJobFactory::CreateJob(this, std::move(req_handle), |
1218 new_create_info); | 1218 new_create_info); |
| 1219 if (job_->UsesParallelRequests()) |
| 1220 RecordParallelDownloadCount(START_COUNT); |
| 1221 |
1219 deferred_interrupt_reason_ = DOWNLOAD_INTERRUPT_REASON_NONE; | 1222 deferred_interrupt_reason_ = DOWNLOAD_INTERRUPT_REASON_NONE; |
1220 | 1223 |
1221 if (state_ == CANCELLED_INTERNAL) { | 1224 if (state_ == CANCELLED_INTERNAL) { |
1222 // The download was in the process of resuming when it was cancelled. Don't | 1225 // The download was in the process of resuming when it was cancelled. Don't |
1223 // proceed. | 1226 // proceed. |
1224 ReleaseDownloadFile(true); | 1227 ReleaseDownloadFile(true); |
1225 job_->Cancel(true); | 1228 job_->Cancel(true); |
1226 return; | 1229 return; |
1227 } | 1230 } |
1228 | 1231 |
(...skipping 29 matching lines...) Expand all Loading... |
1258 hash_.clear(); | 1261 hash_.clear(); |
1259 deferred_interrupt_reason_ = new_create_info.result; | 1262 deferred_interrupt_reason_ = new_create_info.result; |
1260 received_slices_.clear(); | 1263 received_slices_.clear(); |
1261 TransitionTo(INTERRUPTED_TARGET_PENDING_INTERNAL); | 1264 TransitionTo(INTERRUPTED_TARGET_PENDING_INTERNAL); |
1262 DetermineDownloadTarget(); | 1265 DetermineDownloadTarget(); |
1263 return; | 1266 return; |
1264 } | 1267 } |
1265 | 1268 |
1266 if (state_ == INITIAL_INTERNAL) { | 1269 if (state_ == INITIAL_INTERNAL) { |
1267 RecordDownloadCount(NEW_DOWNLOAD_COUNT); | 1270 RecordDownloadCount(NEW_DOWNLOAD_COUNT); |
| 1271 if (job_->UsesParallelRequests()) |
| 1272 RecordParallelDownloadCount(NEW_DOWNLOAD_COUNT); |
1268 RecordDownloadMimeType(mime_type_); | 1273 RecordDownloadMimeType(mime_type_); |
1269 if (!GetBrowserContext()->IsOffTheRecord()) { | 1274 if (!GetBrowserContext()->IsOffTheRecord()) { |
1270 RecordDownloadCount(NEW_DOWNLOAD_COUNT_NORMAL_PROFILE); | 1275 RecordDownloadCount(NEW_DOWNLOAD_COUNT_NORMAL_PROFILE); |
1271 RecordDownloadMimeTypeForNormalProfile(mime_type_); | 1276 RecordDownloadMimeTypeForNormalProfile(mime_type_); |
1272 } | 1277 } |
1273 } | 1278 } |
1274 | 1279 |
1275 // Successful download start. | 1280 // Successful download start. |
1276 DCHECK(download_file_); | 1281 DCHECK(download_file_); |
1277 DCHECK(job_); | 1282 DCHECK(job_); |
1278 | 1283 |
1279 if (state_ == RESUMING_INTERNAL) | 1284 if (state_ == RESUMING_INTERNAL) |
1280 UpdateValidatorsOnResumption(new_create_info); | 1285 UpdateValidatorsOnResumption(new_create_info); |
1281 | 1286 |
1282 if (state_ == INITIAL_INTERNAL && job_->UsesParallelRequests()) | |
1283 RecordParallelDownloadCount(START_COUNT); | |
1284 | |
1285 TransitionTo(TARGET_PENDING_INTERNAL); | 1287 TransitionTo(TARGET_PENDING_INTERNAL); |
1286 | 1288 |
1287 job_->Start(); | 1289 job_->Start(); |
1288 } | 1290 } |
1289 | 1291 |
1290 void DownloadItemImpl::StartDownload() { | 1292 void DownloadItemImpl::StartDownload() { |
1291 BrowserThread::PostTask( | 1293 BrowserThread::PostTask( |
1292 BrowserThread::FILE, FROM_HERE, | 1294 BrowserThread::FILE, FROM_HERE, |
1293 base::Bind(&DownloadFile::Initialize, | 1295 base::Bind(&DownloadFile::Initialize, |
1294 // Safe because we control download file lifetime. | 1296 // Safe because we control download file lifetime. |
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2246 case RESUME_MODE_USER_CONTINUE: | 2248 case RESUME_MODE_USER_CONTINUE: |
2247 return "USER_CONTINUE"; | 2249 return "USER_CONTINUE"; |
2248 case RESUME_MODE_USER_RESTART: | 2250 case RESUME_MODE_USER_RESTART: |
2249 return "USER_RESTART"; | 2251 return "USER_RESTART"; |
2250 } | 2252 } |
2251 NOTREACHED() << "Unknown resume mode " << mode; | 2253 NOTREACHED() << "Unknown resume mode " << mode; |
2252 return "unknown"; | 2254 return "unknown"; |
2253 } | 2255 } |
2254 | 2256 |
2255 } // namespace content | 2257 } // namespace content |
OLD | NEW |