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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 } | 254 } |
255 | 255 |
256 void DownloadItemImpl::RemoveObserver(Observer* observer) { | 256 void DownloadItemImpl::RemoveObserver(Observer* observer) { |
257 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 257 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
258 | 258 |
259 observers_.RemoveObserver(observer); | 259 observers_.RemoveObserver(observer); |
260 } | 260 } |
261 | 261 |
262 void DownloadItemImpl::UpdateObservers() { | 262 void DownloadItemImpl::UpdateObservers() { |
263 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 263 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
264 DVLOG(20) << __FUNCTION__ << "()"; | 264 DVLOG(20) << __func__ << "()"; |
265 | 265 |
266 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadUpdated(this)); | 266 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadUpdated(this)); |
267 } | 267 } |
268 | 268 |
269 void DownloadItemImpl::ValidateDangerousDownload() { | 269 void DownloadItemImpl::ValidateDangerousDownload() { |
270 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 270 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
271 DCHECK(!IsDone()); | 271 DCHECK(!IsDone()); |
272 DCHECK(IsDangerous()); | 272 DCHECK(IsDangerous()); |
273 | 273 |
274 DVLOG(20) << __FUNCTION__ << " download=" << DebugString(true); | 274 DVLOG(20) << __func__ << "() download=" << DebugString(true); |
275 | 275 |
276 if (IsDone() || !IsDangerous()) | 276 if (IsDone() || !IsDangerous()) |
277 return; | 277 return; |
278 | 278 |
279 RecordDangerousDownloadAccept(GetDangerType(), | 279 RecordDangerousDownloadAccept(GetDangerType(), |
280 GetTargetFilePath()); | 280 GetTargetFilePath()); |
281 | 281 |
282 danger_type_ = DOWNLOAD_DANGER_TYPE_USER_VALIDATED; | 282 danger_type_ = DOWNLOAD_DANGER_TYPE_USER_VALIDATED; |
283 | 283 |
284 bound_net_log_.AddEvent( | 284 bound_net_log_.AddEvent( |
285 net::NetLog::TYPE_DOWNLOAD_ITEM_SAFETY_STATE_UPDATED, | 285 net::NetLog::TYPE_DOWNLOAD_ITEM_SAFETY_STATE_UPDATED, |
286 base::Bind(&ItemCheckedNetLogCallback, GetDangerType())); | 286 base::Bind(&ItemCheckedNetLogCallback, GetDangerType())); |
287 | 287 |
288 UpdateObservers(); // TODO(asanka): This is potentially unsafe. The download | 288 UpdateObservers(); // TODO(asanka): This is potentially unsafe. The download |
289 // may not be in a consistent state or around at all after | 289 // may not be in a consistent state or around at all after |
290 // invoking observers. http://crbug.com/586610 | 290 // invoking observers. http://crbug.com/586610 |
291 | 291 |
292 MaybeCompleteDownload(); | 292 MaybeCompleteDownload(); |
293 } | 293 } |
294 | 294 |
295 void DownloadItemImpl::StealDangerousDownload( | 295 void DownloadItemImpl::StealDangerousDownload( |
296 const AcquireFileCallback& callback) { | 296 const AcquireFileCallback& callback) { |
297 DVLOG(20) << __FUNCTION__ << "() download = " << DebugString(true); | 297 DVLOG(20) << __func__ << "() download = " << DebugString(true); |
298 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 298 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
299 DCHECK(IsDangerous()); | 299 DCHECK(IsDangerous()); |
300 | 300 |
301 if (download_file_) { | 301 if (download_file_) { |
302 BrowserThread::PostTaskAndReplyWithResult( | 302 BrowserThread::PostTaskAndReplyWithResult( |
303 BrowserThread::FILE, | 303 BrowserThread::FILE, |
304 FROM_HERE, | 304 FROM_HERE, |
305 base::Bind(&DownloadFileDetach, base::Passed(&download_file_)), | 305 base::Bind(&DownloadFileDetach, base::Passed(&download_file_)), |
306 callback); | 306 callback); |
307 } else { | 307 } else { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 return; | 342 return; |
343 | 343 |
344 case MAX_DOWNLOAD_INTERNAL_STATE: | 344 case MAX_DOWNLOAD_INTERNAL_STATE: |
345 case TARGET_RESOLVED_INTERNAL: | 345 case TARGET_RESOLVED_INTERNAL: |
346 NOTREACHED(); | 346 NOTREACHED(); |
347 } | 347 } |
348 } | 348 } |
349 | 349 |
350 void DownloadItemImpl::Resume() { | 350 void DownloadItemImpl::Resume() { |
351 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 351 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
352 DVLOG(20) << __FUNCTION__ << "() download = " << DebugString(true); | 352 DVLOG(20) << __func__ << "() download = " << DebugString(true); |
353 switch (state_) { | 353 switch (state_) { |
354 case CANCELLED_INTERNAL: // Nothing to resume. | 354 case CANCELLED_INTERNAL: // Nothing to resume. |
355 case COMPLETE_INTERNAL: | 355 case COMPLETE_INTERNAL: |
356 case COMPLETING_INTERNAL: | 356 case COMPLETING_INTERNAL: |
357 case INITIAL_INTERNAL: | 357 case INITIAL_INTERNAL: |
358 case INTERRUPTED_TARGET_PENDING_INTERNAL: | 358 case INTERRUPTED_TARGET_PENDING_INTERNAL: |
359 case RESUMING_INTERNAL: // Resumption in progress. | 359 case RESUMING_INTERNAL: // Resumption in progress. |
360 return; | 360 return; |
361 | 361 |
362 case TARGET_PENDING_INTERNAL: | 362 case TARGET_PENDING_INTERNAL: |
(...skipping 12 matching lines...) Expand all Loading... |
375 return; | 375 return; |
376 | 376 |
377 case MAX_DOWNLOAD_INTERNAL_STATE: | 377 case MAX_DOWNLOAD_INTERNAL_STATE: |
378 case TARGET_RESOLVED_INTERNAL: | 378 case TARGET_RESOLVED_INTERNAL: |
379 NOTREACHED(); | 379 NOTREACHED(); |
380 } | 380 } |
381 } | 381 } |
382 | 382 |
383 void DownloadItemImpl::Cancel(bool user_cancel) { | 383 void DownloadItemImpl::Cancel(bool user_cancel) { |
384 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 384 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
385 DVLOG(20) << __FUNCTION__ << "() download = " << DebugString(true); | 385 DVLOG(20) << __func__ << "() download = " << DebugString(true); |
386 InterruptAndDiscardPartialState( | 386 InterruptAndDiscardPartialState( |
387 user_cancel ? DOWNLOAD_INTERRUPT_REASON_USER_CANCELED | 387 user_cancel ? DOWNLOAD_INTERRUPT_REASON_USER_CANCELED |
388 : DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN); | 388 : DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN); |
389 UpdateObservers(); | 389 UpdateObservers(); |
390 } | 390 } |
391 | 391 |
392 void DownloadItemImpl::Remove() { | 392 void DownloadItemImpl::Remove() { |
393 DVLOG(20) << __FUNCTION__ << "() download = " << DebugString(true); | 393 DVLOG(20) << __func__ << "() download = " << DebugString(true); |
394 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 394 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
395 | 395 |
396 delegate_->AssertStateConsistent(this); | 396 delegate_->AssertStateConsistent(this); |
397 InterruptAndDiscardPartialState(DOWNLOAD_INTERRUPT_REASON_USER_CANCELED); | 397 InterruptAndDiscardPartialState(DOWNLOAD_INTERRUPT_REASON_USER_CANCELED); |
398 UpdateObservers(); | 398 UpdateObservers(); |
399 delegate_->AssertStateConsistent(this); | 399 delegate_->AssertStateConsistent(this); |
400 | 400 |
401 NotifyRemoved(); | 401 NotifyRemoved(); |
402 delegate_->DownloadRemoved(this); | 402 delegate_->DownloadRemoved(this); |
403 // We have now been deleted. | 403 // We have now been deleted. |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 749 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
750 DCHECK(AllDataSaved()); | 750 DCHECK(AllDataSaved()); |
751 | 751 |
752 // Danger type is only allowed to be set on an active download after all data | 752 // Danger type is only allowed to be set on an active download after all data |
753 // has been saved. This excludes all other states. In particular, | 753 // has been saved. This excludes all other states. In particular, |
754 // OnContentCheckCompleted() isn't allowed on an INTERRUPTED download since | 754 // OnContentCheckCompleted() isn't allowed on an INTERRUPTED download since |
755 // such an interruption would need to happen between OnAllDataSaved() and | 755 // such an interruption would need to happen between OnAllDataSaved() and |
756 // OnContentCheckCompleted() during which no disk or network activity | 756 // OnContentCheckCompleted() during which no disk or network activity |
757 // should've taken place. | 757 // should've taken place. |
758 DCHECK_EQ(state_, IN_PROGRESS_INTERNAL); | 758 DCHECK_EQ(state_, IN_PROGRESS_INTERNAL); |
759 DVLOG(20) << __FUNCTION__ << " danger_type=" << danger_type | 759 DVLOG(20) << __func__ << "() danger_type=" << danger_type |
760 << " download=" << DebugString(true); | 760 << " download=" << DebugString(true); |
761 SetDangerType(danger_type); | 761 SetDangerType(danger_type); |
762 UpdateObservers(); | 762 UpdateObservers(); |
763 } | 763 } |
764 | 764 |
765 void DownloadItemImpl::SetOpenWhenComplete(bool open) { | 765 void DownloadItemImpl::SetOpenWhenComplete(bool open) { |
766 open_when_complete_ = open; | 766 open_when_complete_ = open; |
767 } | 767 } |
768 | 768 |
769 void DownloadItemImpl::SetOpened(bool opened) { | 769 void DownloadItemImpl::SetOpened(bool opened) { |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
968 // DownloadFile is created and Start() is called. The observers will be | 968 // DownloadFile is created and Start() is called. The observers will be |
969 // notified when the download transitions to the IN_PROGRESS state. | 969 // notified when the download transitions to the IN_PROGRESS state. |
970 } | 970 } |
971 | 971 |
972 void DownloadItemImpl::NotifyRemoved() { | 972 void DownloadItemImpl::NotifyRemoved() { |
973 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadRemoved(this)); | 973 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadRemoved(this)); |
974 } | 974 } |
975 | 975 |
976 void DownloadItemImpl::OnDownloadedFileRemoved() { | 976 void DownloadItemImpl::OnDownloadedFileRemoved() { |
977 file_externally_removed_ = true; | 977 file_externally_removed_ = true; |
978 DVLOG(20) << __FUNCTION__ << " download=" << DebugString(true); | 978 DVLOG(20) << __func__ << "() download=" << DebugString(true); |
979 UpdateObservers(); | 979 UpdateObservers(); |
980 } | 980 } |
981 | 981 |
982 base::WeakPtr<DownloadDestinationObserver> | 982 base::WeakPtr<DownloadDestinationObserver> |
983 DownloadItemImpl::DestinationObserverAsWeakPtr() { | 983 DownloadItemImpl::DestinationObserverAsWeakPtr() { |
984 return weak_ptr_factory_.GetWeakPtr(); | 984 return weak_ptr_factory_.GetWeakPtr(); |
985 } | 985 } |
986 | 986 |
987 const net::BoundNetLog& DownloadItemImpl::GetBoundNetLog() const { | 987 const net::BoundNetLog& DownloadItemImpl::GetBoundNetLog() const { |
988 return bound_net_log_; | 988 return bound_net_log_; |
989 } | 989 } |
990 | 990 |
991 void DownloadItemImpl::SetTotalBytes(int64_t total_bytes) { | 991 void DownloadItemImpl::SetTotalBytes(int64_t total_bytes) { |
992 total_bytes_ = total_bytes; | 992 total_bytes_ = total_bytes; |
993 } | 993 } |
994 | 994 |
995 void DownloadItemImpl::OnAllDataSaved( | 995 void DownloadItemImpl::OnAllDataSaved( |
996 int64_t total_bytes, | 996 int64_t total_bytes, |
997 std::unique_ptr<crypto::SecureHash> hash_state) { | 997 std::unique_ptr<crypto::SecureHash> hash_state) { |
998 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 998 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
999 DCHECK(!all_data_saved_); | 999 DCHECK(!all_data_saved_); |
1000 all_data_saved_ = true; | 1000 all_data_saved_ = true; |
1001 SetTotalBytes(total_bytes); | 1001 SetTotalBytes(total_bytes); |
1002 UpdateProgress(total_bytes, 0); | 1002 UpdateProgress(total_bytes, 0); |
1003 SetHashState(std::move(hash_state)); | 1003 SetHashState(std::move(hash_state)); |
1004 hash_state_.reset(); // No need to retain hash_state_ since we are done with | 1004 hash_state_.reset(); // No need to retain hash_state_ since we are done with |
1005 // the download and don't expect to receive any more | 1005 // the download and don't expect to receive any more |
1006 // data. | 1006 // data. |
1007 | 1007 |
1008 DVLOG(20) << __FUNCTION__ << " download=" << DebugString(true); | 1008 DVLOG(20) << __func__ << "() download=" << DebugString(true); |
1009 UpdateObservers(); | 1009 UpdateObservers(); |
1010 } | 1010 } |
1011 | 1011 |
1012 void DownloadItemImpl::MarkAsComplete() { | 1012 void DownloadItemImpl::MarkAsComplete() { |
1013 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1013 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1014 | 1014 |
1015 DCHECK(all_data_saved_); | 1015 DCHECK(all_data_saved_); |
1016 end_time_ = base::Time::Now(); | 1016 end_time_ = base::Time::Now(); |
1017 TransitionTo(COMPLETE_INTERNAL); | 1017 TransitionTo(COMPLETE_INTERNAL); |
1018 UpdateObservers(); | 1018 UpdateObservers(); |
1019 } | 1019 } |
1020 | 1020 |
1021 void DownloadItemImpl::DestinationUpdate(int64_t bytes_so_far, | 1021 void DownloadItemImpl::DestinationUpdate(int64_t bytes_so_far, |
1022 int64_t bytes_per_sec) { | 1022 int64_t bytes_per_sec) { |
1023 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1023 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1024 // If the download is in any other state we don't expect any | 1024 // If the download is in any other state we don't expect any |
1025 // DownloadDestinationObserver callbacks. An interruption or a cancellation | 1025 // DownloadDestinationObserver callbacks. An interruption or a cancellation |
1026 // results in a call to ReleaseDownloadFile which invalidates the weak | 1026 // results in a call to ReleaseDownloadFile which invalidates the weak |
1027 // reference held by the DownloadFile and hence cuts off any pending | 1027 // reference held by the DownloadFile and hence cuts off any pending |
1028 // callbacks. | 1028 // callbacks. |
1029 DCHECK(state_ == TARGET_PENDING_INTERNAL || state_ == IN_PROGRESS_INTERNAL); | 1029 DCHECK(state_ == TARGET_PENDING_INTERNAL || state_ == IN_PROGRESS_INTERNAL); |
1030 | 1030 |
1031 // There must be no pending destination_error_. | 1031 // There must be no pending destination_error_. |
1032 DCHECK_EQ(destination_error_, DOWNLOAD_INTERRUPT_REASON_NONE); | 1032 DCHECK_EQ(destination_error_, DOWNLOAD_INTERRUPT_REASON_NONE); |
1033 | 1033 |
1034 DVLOG(20) << __FUNCTION__ << " so_far=" << bytes_so_far | 1034 DVLOG(20) << __func__ << "() so_far=" << bytes_so_far |
1035 << " per_sec=" << bytes_per_sec | 1035 << " per_sec=" << bytes_per_sec |
1036 << " download=" << DebugString(true); | 1036 << " download=" << DebugString(true); |
1037 | 1037 |
1038 UpdateProgress(bytes_so_far, bytes_per_sec); | 1038 UpdateProgress(bytes_so_far, bytes_per_sec); |
1039 if (bound_net_log_.IsCapturing()) { | 1039 if (bound_net_log_.IsCapturing()) { |
1040 bound_net_log_.AddEvent( | 1040 bound_net_log_.AddEvent( |
1041 net::NetLog::TYPE_DOWNLOAD_ITEM_UPDATED, | 1041 net::NetLog::TYPE_DOWNLOAD_ITEM_UPDATED, |
1042 net::NetLog::Int64Callback("bytes_so_far", received_bytes_)); | 1042 net::NetLog::Int64Callback("bytes_so_far", received_bytes_)); |
1043 } | 1043 } |
1044 | 1044 |
1045 UpdateObservers(); | 1045 UpdateObservers(); |
1046 } | 1046 } |
1047 | 1047 |
1048 void DownloadItemImpl::DestinationError( | 1048 void DownloadItemImpl::DestinationError( |
1049 DownloadInterruptReason reason, | 1049 DownloadInterruptReason reason, |
1050 int64_t bytes_so_far, | 1050 int64_t bytes_so_far, |
1051 std::unique_ptr<crypto::SecureHash> secure_hash) { | 1051 std::unique_ptr<crypto::SecureHash> secure_hash) { |
1052 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1052 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1053 // If the download is in any other state we don't expect any | 1053 // If the download is in any other state we don't expect any |
1054 // DownloadDestinationObserver callbacks. An interruption or a cancellation | 1054 // DownloadDestinationObserver callbacks. An interruption or a cancellation |
1055 // results in a call to ReleaseDownloadFile which invalidates the weak | 1055 // results in a call to ReleaseDownloadFile which invalidates the weak |
1056 // reference held by the DownloadFile and hence cuts off any pending | 1056 // reference held by the DownloadFile and hence cuts off any pending |
1057 // callbacks. | 1057 // callbacks. |
1058 DCHECK(state_ == TARGET_PENDING_INTERNAL || state_ == IN_PROGRESS_INTERNAL); | 1058 DCHECK(state_ == TARGET_PENDING_INTERNAL || state_ == IN_PROGRESS_INTERNAL); |
1059 DVLOG(20) << __FUNCTION__ | 1059 DVLOG(20) << __func__ |
1060 << "() reason:" << DownloadInterruptReasonToString(reason); | 1060 << "() reason:" << DownloadInterruptReasonToString(reason); |
1061 | 1061 |
1062 // Postpone recognition of this error until after file name determination | 1062 // Postpone recognition of this error until after file name determination |
1063 // has completed and the intermediate file has been renamed to simplify | 1063 // has completed and the intermediate file has been renamed to simplify |
1064 // resumption conditions. | 1064 // resumption conditions. |
1065 if (state_ == TARGET_PENDING_INTERNAL) { | 1065 if (state_ == TARGET_PENDING_INTERNAL) { |
1066 received_bytes_ = bytes_so_far; | 1066 received_bytes_ = bytes_so_far; |
1067 hash_state_ = std::move(secure_hash); | 1067 hash_state_ = std::move(secure_hash); |
1068 hash_.clear(); | 1068 hash_.clear(); |
1069 destination_error_ = reason; | 1069 destination_error_ = reason; |
1070 return; | 1070 return; |
1071 } | 1071 } |
1072 InterruptWithPartialState(bytes_so_far, std::move(secure_hash), reason); | 1072 InterruptWithPartialState(bytes_so_far, std::move(secure_hash), reason); |
1073 UpdateObservers(); | 1073 UpdateObservers(); |
1074 } | 1074 } |
1075 | 1075 |
1076 void DownloadItemImpl::DestinationCompleted( | 1076 void DownloadItemImpl::DestinationCompleted( |
1077 int64_t total_bytes, | 1077 int64_t total_bytes, |
1078 std::unique_ptr<crypto::SecureHash> secure_hash) { | 1078 std::unique_ptr<crypto::SecureHash> secure_hash) { |
1079 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1079 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1080 // If the download is in any other state we don't expect any | 1080 // If the download is in any other state we don't expect any |
1081 // DownloadDestinationObserver callbacks. An interruption or a cancellation | 1081 // DownloadDestinationObserver callbacks. An interruption or a cancellation |
1082 // results in a call to ReleaseDownloadFile which invalidates the weak | 1082 // results in a call to ReleaseDownloadFile which invalidates the weak |
1083 // reference held by the DownloadFile and hence cuts off any pending | 1083 // reference held by the DownloadFile and hence cuts off any pending |
1084 // callbacks. | 1084 // callbacks. |
1085 DCHECK(state_ == TARGET_PENDING_INTERNAL || state_ == IN_PROGRESS_INTERNAL); | 1085 DCHECK(state_ == TARGET_PENDING_INTERNAL || state_ == IN_PROGRESS_INTERNAL); |
1086 DVLOG(20) << __FUNCTION__ << " download=" << DebugString(true); | 1086 DVLOG(20) << __func__ << "() download=" << DebugString(true); |
1087 | 1087 |
1088 OnAllDataSaved(total_bytes, std::move(secure_hash)); | 1088 OnAllDataSaved(total_bytes, std::move(secure_hash)); |
1089 MaybeCompleteDownload(); | 1089 MaybeCompleteDownload(); |
1090 } | 1090 } |
1091 | 1091 |
1092 // **** Download progression cascade | 1092 // **** Download progression cascade |
1093 | 1093 |
1094 void DownloadItemImpl::Init(bool active, | 1094 void DownloadItemImpl::Init(bool active, |
1095 DownloadType download_type) { | 1095 DownloadType download_type) { |
1096 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1096 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
(...skipping 19 matching lines...) Expand all Loading... |
1116 net::NetLog::ParametersCallback active_data = | 1116 net::NetLog::ParametersCallback active_data = |
1117 base::Bind(&ItemActivatedNetLogCallback, this, download_type, &file_name); | 1117 base::Bind(&ItemActivatedNetLogCallback, this, download_type, &file_name); |
1118 if (active) { | 1118 if (active) { |
1119 bound_net_log_.BeginEvent( | 1119 bound_net_log_.BeginEvent( |
1120 net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE, active_data); | 1120 net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE, active_data); |
1121 } else { | 1121 } else { |
1122 bound_net_log_.AddEvent( | 1122 bound_net_log_.AddEvent( |
1123 net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE, active_data); | 1123 net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE, active_data); |
1124 } | 1124 } |
1125 | 1125 |
1126 DVLOG(20) << __FUNCTION__ << "() " << DebugString(true); | 1126 DVLOG(20) << __func__ << "() " << DebugString(true); |
1127 } | 1127 } |
1128 | 1128 |
1129 // We're starting the download. | 1129 // We're starting the download. |
1130 void DownloadItemImpl::Start( | 1130 void DownloadItemImpl::Start( |
1131 std::unique_ptr<DownloadFile> file, | 1131 std::unique_ptr<DownloadFile> file, |
1132 std::unique_ptr<DownloadRequestHandleInterface> req_handle, | 1132 std::unique_ptr<DownloadRequestHandleInterface> req_handle, |
1133 const DownloadCreateInfo& new_create_info) { | 1133 const DownloadCreateInfo& new_create_info) { |
1134 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1134 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1135 DCHECK(!download_file_.get()); | 1135 DCHECK(!download_file_.get()); |
1136 DVLOG(20) << __FUNCTION__ << "() this=" << DebugString(true); | 1136 DVLOG(20) << __func__ << "() this=" << DebugString(true); |
1137 | 1137 |
1138 download_file_ = std::move(file); | 1138 download_file_ = std::move(file); |
1139 request_handle_ = std::move(req_handle); | 1139 request_handle_ = std::move(req_handle); |
1140 destination_error_ = DOWNLOAD_INTERRUPT_REASON_NONE; | 1140 destination_error_ = DOWNLOAD_INTERRUPT_REASON_NONE; |
1141 | 1141 |
1142 if (state_ == CANCELLED_INTERNAL) { | 1142 if (state_ == CANCELLED_INTERNAL) { |
1143 // The download was in the process of resuming when it was cancelled. Don't | 1143 // The download was in the process of resuming when it was cancelled. Don't |
1144 // proceed. | 1144 // proceed. |
1145 ReleaseDownloadFile(true); | 1145 ReleaseDownloadFile(true); |
1146 if (request_handle_) | 1146 if (request_handle_) |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1209 // Safe because we control download file lifetime. | 1209 // Safe because we control download file lifetime. |
1210 base::Unretained(download_file_.get()), | 1210 base::Unretained(download_file_.get()), |
1211 base::Bind(&DownloadItemImpl::OnDownloadFileInitialized, | 1211 base::Bind(&DownloadItemImpl::OnDownloadFileInitialized, |
1212 weak_ptr_factory_.GetWeakPtr()))); | 1212 weak_ptr_factory_.GetWeakPtr()))); |
1213 } | 1213 } |
1214 | 1214 |
1215 void DownloadItemImpl::OnDownloadFileInitialized( | 1215 void DownloadItemImpl::OnDownloadFileInitialized( |
1216 DownloadInterruptReason result) { | 1216 DownloadInterruptReason result) { |
1217 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1217 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1218 DCHECK_EQ(state_, TARGET_PENDING_INTERNAL); | 1218 DCHECK_EQ(state_, TARGET_PENDING_INTERNAL); |
1219 DVLOG(20) << __FUNCTION__ | 1219 DVLOG(20) << __func__ |
1220 << "() result:" << DownloadInterruptReasonToString(result); | 1220 << "() result:" << DownloadInterruptReasonToString(result); |
1221 if (result != DOWNLOAD_INTERRUPT_REASON_NONE) { | 1221 if (result != DOWNLOAD_INTERRUPT_REASON_NONE) { |
1222 // Whoops. That didn't work. Proceed as an interrupted download, but reset | 1222 // Whoops. That didn't work. Proceed as an interrupted download, but reset |
1223 // the partial state. Currently, the partial stub cannot be recovered if the | 1223 // the partial state. Currently, the partial stub cannot be recovered if the |
1224 // download file initialization fails. | 1224 // download file initialization fails. |
1225 received_bytes_ = 0; | 1225 received_bytes_ = 0; |
1226 hash_state_.reset(); | 1226 hash_state_.reset(); |
1227 hash_.clear(); | 1227 hash_.clear(); |
1228 destination_error_ = result; | 1228 destination_error_ = result; |
1229 TransitionTo(INTERRUPTED_TARGET_PENDING_INTERNAL); | 1229 TransitionTo(INTERRUPTED_TARGET_PENDING_INTERNAL); |
1230 } | 1230 } |
1231 | 1231 |
1232 DetermineDownloadTarget(); | 1232 DetermineDownloadTarget(); |
1233 } | 1233 } |
1234 | 1234 |
1235 void DownloadItemImpl::DetermineDownloadTarget() { | 1235 void DownloadItemImpl::DetermineDownloadTarget() { |
1236 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1236 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1237 DVLOG(20) << __FUNCTION__ << "() " << DebugString(true); | 1237 DVLOG(20) << __func__ << "() " << DebugString(true); |
1238 | 1238 |
1239 delegate_->DetermineDownloadTarget( | 1239 delegate_->DetermineDownloadTarget( |
1240 this, base::Bind(&DownloadItemImpl::OnDownloadTargetDetermined, | 1240 this, base::Bind(&DownloadItemImpl::OnDownloadTargetDetermined, |
1241 weak_ptr_factory_.GetWeakPtr())); | 1241 weak_ptr_factory_.GetWeakPtr())); |
1242 } | 1242 } |
1243 | 1243 |
1244 // Called by delegate_ when the download target path has been determined. | 1244 // Called by delegate_ when the download target path has been determined. |
1245 void DownloadItemImpl::OnDownloadTargetDetermined( | 1245 void DownloadItemImpl::OnDownloadTargetDetermined( |
1246 const base::FilePath& target_path, | 1246 const base::FilePath& target_path, |
1247 TargetDisposition disposition, | 1247 TargetDisposition disposition, |
1248 DownloadDangerType danger_type, | 1248 DownloadDangerType danger_type, |
1249 const base::FilePath& intermediate_path) { | 1249 const base::FilePath& intermediate_path) { |
1250 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1250 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1251 DCHECK(state_ == TARGET_PENDING_INTERNAL || | 1251 DCHECK(state_ == TARGET_PENDING_INTERNAL || |
1252 state_ == INTERRUPTED_TARGET_PENDING_INTERNAL); | 1252 state_ == INTERRUPTED_TARGET_PENDING_INTERNAL); |
1253 | 1253 |
1254 // If the |target_path| is empty, then we consider this download to be | 1254 // If the |target_path| is empty, then we consider this download to be |
1255 // canceled. | 1255 // canceled. |
1256 if (target_path.empty()) { | 1256 if (target_path.empty()) { |
1257 Cancel(true); | 1257 Cancel(true); |
1258 return; | 1258 return; |
1259 } | 1259 } |
1260 | 1260 |
1261 DVLOG(20) << __FUNCTION__ << "() target_path:" << target_path.value() | 1261 DVLOG(20) << __func__ << "() target_path:" << target_path.value() |
1262 << " disposition:" << disposition << " danger_type:" << danger_type | 1262 << " disposition:" << disposition << " danger_type:" << danger_type |
1263 << " this:" << DebugString(true); | 1263 << " this:" << DebugString(true); |
1264 | 1264 |
1265 target_path_ = target_path; | 1265 target_path_ = target_path; |
1266 target_disposition_ = disposition; | 1266 target_disposition_ = disposition; |
1267 SetDangerType(danger_type); | 1267 SetDangerType(danger_type); |
1268 | 1268 |
1269 // This was an interrupted download that was looking for a filename. Now that | 1269 // This was an interrupted download that was looking for a filename. Now that |
1270 // it has one, transition to interrupted. | 1270 // it has one, transition to interrupted. |
1271 if (state_ == INTERRUPTED_TARGET_PENDING_INTERNAL) { | 1271 if (state_ == INTERRUPTED_TARGET_PENDING_INTERNAL) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1310 // Safe because we control download file lifetime. | 1310 // Safe because we control download file lifetime. |
1311 base::Unretained(download_file_.get()), | 1311 base::Unretained(download_file_.get()), |
1312 intermediate_path, callback)); | 1312 intermediate_path, callback)); |
1313 } | 1313 } |
1314 | 1314 |
1315 void DownloadItemImpl::OnDownloadRenamedToIntermediateName( | 1315 void DownloadItemImpl::OnDownloadRenamedToIntermediateName( |
1316 DownloadInterruptReason reason, | 1316 DownloadInterruptReason reason, |
1317 const base::FilePath& full_path) { | 1317 const base::FilePath& full_path) { |
1318 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1318 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1319 DCHECK_EQ(state_, TARGET_PENDING_INTERNAL); | 1319 DCHECK_EQ(state_, TARGET_PENDING_INTERNAL); |
1320 DVLOG(20) << __FUNCTION__ << " download=" << DebugString(true); | 1320 DVLOG(20) << __func__ << "() download=" << DebugString(true); |
1321 | 1321 |
1322 TransitionTo(TARGET_RESOLVED_INTERNAL); | 1322 TransitionTo(TARGET_RESOLVED_INTERNAL); |
1323 | 1323 |
1324 // If the intermediate rename fails while there's also a destination_error_, | 1324 // If the intermediate rename fails while there's also a destination_error_, |
1325 // then the former is considered the critical error since it requires | 1325 // then the former is considered the critical error since it requires |
1326 // discarding the partial state. | 1326 // discarding the partial state. |
1327 if (DOWNLOAD_INTERRUPT_REASON_NONE != reason) { | 1327 if (DOWNLOAD_INTERRUPT_REASON_NONE != reason) { |
1328 // TODO(asanka): Even though the rename failed, it may still be possible to | 1328 // TODO(asanka): Even though the rename failed, it may still be possible to |
1329 // recover the partial state from the 'before' name. | 1329 // recover the partial state from the 'before' name. |
1330 InterruptAndDiscardPartialState(reason); | 1330 InterruptAndDiscardPartialState(reason); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1378 } | 1378 } |
1379 | 1379 |
1380 // Called by MaybeCompleteDownload() when it has determined that the download | 1380 // Called by MaybeCompleteDownload() when it has determined that the download |
1381 // is ready for completion. | 1381 // is ready for completion. |
1382 void DownloadItemImpl::OnDownloadCompleting() { | 1382 void DownloadItemImpl::OnDownloadCompleting() { |
1383 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1383 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1384 | 1384 |
1385 if (state_ != IN_PROGRESS_INTERNAL) | 1385 if (state_ != IN_PROGRESS_INTERNAL) |
1386 return; | 1386 return; |
1387 | 1387 |
1388 DVLOG(20) << __FUNCTION__ << "()" | 1388 DVLOG(20) << __func__ << "() " << DebugString(true); |
1389 << " " << DebugString(true); | |
1390 DCHECK(!GetTargetFilePath().empty()); | 1389 DCHECK(!GetTargetFilePath().empty()); |
1391 DCHECK(!IsDangerous()); | 1390 DCHECK(!IsDangerous()); |
1392 | 1391 |
1393 // TODO(rdsmith/benjhayden): Remove as part of SavePackage integration. | 1392 // TODO(rdsmith/benjhayden): Remove as part of SavePackage integration. |
1394 if (is_save_package_download_) { | 1393 if (is_save_package_download_) { |
1395 // Avoid doing anything on the file thread; there's nothing we control | 1394 // Avoid doing anything on the file thread; there's nothing we control |
1396 // there. Strictly speaking, this skips giving the embedder a chance to | 1395 // there. Strictly speaking, this skips giving the embedder a chance to |
1397 // open the download. But on a save package download, there's no real | 1396 // open the download. But on a save package download, there's no real |
1398 // concept of opening. | 1397 // concept of opening. |
1399 Completed(); | 1398 Completed(); |
(...skipping 23 matching lines...) Expand all Loading... |
1423 const base::FilePath& full_path) { | 1422 const base::FilePath& full_path) { |
1424 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1423 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1425 DCHECK(!is_save_package_download_); | 1424 DCHECK(!is_save_package_download_); |
1426 | 1425 |
1427 // If a cancel or interrupt hit, we'll cancel the DownloadFile, which | 1426 // If a cancel or interrupt hit, we'll cancel the DownloadFile, which |
1428 // will result in deleting the file on the file thread. So we don't | 1427 // will result in deleting the file on the file thread. So we don't |
1429 // care about the name having been changed. | 1428 // care about the name having been changed. |
1430 if (state_ != IN_PROGRESS_INTERNAL) | 1429 if (state_ != IN_PROGRESS_INTERNAL) |
1431 return; | 1430 return; |
1432 | 1431 |
1433 DVLOG(20) << __FUNCTION__ << "()" | 1432 DVLOG(20) << __func__ << "() full_path = \"" << full_path.value() << "\" " |
1434 << " full_path = \"" << full_path.value() << "\"" | 1433 << DebugString(false); |
1435 << " " << DebugString(false); | |
1436 | 1434 |
1437 if (DOWNLOAD_INTERRUPT_REASON_NONE != reason) { | 1435 if (DOWNLOAD_INTERRUPT_REASON_NONE != reason) { |
1438 // Failure to perform the final rename is considered fatal. TODO(asanka): It | 1436 // Failure to perform the final rename is considered fatal. TODO(asanka): It |
1439 // may not be, in which case we should figure out whether we can recover the | 1437 // may not be, in which case we should figure out whether we can recover the |
1440 // state. | 1438 // state. |
1441 InterruptAndDiscardPartialState(reason); | 1439 InterruptAndDiscardPartialState(reason); |
1442 UpdateObservers(); | 1440 UpdateObservers(); |
1443 return; | 1441 return; |
1444 } | 1442 } |
1445 | 1443 |
(...skipping 28 matching lines...) Expand all Loading... |
1474 void DownloadItemImpl::DelayedDownloadOpened(bool auto_opened) { | 1472 void DownloadItemImpl::DelayedDownloadOpened(bool auto_opened) { |
1475 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1473 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1476 | 1474 |
1477 auto_opened_ = auto_opened; | 1475 auto_opened_ = auto_opened; |
1478 Completed(); | 1476 Completed(); |
1479 } | 1477 } |
1480 | 1478 |
1481 void DownloadItemImpl::Completed() { | 1479 void DownloadItemImpl::Completed() { |
1482 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1480 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1483 | 1481 |
1484 DVLOG(20) << __FUNCTION__ << "() " << DebugString(false); | 1482 DVLOG(20) << __func__ << "() " << DebugString(false); |
1485 | 1483 |
1486 DCHECK(all_data_saved_); | 1484 DCHECK(all_data_saved_); |
1487 end_time_ = base::Time::Now(); | 1485 end_time_ = base::Time::Now(); |
1488 TransitionTo(COMPLETE_INTERNAL); | 1486 TransitionTo(COMPLETE_INTERNAL); |
1489 RecordDownloadCompleted(start_tick_, received_bytes_); | 1487 RecordDownloadCompleted(start_tick_, received_bytes_); |
1490 | 1488 |
1491 if (auto_opened_) { | 1489 if (auto_opened_) { |
1492 // If it was already handled by the delegate, do nothing. | 1490 // If it was already handled by the delegate, do nothing. |
1493 } else if (GetOpenWhenComplete() || | 1491 } else if (GetOpenWhenComplete() || |
1494 ShouldOpenFileBasedOnExtension() || | 1492 ShouldOpenFileBasedOnExtension() || |
(...skipping 15 matching lines...) Expand all Loading... |
1510 DownloadInterruptReason reason) { | 1508 DownloadInterruptReason reason) { |
1511 InterruptWithPartialState(0, std::unique_ptr<crypto::SecureHash>(), reason); | 1509 InterruptWithPartialState(0, std::unique_ptr<crypto::SecureHash>(), reason); |
1512 } | 1510 } |
1513 | 1511 |
1514 void DownloadItemImpl::InterruptWithPartialState( | 1512 void DownloadItemImpl::InterruptWithPartialState( |
1515 int64_t bytes_so_far, | 1513 int64_t bytes_so_far, |
1516 std::unique_ptr<crypto::SecureHash> hash_state, | 1514 std::unique_ptr<crypto::SecureHash> hash_state, |
1517 DownloadInterruptReason reason) { | 1515 DownloadInterruptReason reason) { |
1518 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1516 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1519 DCHECK_NE(DOWNLOAD_INTERRUPT_REASON_NONE, reason); | 1517 DCHECK_NE(DOWNLOAD_INTERRUPT_REASON_NONE, reason); |
1520 DVLOG(20) << __FUNCTION__ | 1518 DVLOG(20) << __func__ |
1521 << "() reason:" << DownloadInterruptReasonToString(reason) | 1519 << "() reason:" << DownloadInterruptReasonToString(reason) |
1522 << " bytes_so_far:" << bytes_so_far | 1520 << " bytes_so_far:" << bytes_so_far |
1523 << " hash_state:" << (hash_state ? "Valid" : "Invalid") | 1521 << " hash_state:" << (hash_state ? "Valid" : "Invalid") |
1524 << " this=" << DebugString(true); | 1522 << " this=" << DebugString(true); |
1525 | 1523 |
1526 // Somewhat counter-intuitively, it is possible for us to receive an | 1524 // Somewhat counter-intuitively, it is possible for us to receive an |
1527 // interrupt after we've already been interrupted. The generation of | 1525 // interrupt after we've already been interrupted. The generation of |
1528 // interrupts from the file thread Renames and the generation of | 1526 // interrupts from the file thread Renames and the generation of |
1529 // interrupts from disk writes go through two different mechanisms (driven | 1527 // interrupts from disk writes go through two different mechanisms (driven |
1530 // by rename requests from UI thread and by write requests from IO thread, | 1528 // by rename requests from UI thread and by write requests from IO thread, |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1648 } | 1646 } |
1649 | 1647 |
1650 std::unique_ptr<crypto::SecureHash> clone_of_hash_state(hash_state_->Clone()); | 1648 std::unique_ptr<crypto::SecureHash> clone_of_hash_state(hash_state_->Clone()); |
1651 std::vector<char> hash_value(clone_of_hash_state->GetHashLength()); | 1649 std::vector<char> hash_value(clone_of_hash_state->GetHashLength()); |
1652 clone_of_hash_state->Finish(&hash_value.front(), hash_value.size()); | 1650 clone_of_hash_state->Finish(&hash_value.front(), hash_value.size()); |
1653 hash_.assign(hash_value.begin(), hash_value.end()); | 1651 hash_.assign(hash_value.begin(), hash_value.end()); |
1654 } | 1652 } |
1655 | 1653 |
1656 void DownloadItemImpl::ReleaseDownloadFile(bool destroy_file) { | 1654 void DownloadItemImpl::ReleaseDownloadFile(bool destroy_file) { |
1657 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1655 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1658 DVLOG(20) << __FUNCTION__ << "() destroy_file:" << destroy_file; | 1656 DVLOG(20) << __func__ << "() destroy_file:" << destroy_file; |
1659 | 1657 |
1660 if (destroy_file) { | 1658 if (destroy_file) { |
1661 BrowserThread::PostTask( | 1659 BrowserThread::PostTask( |
1662 BrowserThread::FILE, FROM_HERE, | 1660 BrowserThread::FILE, FROM_HERE, |
1663 // Will be deleted at end of task execution. | 1661 // Will be deleted at end of task execution. |
1664 base::Bind(&DownloadFileCancel, base::Passed(&download_file_))); | 1662 base::Bind(&DownloadFileCancel, base::Passed(&download_file_))); |
1665 // Avoid attempting to reuse the intermediate file by clearing out | 1663 // Avoid attempting to reuse the intermediate file by clearing out |
1666 // current_path_. | 1664 // current_path_. |
1667 current_path_.clear(); | 1665 current_path_.clear(); |
1668 } else { | 1666 } else { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1786 bound_net_log_.AddEvent( | 1784 bound_net_log_.AddEvent( |
1787 net::NetLog::TYPE_DOWNLOAD_ITEM_CANCELED, | 1785 net::NetLog::TYPE_DOWNLOAD_ITEM_CANCELED, |
1788 base::Bind(&ItemCanceledNetLogCallback, received_bytes_)); | 1786 base::Bind(&ItemCanceledNetLogCallback, received_bytes_)); |
1789 break; | 1787 break; |
1790 | 1788 |
1791 case MAX_DOWNLOAD_INTERNAL_STATE: | 1789 case MAX_DOWNLOAD_INTERNAL_STATE: |
1792 NOTREACHED(); | 1790 NOTREACHED(); |
1793 break; | 1791 break; |
1794 } | 1792 } |
1795 | 1793 |
1796 DVLOG(20) << " " << __FUNCTION__ << "()" | 1794 DVLOG(20) << __func__ << "() from:" << DebugDownloadStateString(old_state) |
1797 << " from:" << DebugDownloadStateString(old_state) | |
1798 << " to:" << DebugDownloadStateString(state_) | 1795 << " to:" << DebugDownloadStateString(state_) |
1799 << " this = " << DebugString(true); | 1796 << " this = " << DebugString(true); |
1800 bool is_done = | 1797 bool is_done = |
1801 (state_ == COMPLETE_INTERNAL || state_ == INTERRUPTED_INTERNAL || | 1798 (state_ == COMPLETE_INTERNAL || state_ == INTERRUPTED_INTERNAL || |
1802 state_ == RESUMING_INTERNAL || state_ == CANCELLED_INTERNAL); | 1799 state_ == RESUMING_INTERNAL || state_ == CANCELLED_INTERNAL); |
1803 bool was_done = | 1800 bool was_done = |
1804 (old_state == COMPLETE_INTERNAL || old_state == INTERRUPTED_INTERNAL || | 1801 (old_state == COMPLETE_INTERNAL || old_state == INTERRUPTED_INTERNAL || |
1805 old_state == RESUMING_INTERNAL || old_state == CANCELLED_INTERNAL); | 1802 old_state == RESUMING_INTERNAL || old_state == CANCELLED_INTERNAL); |
1806 | 1803 |
1807 // Termination | 1804 // Termination |
(...skipping 26 matching lines...) Expand all Loading... |
1834 danger_type == DOWNLOAD_DANGER_TYPE_DANGEROUS_URL || | 1831 danger_type == DOWNLOAD_DANGER_TYPE_DANGEROUS_URL || |
1835 danger_type == DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT || | 1832 danger_type == DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT || |
1836 danger_type == DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED)) { | 1833 danger_type == DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED)) { |
1837 RecordMaliciousDownloadClassified(danger_type); | 1834 RecordMaliciousDownloadClassified(danger_type); |
1838 } | 1835 } |
1839 danger_type_ = danger_type; | 1836 danger_type_ = danger_type; |
1840 } | 1837 } |
1841 | 1838 |
1842 void DownloadItemImpl::SetFullPath(const base::FilePath& new_path) { | 1839 void DownloadItemImpl::SetFullPath(const base::FilePath& new_path) { |
1843 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1840 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1844 DVLOG(20) << __FUNCTION__ << "()" | 1841 DVLOG(20) << __func__ << "() new_path = \"" << new_path.value() << "\" " |
1845 << " new_path = \"" << new_path.value() << "\"" | 1842 << DebugString(true); |
1846 << " " << DebugString(true); | |
1847 DCHECK(!new_path.empty()); | 1843 DCHECK(!new_path.empty()); |
1848 | 1844 |
1849 bound_net_log_.AddEvent( | 1845 bound_net_log_.AddEvent( |
1850 net::NetLog::TYPE_DOWNLOAD_ITEM_RENAMED, | 1846 net::NetLog::TYPE_DOWNLOAD_ITEM_RENAMED, |
1851 base::Bind(&ItemRenamedNetLogCallback, ¤t_path_, &new_path)); | 1847 base::Bind(&ItemRenamedNetLogCallback, ¤t_path_, &new_path)); |
1852 | 1848 |
1853 current_path_ = new_path; | 1849 current_path_ = new_path; |
1854 } | 1850 } |
1855 | 1851 |
1856 void DownloadItemImpl::AutoResumeIfValid() { | 1852 void DownloadItemImpl::AutoResumeIfValid() { |
1857 DVLOG(20) << __FUNCTION__ << "() " << DebugString(true); | 1853 DVLOG(20) << __func__ << "() " << DebugString(true); |
1858 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1854 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1859 ResumeMode mode = GetResumeMode(); | 1855 ResumeMode mode = GetResumeMode(); |
1860 | 1856 |
1861 if (mode != RESUME_MODE_IMMEDIATE_RESTART && | 1857 if (mode != RESUME_MODE_IMMEDIATE_RESTART && |
1862 mode != RESUME_MODE_IMMEDIATE_CONTINUE) { | 1858 mode != RESUME_MODE_IMMEDIATE_CONTINUE) { |
1863 return; | 1859 return; |
1864 } | 1860 } |
1865 | 1861 |
1866 auto_resume_count_++; | 1862 auto_resume_count_++; |
1867 | 1863 |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2093 case RESUME_MODE_USER_CONTINUE: | 2089 case RESUME_MODE_USER_CONTINUE: |
2094 return "USER_CONTINUE"; | 2090 return "USER_CONTINUE"; |
2095 case RESUME_MODE_USER_RESTART: | 2091 case RESUME_MODE_USER_RESTART: |
2096 return "USER_RESTART"; | 2092 return "USER_RESTART"; |
2097 } | 2093 } |
2098 NOTREACHED() << "Unknown resume mode " << mode; | 2094 NOTREACHED() << "Unknown resume mode " << mode; |
2099 return "unknown"; | 2095 return "unknown"; |
2100 } | 2096 } |
2101 | 2097 |
2102 } // namespace content | 2098 } // namespace content |
OLD | NEW |