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 "chrome/browser/renderer_host/download_resource_handler.h" | 5 #include "chrome/browser/renderer_host/download_resource_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "base/metrics/stats_counters.h" | 11 #include "base/metrics/stats_counters.h" |
12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
13 #include "chrome/browser/download/download_item.h" | 13 #include "chrome/browser/download/download_item.h" |
14 #include "chrome/browser/download/download_file_manager.h" | 14 #include "chrome/browser/download/download_file_manager.h" |
| 15 #include "chrome/browser/download/download_process_handle.h" |
15 #include "chrome/browser/download/download_util.h" | 16 #include "chrome/browser/download/download_util.h" |
16 #include "chrome/browser/history/download_create_info.h" | 17 #include "chrome/browser/history/download_create_info.h" |
17 #include "content/browser/browser_thread.h" | 18 #include "content/browser/browser_thread.h" |
18 #include "content/browser/renderer_host/global_request_id.h" | 19 #include "content/browser/renderer_host/global_request_id.h" |
19 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 20 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
20 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" | 21 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" |
21 #include "content/common/resource_response.h" | 22 #include "content/common/resource_response.h" |
22 #include "net/base/io_buffer.h" | 23 #include "net/base/io_buffer.h" |
23 #include "net/http/http_response_headers.h" | 24 #include "net/http/http_response_headers.h" |
24 #include "net/url_request/url_request_context.h" | 25 #include "net/url_request/url_request_context.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // Deleted in DownloadManager. | 82 // Deleted in DownloadManager. |
82 DownloadCreateInfo* info = new DownloadCreateInfo; | 83 DownloadCreateInfo* info = new DownloadCreateInfo; |
83 info->url_chain = request_->url_chain(); | 84 info->url_chain = request_->url_chain(); |
84 info->referrer_url = GURL(request_->referrer()); | 85 info->referrer_url = GURL(request_->referrer()); |
85 info->start_time = base::Time::Now(); | 86 info->start_time = base::Time::Now(); |
86 info->received_bytes = 0; | 87 info->received_bytes = 0; |
87 info->total_bytes = content_length_; | 88 info->total_bytes = content_length_; |
88 info->state = DownloadItem::IN_PROGRESS; | 89 info->state = DownloadItem::IN_PROGRESS; |
89 info->download_id = download_id_; | 90 info->download_id = download_id_; |
90 info->has_user_gesture = request_info->has_user_gesture(); | 91 info->has_user_gesture = request_info->has_user_gesture(); |
91 info->child_id = global_id_.child_id; | 92 info->process_handle = DownloadProcessHandle(global_id_.child_id, |
92 info->render_view_id = render_view_id_; | 93 render_view_id_, |
93 info->request_id = global_id_.request_id; | 94 global_id_.request_id); |
94 info->content_disposition = content_disposition_; | 95 info->content_disposition = content_disposition_; |
95 info->mime_type = response->response_head.mime_type; | 96 info->mime_type = response->response_head.mime_type; |
96 // TODO(ahendrickson) -- Get the last modified time and etag, so we can | 97 // TODO(ahendrickson) -- Get the last modified time and etag, so we can |
97 // resume downloading. | 98 // resume downloading. |
98 | 99 |
99 std::string content_type_header; | 100 std::string content_type_header; |
100 if (!response->response_head.headers || | 101 if (!response->response_head.headers || |
101 !response->response_head.headers->GetMimeType(&content_type_header)) | 102 !response->response_head.headers->GetMimeType(&content_type_header)) |
102 content_type_header = ""; | 103 content_type_header = ""; |
103 info->original_mime_type = content_type_header; | 104 info->original_mime_type = content_type_header; |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 " render_view_id_ = " "%d" | 256 " render_view_id_ = " "%d" |
256 " save_info_.file_path = \"%" PRFilePath "\"" | 257 " save_info_.file_path = \"%" PRFilePath "\"" |
257 " }", | 258 " }", |
258 request_->url().spec().c_str(), | 259 request_->url().spec().c_str(), |
259 download_id_, | 260 download_id_, |
260 global_id_.child_id, | 261 global_id_.child_id, |
261 global_id_.request_id, | 262 global_id_.request_id, |
262 render_view_id_, | 263 render_view_id_, |
263 save_info_.file_path.value().c_str()); | 264 save_info_.file_path.value().c_str()); |
264 } | 265 } |
OLD | NEW |