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/location.h" | |
11 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/message_loop/message_loop_proxy.h" |
12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
13 #include "base/metrics/sparse_histogram.h" | 13 #include "base/metrics/sparse_histogram.h" |
14 #include "base/single_thread_task_runner.h" | |
15 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
16 #include "base/thread_task_runner_handle.h" | |
17 #include "content/browser/byte_stream.h" | 15 #include "content/browser/byte_stream.h" |
18 #include "content/browser/download/download_create_info.h" | 16 #include "content/browser/download/download_create_info.h" |
19 #include "content/browser/download/download_interrupt_reasons_impl.h" | 17 #include "content/browser/download/download_interrupt_reasons_impl.h" |
20 #include "content/browser/download/download_manager_impl.h" | 18 #include "content/browser/download/download_manager_impl.h" |
21 #include "content/browser/download/download_request_handle.h" | 19 #include "content/browser/download/download_request_handle.h" |
22 #include "content/browser/download/download_stats.h" | 20 #include "content/browser/download/download_stats.h" |
23 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 21 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
24 #include "content/browser/loader/resource_request_info_impl.h" | 22 #include "content/browser/loader/resource_request_info_impl.h" |
25 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
26 #include "content/public/browser/download_interrupt_reasons.h" | 24 #include "content/public/browser/download_interrupt_reasons.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 new DownloadCreateInfo(base::Time::Now(), | 184 new DownloadCreateInfo(base::Time::Now(), |
187 content_length, | 185 content_length, |
188 request()->net_log(), | 186 request()->net_log(), |
189 request_info->HasUserGesture(), | 187 request_info->HasUserGesture(), |
190 request_info->GetPageTransition(), | 188 request_info->GetPageTransition(), |
191 save_info_.Pass())); | 189 save_info_.Pass())); |
192 | 190 |
193 // Create the ByteStream for sending data to the download sink. | 191 // Create the ByteStream for sending data to the download sink. |
194 scoped_ptr<ByteStreamReader> stream_reader; | 192 scoped_ptr<ByteStreamReader> stream_reader; |
195 CreateByteStream( | 193 CreateByteStream( |
196 base::ThreadTaskRunnerHandle::Get(), | 194 base::MessageLoopProxy::current(), |
197 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | 195 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
198 kDownloadByteStreamSize, &stream_writer_, &stream_reader); | 196 kDownloadByteStreamSize, &stream_writer_, &stream_reader); |
199 stream_writer_->RegisterCallback( | 197 stream_writer_->RegisterCallback( |
200 base::Bind(&DownloadResourceHandler::ResumeRequest, AsWeakPtr())); | 198 base::Bind(&DownloadResourceHandler::ResumeRequest, AsWeakPtr())); |
201 | 199 |
202 info->download_id = download_id_; | 200 info->download_id = download_id_; |
203 info->url_chain = request()->url_chain(); | 201 info->url_chain = request()->url_chain(); |
204 info->referrer_url = GURL(request()->referrer()); | 202 info->referrer_url = GURL(request()->referrer()); |
205 info->mime_type = response->head.mime_type; | 203 info->mime_type = response->head.mime_type; |
206 info->remote_address = request()->GetSocketAddress().host(); | 204 info->remote_address = request()->GetSocketAddress().host(); |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 BrowserThread::PostTask( | 540 BrowserThread::PostTask( |
543 BrowserThread::UI, FROM_HERE, | 541 BrowserThread::UI, FROM_HERE, |
544 base::Bind(&DeleteOnUIThread, base::Passed(&tab_info_))); | 542 base::Bind(&DeleteOnUIThread, base::Passed(&tab_info_))); |
545 } | 543 } |
546 | 544 |
547 UMA_HISTOGRAM_TIMES("SB2.DownloadDuration", | 545 UMA_HISTOGRAM_TIMES("SB2.DownloadDuration", |
548 base::TimeTicks::Now() - download_start_time_); | 546 base::TimeTicks::Now() - download_start_time_); |
549 } | 547 } |
550 | 548 |
551 } // namespace content | 549 } // namespace content |
OLD | NEW |