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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 render_view_id_(render_view_id), | 49 render_view_id_(render_view_id), |
50 content_length_(0), | 50 content_length_(0), |
51 download_file_manager_(download_file_manager), | 51 download_file_manager_(download_file_manager), |
52 request_(request), | 52 request_(request), |
53 started_cb_(started_cb), | 53 started_cb_(started_cb), |
54 save_info_(save_info), | 54 save_info_(save_info), |
55 buffer_(new content::DownloadBuffer), | 55 buffer_(new content::DownloadBuffer), |
56 rdh_(rdh), | 56 rdh_(rdh), |
57 is_paused_(false), | 57 is_paused_(false), |
58 last_buffer_size_(0), | 58 last_buffer_size_(0), |
59 bytes_read_(0) { | 59 bytes_read_(0), |
| 60 bound_net_log_(net::BoundNetLog::Make(request->net_log().net_log(), |
| 61 net::NetLog::SOURCE_DOWNLOAD)) { |
60 download_stats::RecordDownloadCount(download_stats::UNTHROTTLED_COUNT); | 62 download_stats::RecordDownloadCount(download_stats::UNTHROTTLED_COUNT); |
| 63 |
| 64 bound_net_log_.AddEvent( |
| 65 net::NetLog::TYPE_DOWNLOAD_URL_REQUEST, |
| 66 make_scoped_refptr(new net::NetLogSourceParameter( |
| 67 "source_dependency", |
| 68 request->net_log().source()))); |
| 69 |
| 70 request->net_log().AddEvent( |
| 71 net::NetLog::TYPE_DOWNLOAD_STARTED, |
| 72 make_scoped_refptr(new net::NetLogSourceParameter( |
| 73 "source_dependency", |
| 74 bound_net_log_.source()))); |
61 } | 75 } |
62 | 76 |
63 bool DownloadResourceHandler::OnUploadProgress(int request_id, | 77 bool DownloadResourceHandler::OnUploadProgress(int request_id, |
64 uint64 position, | 78 uint64 position, |
65 uint64 size) { | 79 uint64 size) { |
66 return true; | 80 return true; |
67 } | 81 } |
68 | 82 |
69 // Not needed, as this event handler ought to be the final resource. | 83 // Not needed, as this event handler ought to be the final resource. |
70 bool DownloadResourceHandler::OnRequestRedirected( | 84 bool DownloadResourceHandler::OnRequestRedirected( |
(...skipping 20 matching lines...) Expand all Loading... |
91 &content_disposition); | 105 &content_disposition); |
92 set_content_disposition(content_disposition); | 106 set_content_disposition(content_disposition); |
93 set_content_length(response->content_length); | 107 set_content_length(response->content_length); |
94 | 108 |
95 const ResourceDispatcherHostRequestInfo* request_info = | 109 const ResourceDispatcherHostRequestInfo* request_info = |
96 ResourceDispatcherHost::InfoForRequest(request_); | 110 ResourceDispatcherHost::InfoForRequest(request_); |
97 | 111 |
98 // Deleted in DownloadManager. | 112 // Deleted in DownloadManager. |
99 scoped_ptr<DownloadCreateInfo> info(new DownloadCreateInfo(FilePath(), GURL(), | 113 scoped_ptr<DownloadCreateInfo> info(new DownloadCreateInfo(FilePath(), GURL(), |
100 base::Time::Now(), 0, content_length_, DownloadItem::IN_PROGRESS, | 114 base::Time::Now(), 0, content_length_, DownloadItem::IN_PROGRESS, |
101 request_info->has_user_gesture(), request_info->transition_type())); | 115 bound_net_log_, request_info->has_user_gesture(), |
| 116 request_info->transition_type())); |
102 info->url_chain = request_->url_chain(); | 117 info->url_chain = request_->url_chain(); |
103 info->referrer_url = GURL(request_->referrer()); | 118 info->referrer_url = GURL(request_->referrer()); |
104 info->start_time = base::Time::Now(); | 119 info->start_time = base::Time::Now(); |
105 info->received_bytes = save_info_.offset; | 120 info->received_bytes = save_info_.offset; |
106 info->total_bytes = content_length_; | 121 info->total_bytes = content_length_; |
107 info->state = DownloadItem::IN_PROGRESS; | 122 info->state = DownloadItem::IN_PROGRESS; |
108 info->has_user_gesture = request_info->has_user_gesture(); | 123 info->has_user_gesture = request_info->has_user_gesture(); |
109 info->content_disposition = content_disposition_; | 124 info->content_disposition = content_disposition_; |
110 info->mime_type = response->mime_type; | 125 info->mime_type = response->mime_type; |
111 info->remote_address = request_->GetSocketAddress().host(); | 126 info->remote_address = request_->GetSocketAddress().host(); |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 " render_view_id_ = " "%d" | 390 " render_view_id_ = " "%d" |
376 " save_info_.file_path = \"%" PRFilePath "\"" | 391 " save_info_.file_path = \"%" PRFilePath "\"" |
377 " }", | 392 " }", |
378 request_->url().spec().c_str(), | 393 request_->url().spec().c_str(), |
379 download_id_.local(), | 394 download_id_.local(), |
380 global_id_.child_id, | 395 global_id_.child_id, |
381 global_id_.request_id, | 396 global_id_.request_id, |
382 render_view_id_, | 397 render_view_id_, |
383 save_info_.file_path.value().c_str()); | 398 save_info_.file_path.value().c_str()); |
384 } | 399 } |
OLD | NEW |