| 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 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 | 842 |
| 843 rdh->BeginDownload(url, | 843 rdh->BeginDownload(url, |
| 844 referrer, | 844 referrer, |
| 845 save_info, | 845 save_info, |
| 846 true, // Show "Save as" UI. | 846 true, // Show "Save as" UI. |
| 847 render_process_host_id, | 847 render_process_host_id, |
| 848 render_view_id, | 848 render_view_id, |
| 849 *context); | 849 *context); |
| 850 } | 850 } |
| 851 | 851 |
| 852 static void CancelDownloadRequestOnIOThread( | |
| 853 ResourceDispatcherHost* rdh, DownloadProcessHandle process_handle) { | |
| 854 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
| 855 // |rdh| may be NULL in unit tests. | |
| 856 if (!rdh) | |
| 857 return; | |
| 858 | |
| 859 rdh->CancelRequest(process_handle.child_id(), | |
| 860 process_handle.request_id(), | |
| 861 false); | |
| 862 } | |
| 863 | |
| 864 void CancelDownloadRequest(ResourceDispatcherHost* rdh, | |
| 865 DownloadProcessHandle process_handle) { | |
| 866 BrowserThread::PostTask( | |
| 867 BrowserThread::IO, FROM_HERE, | |
| 868 NewRunnableFunction(&download_util::CancelDownloadRequestOnIOThread, | |
| 869 rdh, process_handle)); | |
| 870 } | |
| 871 | |
| 872 void NotifyDownloadInitiated(int render_process_id, int render_view_id) { | 852 void NotifyDownloadInitiated(int render_process_id, int render_view_id) { |
| 873 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 853 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 874 RenderViewHost* rvh = RenderViewHost::FromID(render_process_id, | 854 RenderViewHost* rvh = RenderViewHost::FromID(render_process_id, |
| 875 render_view_id); | 855 render_view_id); |
| 876 if (!rvh) | 856 if (!rvh) |
| 877 return; | 857 return; |
| 878 | 858 |
| 879 NotificationService::current()->Notify(NotificationType::DOWNLOAD_INITIATED, | 859 NotificationService::current()->Notify(NotificationType::DOWNLOAD_INITIATED, |
| 880 Source<RenderViewHost>(rvh), | 860 Source<RenderViewHost>(rvh), |
| 881 NotificationService::NoDetails()); | 861 NotificationService::NoDetails()); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 FilePath GetCrDownloadPath(const FilePath& suggested_path) { | 903 FilePath GetCrDownloadPath(const FilePath& suggested_path) { |
| 924 FilePath::StringType file_name; | 904 FilePath::StringType file_name; |
| 925 base::SStringPrintf( | 905 base::SStringPrintf( |
| 926 &file_name, | 906 &file_name, |
| 927 PRFilePathLiteral FILE_PATH_LITERAL(".crdownload"), | 907 PRFilePathLiteral FILE_PATH_LITERAL(".crdownload"), |
| 928 suggested_path.value().c_str()); | 908 suggested_path.value().c_str()); |
| 929 return FilePath(file_name); | 909 return FilePath(file_name); |
| 930 } | 910 } |
| 931 | 911 |
| 932 } // namespace download_util | 912 } // namespace download_util |
| OLD | NEW |