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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 void DownloadFileManager::CreateDownloadFile( | 56 void DownloadFileManager::CreateDownloadFile( |
57 scoped_ptr<DownloadCreateInfo> info, | 57 scoped_ptr<DownloadCreateInfo> info, |
58 scoped_ptr<content::ByteStreamReader> stream, | 58 scoped_ptr<content::ByteStreamReader> stream, |
59 scoped_refptr<DownloadManager> download_manager, bool get_hash, | 59 scoped_refptr<DownloadManager> download_manager, bool get_hash, |
60 const net::BoundNetLog& bound_net_log, | 60 const net::BoundNetLog& bound_net_log, |
61 const CreateDownloadFileCallback& callback) { | 61 const CreateDownloadFileCallback& callback) { |
62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
63 DCHECK(info.get()); | 63 DCHECK(info.get()); |
64 VLOG(20) << __FUNCTION__ << "()" << " info = " << info->DebugString(); | 64 VLOG(20) << __FUNCTION__ << "()" << " info = " << info->DebugString(); |
65 | 65 |
66 DownloadId id(info->download_id); | |
benjhayden
2012/10/11 19:41:12
Comment that we can't use |info| after we Pass() i
Randy Smith (Not in Mondays)
2012/10/15 18:56:32
Done.
| |
67 | |
66 scoped_ptr<DownloadFile> download_file(download_file_factory_->CreateFile( | 68 scoped_ptr<DownloadFile> download_file(download_file_factory_->CreateFile( |
67 info.get(), stream.Pass(), download_manager, get_hash, bound_net_log)); | 69 info.Pass(), stream.Pass(), download_manager, get_hash, bound_net_log)); |
68 | 70 |
69 content::DownloadInterruptReason interrupt_reason( | 71 content::DownloadInterruptReason interrupt_reason( |
70 download_file->Initialize()); | 72 download_file->Initialize()); |
71 if (interrupt_reason == content::DOWNLOAD_INTERRUPT_REASON_NONE) { | 73 if (interrupt_reason == content::DOWNLOAD_INTERRUPT_REASON_NONE) { |
72 DCHECK(GetDownloadFile(info->download_id) == NULL); | 74 DCHECK(GetDownloadFile(id) == NULL); |
73 downloads_[info->download_id] = download_file.release(); | 75 downloads_[id] = download_file.release(); |
74 } | 76 } |
75 | 77 |
76 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 78 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
77 base::Bind(callback, interrupt_reason)); | 79 base::Bind(callback, interrupt_reason)); |
78 } | 80 } |
79 | 81 |
80 DownloadFile* DownloadFileManager::GetDownloadFile( | 82 DownloadFile* DownloadFileManager::GetDownloadFile( |
81 DownloadId global_id) { | 83 DownloadId global_id) { |
82 DownloadFileMap::iterator it = downloads_.find(global_id); | 84 DownloadFileMap::iterator it = downloads_.find(global_id); |
83 return it == downloads_.end() ? NULL : it->second; | 85 return it == downloads_.end() ? NULL : it->second; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 DownloadFile* download_file = downloads_[global_id]; | 176 DownloadFile* download_file = downloads_[global_id]; |
175 | 177 |
176 VLOG(20) << " " << __FUNCTION__ << "()" | 178 VLOG(20) << " " << __FUNCTION__ << "()" |
177 << " id = " << global_id | 179 << " id = " << global_id |
178 << " download_file = " << download_file->DebugString(); | 180 << " download_file = " << download_file->DebugString(); |
179 | 181 |
180 downloads_.erase(global_id); | 182 downloads_.erase(global_id); |
181 | 183 |
182 delete download_file; | 184 delete download_file; |
183 } | 185 } |
OLD | NEW |