| 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_file_manager.h" | 5 #include "content/browser/download/download_file_manager.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 } | 172 } |
| 173 } | 173 } |
| 174 } | 174 } |
| 175 | 175 |
| 176 void DownloadFileManager::StartDownload( | 176 void DownloadFileManager::StartDownload( |
| 177 DownloadCreateInfo* info, const DownloadRequestHandle& request_handle) { | 177 DownloadCreateInfo* info, const DownloadRequestHandle& request_handle) { |
| 178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 179 DCHECK(info); | 179 DCHECK(info); |
| 180 | 180 |
| 181 DownloadManager* manager = request_handle.GetDownloadManager(); | 181 DownloadManager* manager = request_handle.GetDownloadManager(); |
| 182 if (!manager) { | 182 DCHECK(manager); // Checked in |DownloadResourceHandler::StartOnUIThread()|. |
| 183 request_handle.CancelRequest(); | |
| 184 delete info; | |
| 185 return; | |
| 186 } | |
| 187 | 183 |
| 188 // |bound_net_log| will be used for logging the both the download item's and | 184 // |bound_net_log| will be used for logging the both the download item's and |
| 189 // the download file's events. | 185 // the download file's events. |
| 190 net::BoundNetLog bound_net_log = | 186 net::BoundNetLog bound_net_log = |
| 191 manager->CreateDownloadItem(info, request_handle); | 187 manager->CreateDownloadItem(info, request_handle); |
| 192 bool hash_needed = manager->GenerateFileHash(); | 188 bool hash_needed = manager->GenerateFileHash(); |
| 193 | 189 |
| 194 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 190 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 195 base::Bind(&DownloadFileManager::CreateDownloadFile, this, | 191 base::Bind(&DownloadFileManager::CreateDownloadFile, this, |
| 196 info, request_handle, make_scoped_refptr(manager), | 192 info, request_handle, make_scoped_refptr(manager), |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 << " id = " << global_id | 486 << " id = " << global_id |
| 491 << " download_file = " << download_file->DebugString(); | 487 << " download_file = " << download_file->DebugString(); |
| 492 | 488 |
| 493 downloads_.erase(global_id); | 489 downloads_.erase(global_id); |
| 494 | 490 |
| 495 delete download_file; | 491 delete download_file; |
| 496 | 492 |
| 497 if (downloads_.empty()) | 493 if (downloads_.empty()) |
| 498 StopUpdateTimer(); | 494 StopUpdateTimer(); |
| 499 } | 495 } |
| OLD | NEW |