Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: content/browser/download/download_item_impl.cc

Issue 2811293004: Fix an issue that we didn't clean url request properly. (Closed)
Patch Set: Fixed compiling for unit tests. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 1108
1109 DCHECK(all_data_saved_); 1109 DCHECK(all_data_saved_);
1110 end_time_ = base::Time::Now(); 1110 end_time_ = base::Time::Now();
1111 TransitionTo(COMPLETE_INTERNAL); 1111 TransitionTo(COMPLETE_INTERNAL);
1112 UpdateObservers(); 1112 UpdateObservers();
1113 } 1113 }
1114 1114
1115 void DownloadItemImpl::DestinationUpdate( 1115 void DownloadItemImpl::DestinationUpdate(
1116 int64_t bytes_so_far, 1116 int64_t bytes_so_far,
1117 int64_t bytes_per_sec, 1117 int64_t bytes_per_sec,
1118 const std::vector<DownloadItem::ReceivedSlice>& received_slices) { 1118 const std::vector<DownloadItem::ReceivedSlice>& received_slices,
1119 const std::unordered_set<int64_t>& stream_to_close) {
1119 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1120 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1120 // If the download is in any other state we don't expect any 1121 // If the download is in any other state we don't expect any
1121 // DownloadDestinationObserver callbacks. An interruption or a cancellation 1122 // DownloadDestinationObserver callbacks. An interruption or a cancellation
1122 // results in a call to ReleaseDownloadFile which invalidates the weak 1123 // results in a call to ReleaseDownloadFile which invalidates the weak
1123 // reference held by the DownloadFile and hence cuts off any pending 1124 // reference held by the DownloadFile and hence cuts off any pending
1124 // callbacks. 1125 // callbacks.
1125 DCHECK(state_ == TARGET_PENDING_INTERNAL || state_ == IN_PROGRESS_INTERNAL); 1126 DCHECK(state_ == TARGET_PENDING_INTERNAL || state_ == IN_PROGRESS_INTERNAL);
1126 1127
1127 // There must be no pending deferred_interrupt_reason_. 1128 // There must be no pending deferred_interrupt_reason_.
1128 DCHECK_EQ(deferred_interrupt_reason_, DOWNLOAD_INTERRUPT_REASON_NONE); 1129 DCHECK_EQ(deferred_interrupt_reason_, DOWNLOAD_INTERRUPT_REASON_NONE);
1129 1130
1130 DVLOG(20) << __func__ << "() so_far=" << bytes_so_far 1131 DVLOG(20) << __func__ << "() so_far=" << bytes_so_far
1131 << " per_sec=" << bytes_per_sec 1132 << " per_sec=" << bytes_per_sec
1132 << " download=" << DebugString(true); 1133 << " download=" << DebugString(true);
1133 1134
1134 UpdateProgress(bytes_so_far, bytes_per_sec); 1135 UpdateProgress(bytes_so_far, bytes_per_sec);
1135 received_slices_ = received_slices; 1136 received_slices_ = received_slices;
1137
1138 if (job_) {
1139 for (int64_t offset : stream_to_close)
1140 job_->CancelRequest(offset);
1141 }
1142
1136 if (net_log_.IsCapturing()) { 1143 if (net_log_.IsCapturing()) {
1137 net_log_.AddEvent( 1144 net_log_.AddEvent(
1138 net::NetLogEventType::DOWNLOAD_ITEM_UPDATED, 1145 net::NetLogEventType::DOWNLOAD_ITEM_UPDATED,
1139 net::NetLog::Int64Callback("bytes_so_far", received_bytes_)); 1146 net::NetLog::Int64Callback("bytes_so_far", received_bytes_));
1140 } 1147 }
1141 1148
1142 UpdateObservers(); 1149 UpdateObservers();
1143 } 1150 }
1144 1151
1145 void DownloadItemImpl::DestinationError( 1152 void DownloadItemImpl::DestinationError(
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after
2254 case RESUME_MODE_USER_CONTINUE: 2261 case RESUME_MODE_USER_CONTINUE:
2255 return "USER_CONTINUE"; 2262 return "USER_CONTINUE";
2256 case RESUME_MODE_USER_RESTART: 2263 case RESUME_MODE_USER_RESTART:
2257 return "USER_RESTART"; 2264 return "USER_RESTART";
2258 } 2265 }
2259 NOTREACHED() << "Unknown resume mode " << mode; 2266 NOTREACHED() << "Unknown resume mode " << mode;
2260 return "unknown"; 2267 return "unknown";
2261 } 2268 }
2262 2269
2263 } // namespace content 2270 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698