| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 ResourceDispatcherHost::InfoForRequest(request_); | 98 ResourceDispatcherHost::InfoForRequest(request_); |
| 99 | 99 |
| 100 // Deleted in DownloadManager. | 100 // Deleted in DownloadManager. |
| 101 DownloadCreateInfo* info = new DownloadCreateInfo(FilePath(), GURL(), | 101 DownloadCreateInfo* info = new DownloadCreateInfo(FilePath(), GURL(), |
| 102 base::Time::Now(), 0, content_length_, DownloadItem::IN_PROGRESS, | 102 base::Time::Now(), 0, content_length_, DownloadItem::IN_PROGRESS, |
| 103 download_id_, request_info->has_user_gesture(), | 103 download_id_, request_info->has_user_gesture(), |
| 104 request_info->transition_type()); | 104 request_info->transition_type()); |
| 105 info->url_chain = request_->url_chain(); | 105 info->url_chain = request_->url_chain(); |
| 106 info->referrer_url = GURL(request_->referrer()); | 106 info->referrer_url = GURL(request_->referrer()); |
| 107 info->start_time = base::Time::Now(); | 107 info->start_time = base::Time::Now(); |
| 108 info->received_bytes = 0; | 108 info->received_bytes = save_info_.offset; |
| 109 info->total_bytes = content_length_; | 109 info->total_bytes = content_length_; |
| 110 info->state = DownloadItem::IN_PROGRESS; | 110 info->state = DownloadItem::IN_PROGRESS; |
| 111 info->download_id = download_id_; | 111 info->download_id = download_id_; |
| 112 info->has_user_gesture = request_info->has_user_gesture(); | 112 info->has_user_gesture = request_info->has_user_gesture(); |
| 113 info->content_disposition = content_disposition_; | 113 info->content_disposition = content_disposition_; |
| 114 info->mime_type = response->mime_type; | 114 info->mime_type = response->mime_type; |
| 115 info->remote_address = request_->GetSocketAddress().host(); | 115 info->remote_address = request_->GetSocketAddress().host(); |
| 116 download_stats::RecordDownloadMimeType(info->mime_type); | 116 download_stats::RecordDownloadMimeType(info->mime_type); |
| 117 | 117 |
| 118 DownloadRequestHandle request_handle(rdh_, global_id_.child_id, | 118 DownloadRequestHandle request_handle(rdh_, global_id_.child_id, |
| 119 render_view_id_, global_id_.request_id); | 119 render_view_id_, global_id_.request_id); |
| 120 | 120 |
| 121 // TODO(ahendrickson) -- Get the last modified time and etag, so we can | 121 // Get the last modified time and etag. |
| 122 // resume downloading. | 122 const net::HttpResponseHeaders* headers = request_->response_headers(); |
| 123 if (headers) { |
| 124 std::string last_modified_hdr; |
| 125 std::string etag; |
| 126 if (headers->EnumerateHeader(NULL, "Last-Modified", &last_modified_hdr)) |
| 127 info->last_modified = last_modified_hdr; |
| 128 if (headers->EnumerateHeader(NULL, "ETag", &etag)) |
| 129 info->etag = etag; |
| 130 } |
| 123 | 131 |
| 124 CallStartedCB(net::OK); | 132 CallStartedCB(net::OK); |
| 125 | 133 |
| 126 std::string content_type_header; | 134 std::string content_type_header; |
| 127 if (!response->headers || | 135 if (!response->headers || |
| 128 !response->headers->GetMimeType(&content_type_header)) | 136 !response->headers->GetMimeType(&content_type_header)) |
| 129 content_type_header = ""; | 137 content_type_header = ""; |
| 130 info->original_mime_type = content_type_header; | 138 info->original_mime_type = content_type_header; |
| 131 | 139 |
| 132 if (!response->headers || | 140 if (!response->headers || |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 " render_view_id_ = " "%d" | 333 " render_view_id_ = " "%d" |
| 326 " save_info_.file_path = \"%" PRFilePath "\"" | 334 " save_info_.file_path = \"%" PRFilePath "\"" |
| 327 " }", | 335 " }", |
| 328 request_->url().spec().c_str(), | 336 request_->url().spec().c_str(), |
| 329 download_id_.local(), | 337 download_id_.local(), |
| 330 global_id_.child_id, | 338 global_id_.child_id, |
| 331 global_id_.request_id, | 339 global_id_.request_id, |
| 332 render_view_id_, | 340 render_view_id_, |
| 333 save_info_.file_path.value().c_str()); | 341 save_info_.file_path.value().c_str()); |
| 334 } | 342 } |
| OLD | NEW |