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( | 177 ChromeThread::PostTask(ChromeThread::FILE, FROM_HERE, |
178 ChromeThread::FILE, | 178 NewRunnableMethod(this, &DownloadFileManager::CreateDownloadFile, |
179 FROM_HERE, | 179 info, manager)); |
180 NewRunnableMethod(this, | |
181 &DownloadFileManager::CreateDownloadFile, | |
182 info, | |
183 make_scoped_refptr(manager))); | |
184 } | 180 } |
185 | 181 |
186 // We don't forward an update to the UI thread here, since we want to throttle | 182 // We don't forward an update to the UI thread here, since we want to throttle |
187 // the UI update rate via a periodic timer. If the user has cancelled the | 183 // the UI update rate via a periodic timer. If the user has cancelled the |
188 // download (in the UI thread), we may receive a few more updates before the IO | 184 // download (in the UI thread), we may receive a few more updates before the IO |
189 // thread gets the cancel message: we just delete the data since the | 185 // thread gets the cancel message: we just delete the data since the |
190 // DownloadFile has been deleted. | 186 // DownloadFile has been deleted. |
191 void DownloadFileManager::UpdateDownload(int id, DownloadBuffer* buffer) { | 187 void DownloadFileManager::UpdateDownload(int id, DownloadBuffer* buffer) { |
192 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE)); | 188 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE)); |
193 std::vector<DownloadBuffer::Contents> contents; | 189 std::vector<DownloadBuffer::Contents> contents; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 if (!download_manager) { | 357 if (!download_manager) { |
362 download->CancelDownloadRequest(resource_dispatcher_host_); | 358 download->CancelDownloadRequest(resource_dispatcher_host_); |
363 return; | 359 return; |
364 } | 360 } |
365 | 361 |
366 ChromeThread::PostTask( | 362 ChromeThread::PostTask( |
367 ChromeThread::UI, FROM_HERE, | 363 ChromeThread::UI, FROM_HERE, |
368 NewRunnableMethod(download_manager, | 364 NewRunnableMethod(download_manager, |
369 &DownloadManager::DownloadCancelled, id)); | 365 &DownloadManager::DownloadCancelled, id)); |
370 } | 366 } |
OLD | NEW |