OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "content/browser/download/download_resource_handler.h" | 5 #include "content/browser/download/download_resource_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 CallStartedCB(net::OK); | 122 CallStartedCB(net::OK); |
123 | 123 |
124 std::string content_type_header; | 124 std::string content_type_header; |
125 if (!response->headers || | 125 if (!response->headers || |
126 !response->headers->GetMimeType(&content_type_header)) | 126 !response->headers->GetMimeType(&content_type_header)) |
127 content_type_header = ""; | 127 content_type_header = ""; |
128 info->original_mime_type = content_type_header; | 128 info->original_mime_type = content_type_header; |
129 | 129 |
130 if (!response->headers || | 130 if (!response->headers || |
131 !response->headers->EnumerateHeader(NULL, | 131 !response->headers->EnumerateHeader(NULL, |
132 "Accepts-Ranges", | 132 "Accept-Ranges", |
133 &accepts_ranges_)) { | 133 &accept_ranges_)) { |
134 accepts_ranges_ = ""; | 134 accept_ranges_ = ""; |
135 } | 135 } |
136 | 136 |
137 info->prompt_user_for_save_location = | 137 info->prompt_user_for_save_location = |
138 save_as_ && save_info_.file_path.empty(); | 138 save_as_ && save_info_.file_path.empty(); |
139 info->referrer_charset = request_->context()->referrer_charset(); | 139 info->referrer_charset = request_->context()->referrer_charset(); |
140 info->save_info = save_info_; | 140 info->save_info = save_info_; |
141 BrowserThread::PostTask( | 141 BrowserThread::PostTask( |
142 BrowserThread::UI, FROM_HERE, | 142 BrowserThread::UI, FROM_HERE, |
143 base::Bind(&DownloadFileManager::StartDownload, | 143 base::Bind(&DownloadFileManager::StartDownload, |
144 download_file_manager_, info, request_handle)); | 144 download_file_manager_, info, request_handle)); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 InterruptReason reason = | 241 InterruptReason reason = |
242 ConvertNetErrorToInterruptReason(error_code, | 242 ConvertNetErrorToInterruptReason(error_code, |
243 DOWNLOAD_INTERRUPT_FROM_NETWORK); | 243 DOWNLOAD_INTERRUPT_FROM_NETWORK); |
244 if ((status.status() == net::URLRequestStatus::CANCELED) && | 244 if ((status.status() == net::URLRequestStatus::CANCELED) && |
245 (status.error() == net::ERR_ABORTED)) { | 245 (status.error() == net::ERR_ABORTED)) { |
246 // TODO(ahendrickson) -- Find a better set of codes to use here, as | 246 // TODO(ahendrickson) -- Find a better set of codes to use here, as |
247 // CANCELED/ERR_ABORTED can occur for reasons other than user cancel. | 247 // CANCELED/ERR_ABORTED can occur for reasons other than user cancel. |
248 reason = DOWNLOAD_INTERRUPT_REASON_USER_CANCELED; // User canceled. | 248 reason = DOWNLOAD_INTERRUPT_REASON_USER_CANCELED; // User canceled. |
249 } | 249 } |
250 | 250 |
251 download_stats::RecordAcceptsRanges(accepts_ranges_, bytes_read_); | 251 download_stats::RecordAcceptsRanges(accept_ranges_, bytes_read_); |
252 | 252 |
253 if (!download_id_.IsValid()) | 253 if (!download_id_.IsValid()) |
254 CallStartedCB(error_code); | 254 CallStartedCB(error_code); |
255 // We transfer ownership to |DownloadFileManager| to delete |buffer_|, | 255 // We transfer ownership to |DownloadFileManager| to delete |buffer_|, |
256 // so that any functions queued up on the FILE thread are executed | 256 // so that any functions queued up on the FILE thread are executed |
257 // before deletion. | 257 // before deletion. |
258 BrowserThread::PostTask( | 258 BrowserThread::PostTask( |
259 BrowserThread::FILE, FROM_HERE, | 259 BrowserThread::FILE, FROM_HERE, |
260 base::Bind(&DownloadFileManager::OnResponseCompleted, | 260 base::Bind(&DownloadFileManager::OnResponseCompleted, |
261 download_file_manager_, download_id_, reason, security_info)); | 261 download_file_manager_, download_id_, reason, security_info)); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 " render_view_id_ = " "%d" | 323 " render_view_id_ = " "%d" |
324 " save_info_.file_path = \"%" PRFilePath "\"" | 324 " save_info_.file_path = \"%" PRFilePath "\"" |
325 " }", | 325 " }", |
326 request_->url().spec().c_str(), | 326 request_->url().spec().c_str(), |
327 download_id_.local(), | 327 download_id_.local(), |
328 global_id_.child_id, | 328 global_id_.child_id, |
329 global_id_.request_id, | 329 global_id_.request_id, |
330 render_view_id_, | 330 render_view_id_, |
331 save_info_.file_path.value().c_str()); | 331 save_info_.file_path.value().c_str()); |
332 } | 332 } |
OLD | NEW |