| 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" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/metrics/stats_counters.h" | 12 #include "base/metrics/stats_counters.h" |
| 13 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
| 14 #include "content/browser/download/download_buffer.h" | 14 #include "content/browser/download/download_buffer.h" |
| 15 #include "content/browser/download/download_create_info.h" | 15 #include "content/browser/download/download_create_info.h" |
| 16 #include "content/browser/download/download_file_manager.h" | 16 #include "content/browser/download/download_file_manager.h" |
| 17 #include "content/browser/download/download_manager_impl.h" | 17 #include "content/browser/download/download_manager_impl.h" |
| 18 #include "content/browser/download/download_request_handle.h" | 18 #include "content/browser/download/download_request_handle.h" |
| 19 #include "content/browser/download/download_stats.h" | 19 #include "content/browser/download/download_stats.h" |
| 20 #include "content/browser/download/interrupt_reasons.h" | 20 #include "content/browser/download/interrupt_reasons.h" |
| 21 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 21 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 22 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" | 22 #include "content/browser/renderer_host/resource_request_info_impl.h" |
| 23 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 24 #include "content/public/browser/download_item.h" | 24 #include "content/public/browser/download_item.h" |
| 25 #include "content/public/browser/download_manager_delegate.h" | 25 #include "content/public/browser/download_manager_delegate.h" |
| 26 #include "content/public/common/resource_response.h" | 26 #include "content/public/common/resource_response.h" |
| 27 #include "net/base/io_buffer.h" | 27 #include "net/base/io_buffer.h" |
| 28 #include "net/base/net_errors.h" | 28 #include "net/base/net_errors.h" |
| 29 #include "net/http/http_response_headers.h" | 29 #include "net/http/http_response_headers.h" |
| 30 #include "net/url_request/url_request_context.h" | 30 #include "net/url_request/url_request_context.h" |
| 31 | 31 |
| 32 using content::BrowserThread; | 32 using content::BrowserThread; |
| 33 using content::DownloadId; | 33 using content::DownloadId; |
| 34 using content::DownloadItem; | 34 using content::DownloadItem; |
| 35 using content::DownloadManager; | 35 using content::DownloadManager; |
| 36 using content::ResourceRequestInfoImpl; |
| 36 | 37 |
| 37 DownloadResourceHandler::DownloadResourceHandler( | 38 DownloadResourceHandler::DownloadResourceHandler( |
| 38 ResourceDispatcherHost* rdh, | 39 ResourceDispatcherHost* rdh, |
| 39 int render_process_host_id, | 40 int render_process_host_id, |
| 40 int render_view_id, | 41 int render_view_id, |
| 41 int request_id, | 42 int request_id, |
| 42 const GURL& url, | 43 const GURL& url, |
| 43 DownloadFileManager* download_file_manager, | 44 DownloadFileManager* download_file_manager, |
| 44 net::URLRequest* request, | 45 net::URLRequest* request, |
| 45 const DownloadResourceHandler::OnStartedCallback& started_cb, | 46 const DownloadResourceHandler::OnStartedCallback& started_cb, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 86 |
| 86 // If it's a download, we don't want to poison the cache with it. | 87 // If it's a download, we don't want to poison the cache with it. |
| 87 request_->StopCaching(); | 88 request_->StopCaching(); |
| 88 | 89 |
| 89 std::string content_disposition; | 90 std::string content_disposition; |
| 90 request_->GetResponseHeaderByName("content-disposition", | 91 request_->GetResponseHeaderByName("content-disposition", |
| 91 &content_disposition); | 92 &content_disposition); |
| 92 set_content_disposition(content_disposition); | 93 set_content_disposition(content_disposition); |
| 93 set_content_length(response->content_length); | 94 set_content_length(response->content_length); |
| 94 | 95 |
| 95 const ResourceDispatcherHostRequestInfo* request_info = | 96 const ResourceRequestInfoImpl* request_info = |
| 96 ResourceDispatcherHost::InfoForRequest(request_); | 97 ResourceDispatcherHost::InfoForRequest(request_); |
| 97 | 98 |
| 98 // Deleted in DownloadManager. | 99 // Deleted in DownloadManager. |
| 99 scoped_ptr<DownloadCreateInfo> info(new DownloadCreateInfo( | 100 scoped_ptr<DownloadCreateInfo> info(new DownloadCreateInfo( |
| 100 base::Time::Now(), 0, content_length_, DownloadItem::IN_PROGRESS, | 101 base::Time::Now(), 0, content_length_, DownloadItem::IN_PROGRESS, |
| 101 request_->net_log(), request_info->has_user_gesture(), | 102 request_->net_log(), request_info->has_user_gesture(), |
| 102 request_info->transition_type())); | 103 request_info->transition_type())); |
| 103 info->url_chain = request_->url_chain(); | 104 info->url_chain = request_->url_chain(); |
| 104 info->referrer_url = GURL(request_->referrer()); | 105 info->referrer_url = GURL(request_->referrer()); |
| 105 info->start_time = base::Time::Now(); | 106 info->start_time = base::Time::Now(); |
| 106 info->received_bytes = save_info_.offset; | 107 info->received_bytes = save_info_.offset; |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 " render_view_id_ = " "%d" | 402 " render_view_id_ = " "%d" |
| 402 " save_info_.file_path = \"%" PRFilePath "\"" | 403 " save_info_.file_path = \"%" PRFilePath "\"" |
| 403 " }", | 404 " }", |
| 404 request_->url().spec().c_str(), | 405 request_->url().spec().c_str(), |
| 405 download_id_.local(), | 406 download_id_.local(), |
| 406 global_id_.child_id, | 407 global_id_.child_id, |
| 407 global_id_.request_id, | 408 global_id_.request_id, |
| 408 render_view_id_, | 409 render_view_id_, |
| 409 save_info_.file_path.value().c_str()); | 410 save_info_.file_path.value().c_str()); |
| 410 } | 411 } |
| OLD | NEW |