| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 scoped_ptr<ByteStreamReader> stream, | 52 scoped_ptr<ByteStreamReader> stream, |
| 53 const DownloadUrlParameters::OnStartedCallback& started_cb) { | 53 const DownloadUrlParameters::OnStartedCallback& started_cb) { |
| 54 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 54 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 55 | 55 |
| 56 DownloadManager* download_manager = info->request_handle.GetDownloadManager(); | 56 DownloadManager* download_manager = info->request_handle.GetDownloadManager(); |
| 57 if (!download_manager) { | 57 if (!download_manager) { |
| 58 // NULL in unittests or if the page closed right after starting the | 58 // NULL in unittests or if the page closed right after starting the |
| 59 // download. | 59 // download. |
| 60 if (!started_cb.is_null()) | 60 if (!started_cb.is_null()) |
| 61 started_cb.Run(NULL, DOWNLOAD_INTERRUPT_REASON_USER_CANCELED); | 61 started_cb.Run(NULL, DOWNLOAD_INTERRUPT_REASON_USER_CANCELED); |
| 62 |
| 63 // |stream| gets deleted on non-FILE thread, but it's ok since |
| 64 // we're not using stream_writer_ yet. |
| 65 |
| 62 return; | 66 return; |
| 63 } | 67 } |
| 64 | 68 |
| 65 download_manager->StartDownload(info.Pass(), stream.Pass(), started_cb); | 69 download_manager->StartDownload(info.Pass(), stream.Pass(), started_cb); |
| 66 } | 70 } |
| 67 | 71 |
| 68 } // namespace | 72 } // namespace |
| 69 | 73 |
| 70 const int DownloadResourceHandler::kDownloadByteStreamSize = 100 * 1024; | 74 const int DownloadResourceHandler::kDownloadByteStreamSize = 100 * 1024; |
| 71 | 75 |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 | 480 |
| 477 // Remove output stream callback if a stream exists. | 481 // Remove output stream callback if a stream exists. |
| 478 if (stream_writer_) | 482 if (stream_writer_) |
| 479 stream_writer_->RegisterCallback(base::Closure()); | 483 stream_writer_->RegisterCallback(base::Closure()); |
| 480 | 484 |
| 481 UMA_HISTOGRAM_TIMES("SB2.DownloadDuration", | 485 UMA_HISTOGRAM_TIMES("SB2.DownloadDuration", |
| 482 base::TimeTicks::Now() - download_start_time_); | 486 base::TimeTicks::Now() - download_start_time_); |
| 483 } | 487 } |
| 484 | 488 |
| 485 } // namespace content | 489 } // namespace content |
| OLD | NEW |