| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, net::ERR_ACCESS_DENIED); | 61 started_cb.Run(NULL, net::ERR_ACCESS_DENIED); |
| 62 return; | 62 return; |
| 63 } | 63 } |
| 64 | 64 |
| 65 DownloadItem* item = download_manager->StartDownload( | 65 DownloadItem* item = download_manager->StartDownload( |
| 66 info.Pass(), stream.Pass()); | 66 info.Pass(), stream.Pass()); |
| 67 | 67 |
| 68 // |item| can be NULL if the download has been removed. |
| 68 if (!started_cb.is_null()) | 69 if (!started_cb.is_null()) |
| 69 started_cb.Run(item, net::OK); | 70 started_cb.Run(item, item ? net::OK : net::ERR_ABORTED); |
| 70 } | 71 } |
| 71 | 72 |
| 72 } // namespace | 73 } // namespace |
| 73 | 74 |
| 74 const int DownloadResourceHandler::kDownloadByteStreamSize = 100 * 1024; | 75 const int DownloadResourceHandler::kDownloadByteStreamSize = 100 * 1024; |
| 75 | 76 |
| 76 DownloadResourceHandler::DownloadResourceHandler( | 77 DownloadResourceHandler::DownloadResourceHandler( |
| 77 DownloadId id, | 78 DownloadId id, |
| 78 net::URLRequest* request, | 79 net::URLRequest* request, |
| 79 const DownloadResourceHandler::OnStartedCallback& started_cb, | 80 const DownloadResourceHandler::OnStartedCallback& started_cb, |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 | 482 |
| 482 // Remove output stream callback if a stream exists. | 483 // Remove output stream callback if a stream exists. |
| 483 if (stream_writer_) | 484 if (stream_writer_) |
| 484 stream_writer_->RegisterCallback(base::Closure()); | 485 stream_writer_->RegisterCallback(base::Closure()); |
| 485 | 486 |
| 486 UMA_HISTOGRAM_TIMES("SB2.DownloadDuration", | 487 UMA_HISTOGRAM_TIMES("SB2.DownloadDuration", |
| 487 base::TimeTicks::Now() - download_start_time_); | 488 base::TimeTicks::Now() - download_start_time_); |
| 488 } | 489 } |
| 489 | 490 |
| 490 } // namespace content | 491 } // namespace content |
| OLD | NEW |