| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Download utility implementation | 5 // Download utility implementation |
| 6 | 6 |
| 7 #include "chrome/browser/download/download_util.h" | 7 #include "chrome/browser/download/download_util.h" |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <shobjidl.h> | 10 #include <shobjidl.h> |
| (...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 | 826 |
| 827 rdh->BeginDownload(url, | 827 rdh->BeginDownload(url, |
| 828 referrer, | 828 referrer, |
| 829 save_info, | 829 save_info, |
| 830 true, // Show "Save as" UI. | 830 true, // Show "Save as" UI. |
| 831 render_process_host_id, | 831 render_process_host_id, |
| 832 render_view_id, | 832 render_view_id, |
| 833 *context); | 833 *context); |
| 834 } | 834 } |
| 835 | 835 |
| 836 static void CancelDownloadRequestOnIOThread( | |
| 837 ResourceDispatcherHost* rdh, DownloadProcessHandle process_handle) { | |
| 838 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
| 839 // |rdh| may be NULL in unit tests. | |
| 840 if (!rdh) | |
| 841 return; | |
| 842 | |
| 843 rdh->CancelRequest(process_handle.child_id(), | |
| 844 process_handle.request_id(), | |
| 845 false); | |
| 846 } | |
| 847 | |
| 848 void CancelDownloadRequest(ResourceDispatcherHost* rdh, | |
| 849 DownloadProcessHandle process_handle) { | |
| 850 BrowserThread::PostTask( | |
| 851 BrowserThread::IO, FROM_HERE, | |
| 852 NewRunnableFunction(&download_util::CancelDownloadRequestOnIOThread, | |
| 853 rdh, process_handle)); | |
| 854 } | |
| 855 | |
| 856 void NotifyDownloadInitiated(int render_process_id, int render_view_id) { | 836 void NotifyDownloadInitiated(int render_process_id, int render_view_id) { |
| 857 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 837 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 858 RenderViewHost* rvh = RenderViewHost::FromID(render_process_id, | 838 RenderViewHost* rvh = RenderViewHost::FromID(render_process_id, |
| 859 render_view_id); | 839 render_view_id); |
| 860 if (!rvh) | 840 if (!rvh) |
| 861 return; | 841 return; |
| 862 | 842 |
| 863 NotificationService::current()->Notify(NotificationType::DOWNLOAD_INITIATED, | 843 NotificationService::current()->Notify(NotificationType::DOWNLOAD_INITIATED, |
| 864 Source<RenderViewHost>(rvh), | 844 Source<RenderViewHost>(rvh), |
| 865 NotificationService::NoDetails()); | 845 NotificationService::NoDetails()); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 FilePath GetCrDownloadPath(const FilePath& suggested_path) { | 887 FilePath GetCrDownloadPath(const FilePath& suggested_path) { |
| 908 FilePath::StringType file_name; | 888 FilePath::StringType file_name; |
| 909 base::SStringPrintf( | 889 base::SStringPrintf( |
| 910 &file_name, | 890 &file_name, |
| 911 PRFilePathLiteral FILE_PATH_LITERAL(".crdownload"), | 891 PRFilePathLiteral FILE_PATH_LITERAL(".crdownload"), |
| 912 suggested_path.value().c_str()); | 892 suggested_path.value().c_str()); |
| 913 return FilePath(file_name); | 893 return FilePath(file_name); |
| 914 } | 894 } |
| 915 | 895 |
| 916 } // namespace download_util | 896 } // namespace download_util |
| OLD | NEW |