| 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 #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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 std::string content_disposition; | 89 std::string content_disposition; |
| 90 request_->GetResponseHeaderByName("content-disposition", | 90 request_->GetResponseHeaderByName("content-disposition", |
| 91 &content_disposition); | 91 &content_disposition); |
| 92 set_content_disposition(content_disposition); | 92 set_content_disposition(content_disposition); |
| 93 set_content_length(response->content_length); | 93 set_content_length(response->content_length); |
| 94 | 94 |
| 95 const ResourceDispatcherHostRequestInfo* request_info = | 95 const ResourceDispatcherHostRequestInfo* request_info = |
| 96 ResourceDispatcherHost::InfoForRequest(request_); | 96 ResourceDispatcherHost::InfoForRequest(request_); |
| 97 | 97 |
| 98 // Deleted in DownloadManager. | 98 // Deleted in DownloadManager. |
| 99 scoped_ptr<DownloadCreateInfo> info(new DownloadCreateInfo(FilePath(), GURL(), | 99 scoped_ptr<DownloadCreateInfo> info(new DownloadCreateInfo( |
| 100 base::Time::Now(), 0, content_length_, DownloadItem::IN_PROGRESS, | 100 base::Time::Now(), 0, content_length_, DownloadItem::IN_PROGRESS, |
| 101 request_info->has_user_gesture(), request_info->transition_type())); | 101 request_info->has_user_gesture(), request_info->transition_type())); |
| 102 info->url_chain = request_->url_chain(); | 102 info->url_chain = request_->url_chain(); |
| 103 info->referrer_url = GURL(request_->referrer()); | 103 info->referrer_url = GURL(request_->referrer()); |
| 104 info->start_time = base::Time::Now(); | 104 info->start_time = base::Time::Now(); |
| 105 info->received_bytes = save_info_.offset; | 105 info->received_bytes = save_info_.offset; |
| 106 info->total_bytes = content_length_; | 106 info->total_bytes = content_length_; |
| 107 info->state = DownloadItem::IN_PROGRESS; | 107 info->state = DownloadItem::IN_PROGRESS; |
| 108 info->has_user_gesture = request_info->has_user_gesture(); | 108 info->has_user_gesture = request_info->has_user_gesture(); |
| 109 info->content_disposition = content_disposition_; | 109 info->content_disposition = content_disposition_; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 if (!download_id_.IsValid()) { | 234 if (!download_id_.IsValid()) { |
| 235 // We got cancelled before the task which sets the id ran on the IO thread. | 235 // We got cancelled before the task which sets the id ran on the IO thread. |
| 236 // Wait for it. | 236 // Wait for it. |
| 237 BrowserThread::PostTask( | 237 BrowserThread::PostTask( |
| 238 BrowserThread::UI, FROM_HERE, | 238 BrowserThread::UI, FROM_HERE, |
| 239 base::Bind(base::IgnoreResult(&BrowserThread::PostTask), | 239 base::Bind(base::IgnoreResult(&BrowserThread::PostTask), |
| 240 BrowserThread::IO, FROM_HERE, | 240 BrowserThread::IO, FROM_HERE, |
| 241 base::Bind(base::IgnoreResult( | 241 base::Bind(base::IgnoreResult( |
| 242 &DownloadResourceHandler::OnResponseCompleted), this, | 242 &DownloadResourceHandler::OnResponseCompleted), this, |
| 243 request_id, status, security_info))); | 243 request_id, status, security_info))); |
| 244 | |
| 245 return true; | 244 return true; |
| 246 } | 245 } |
| 247 | 246 |
| 248 VLOG(20) << __FUNCTION__ << "()" << DebugString() | 247 VLOG(20) << __FUNCTION__ << "()" << DebugString() |
| 249 << " request_id = " << request_id | 248 << " request_id = " << request_id |
| 250 << " status.status() = " << status.status() | 249 << " status.status() = " << status.status() |
| 251 << " status.error() = " << status.error(); | 250 << " status.error() = " << status.error(); |
| 252 net::Error error_code = net::OK; | 251 net::Error error_code = net::OK; |
| 253 if (status.status() == net::URLRequestStatus::FAILED) | 252 if (status.status() == net::URLRequestStatus::FAILED) |
| 254 error_code = static_cast<net::Error>(status.error()); // Normal case. | 253 error_code = static_cast<net::Error>(status.error()); // Normal case. |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 " render_view_id_ = " "%d" | 374 " render_view_id_ = " "%d" |
| 376 " save_info_.file_path = \"%" PRFilePath "\"" | 375 " save_info_.file_path = \"%" PRFilePath "\"" |
| 377 " }", | 376 " }", |
| 378 request_->url().spec().c_str(), | 377 request_->url().spec().c_str(), |
| 379 download_id_.local(), | 378 download_id_.local(), |
| 380 global_id_.child_id, | 379 global_id_.child_id, |
| 381 global_id_.request_id, | 380 global_id_.request_id, |
| 382 render_view_id_, | 381 render_view_id_, |
| 383 save_info_.file_path.value().c_str()); | 382 save_info_.file_path.value().c_str()); |
| 384 } | 383 } |
| OLD | NEW |