OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/download/download_file_manager.h" | 5 #include "chrome/browser/download/download_file_manager.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/stl_util-inl.h" | 8 #include "base/stl_util-inl.h" |
9 #include "base/task.h" | 9 #include "base/task.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 ChromeThread::PostTask( | 167 ChromeThread::PostTask( |
168 ChromeThread::IO, FROM_HERE, | 168 ChromeThread::IO, FROM_HERE, |
169 NewRunnableFunction(&download_util::CancelDownloadRequest, | 169 NewRunnableFunction(&download_util::CancelDownloadRequest, |
170 resource_dispatcher_host_, | 170 resource_dispatcher_host_, |
171 info->child_id, | 171 info->child_id, |
172 info->request_id)); | 172 info->request_id)); |
173 delete info; | 173 delete info; |
174 return; | 174 return; |
175 } | 175 } |
176 | 176 |
177 ChromeThread::PostTask(ChromeThread::FILE, FROM_HERE, | 177 ChromeThread::PostTask( |
178 NewRunnableMethod(this, &DownloadFileManager::CreateDownloadFile, | 178 ChromeThread::FILE, |
179 info, manager)); | 179 FROM_HERE, |
| 180 NewRunnableMethod(this, |
| 181 &DownloadFileManager::CreateDownloadFile, |
| 182 info, |
| 183 make_scoped_refptr(manager))); |
180 } | 184 } |
181 | 185 |
182 // We don't forward an update to the UI thread here, since we want to throttle | 186 // We don't forward an update to the UI thread here, since we want to throttle |
183 // the UI update rate via a periodic timer. If the user has cancelled the | 187 // the UI update rate via a periodic timer. If the user has cancelled the |
184 // download (in the UI thread), we may receive a few more updates before the IO | 188 // download (in the UI thread), we may receive a few more updates before the IO |
185 // thread gets the cancel message: we just delete the data since the | 189 // thread gets the cancel message: we just delete the data since the |
186 // DownloadFile has been deleted. | 190 // DownloadFile has been deleted. |
187 void DownloadFileManager::UpdateDownload(int id, DownloadBuffer* buffer) { | 191 void DownloadFileManager::UpdateDownload(int id, DownloadBuffer* buffer) { |
188 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE)); | 192 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE)); |
189 std::vector<DownloadBuffer::Contents> contents; | 193 std::vector<DownloadBuffer::Contents> contents; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 if (!download_manager) { | 361 if (!download_manager) { |
358 download->CancelDownloadRequest(resource_dispatcher_host_); | 362 download->CancelDownloadRequest(resource_dispatcher_host_); |
359 return; | 363 return; |
360 } | 364 } |
361 | 365 |
362 ChromeThread::PostTask( | 366 ChromeThread::PostTask( |
363 ChromeThread::UI, FROM_HERE, | 367 ChromeThread::UI, FROM_HERE, |
364 NewRunnableMethod(download_manager, | 368 NewRunnableMethod(download_manager, |
365 &DownloadManager::DownloadCancelled, id)); | 369 &DownloadManager::DownloadCancelled, id)); |
366 } | 370 } |
OLD | NEW |