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