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