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_manager_impl.h" | 5 #include "content/browser/download/download_manager_impl.h" |
6 | 6 |
7 #include <iterator> | 7 #include <iterator> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "base/supports_user_data.h" | 22 #include "base/supports_user_data.h" |
23 #include "base/synchronization/lock.h" | 23 #include "base/synchronization/lock.h" |
24 #include "build/build_config.h" | 24 #include "build/build_config.h" |
25 #include "content/browser/byte_stream.h" | 25 #include "content/browser/byte_stream.h" |
26 #include "content/browser/child_process_security_policy_impl.h" | 26 #include "content/browser/child_process_security_policy_impl.h" |
27 #include "content/browser/download/download_create_info.h" | 27 #include "content/browser/download/download_create_info.h" |
28 #include "content/browser/download/download_file_factory.h" | 28 #include "content/browser/download/download_file_factory.h" |
29 #include "content/browser/download/download_item_factory.h" | 29 #include "content/browser/download/download_item_factory.h" |
30 #include "content/browser/download/download_item_impl.h" | 30 #include "content/browser/download/download_item_impl.h" |
31 #include "content/browser/download/download_stats.h" | 31 #include "content/browser/download/download_stats.h" |
| 32 #include "content/browser/download/download_task_runner.h" |
32 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 33 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
33 #include "content/browser/loader/resource_request_info_impl.h" | 34 #include "content/browser/loader/resource_request_info_impl.h" |
34 #include "content/browser/renderer_host/render_view_host_impl.h" | 35 #include "content/browser/renderer_host/render_view_host_impl.h" |
35 #include "content/browser/web_contents/web_contents_impl.h" | 36 #include "content/browser/web_contents/web_contents_impl.h" |
36 #include "content/public/browser/browser_context.h" | 37 #include "content/public/browser/browser_context.h" |
37 #include "content/public/browser/content_browser_client.h" | 38 #include "content/public/browser/content_browser_client.h" |
38 #include "content/public/browser/download_interrupt_reasons.h" | 39 #include "content/public/browser/download_interrupt_reasons.h" |
39 #include "content/public/browser/download_manager_delegate.h" | 40 #include "content/public/browser/download_manager_delegate.h" |
40 #include "content/public/browser/download_url_parameters.h" | 41 #include "content/public/browser/download_url_parameters.h" |
41 #include "content/public/browser/notification_service.h" | 42 #include "content/public/browser/notification_service.h" |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 if (item_iterator == downloads_.end() || | 345 if (item_iterator == downloads_.end() || |
345 (item_iterator->second->GetState() == DownloadItem::CANCELLED)) { | 346 (item_iterator->second->GetState() == DownloadItem::CANCELLED)) { |
346 // If the download is no longer known to the DownloadManager, then it was | 347 // If the download is no longer known to the DownloadManager, then it was |
347 // removed after it was resumed. Ignore. If the download is cancelled | 348 // removed after it was resumed. Ignore. If the download is cancelled |
348 // while resuming, then also ignore the request. | 349 // while resuming, then also ignore the request. |
349 info->request_handle->CancelRequest(true); | 350 info->request_handle->CancelRequest(true); |
350 if (!on_started.is_null()) | 351 if (!on_started.is_null()) |
351 on_started.Run(nullptr, DOWNLOAD_INTERRUPT_REASON_USER_CANCELED); | 352 on_started.Run(nullptr, DOWNLOAD_INTERRUPT_REASON_USER_CANCELED); |
352 // The ByteStreamReader lives and dies on the FILE thread. | 353 // The ByteStreamReader lives and dies on the FILE thread. |
353 if (info->result == DOWNLOAD_INTERRUPT_REASON_NONE) | 354 if (info->result == DOWNLOAD_INTERRUPT_REASON_NONE) |
354 BrowserThread::DeleteSoon(BrowserThread::FILE, FROM_HERE, | 355 GetDownloadTaskRunner()->DeleteSoon(FROM_HERE, stream.release()); |
355 stream.release()); | |
356 return; | 356 return; |
357 } | 357 } |
358 download = item_iterator->second.get(); | 358 download = item_iterator->second.get(); |
359 } | 359 } |
360 | 360 |
361 base::FilePath default_download_directory; | 361 base::FilePath default_download_directory; |
362 if (delegate_) { | 362 if (delegate_) { |
363 base::FilePath website_save_directory; // Unused | 363 base::FilePath website_save_directory; // Unused |
364 bool skip_dir_check = false; // Unused | 364 bool skip_dir_check = false; // Unused |
365 delegate_->GetSaveDir(GetBrowserContext(), &website_save_directory, | 365 delegate_->GetSaveDir(GetBrowserContext(), &website_save_directory, |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 if (delegate_) | 759 if (delegate_) |
760 delegate_->OpenDownload(download); | 760 delegate_->OpenDownload(download); |
761 } | 761 } |
762 | 762 |
763 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { | 763 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { |
764 if (delegate_) | 764 if (delegate_) |
765 delegate_->ShowDownloadInShell(download); | 765 delegate_->ShowDownloadInShell(download); |
766 } | 766 } |
767 | 767 |
768 } // namespace content | 768 } // namespace content |
OLD | NEW |