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