| 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 // The DownloadFileManager owns a set of DownloadFile objects, each of which | 5 // The DownloadFileManager owns a set of DownloadFile objects, each of which |
| 6 // represent one in progress download and performs the disk IO for that | 6 // represent one in progress download and performs the disk IO for that |
| 7 // download. The DownloadFileManager itself is a singleton object owned by the | 7 // download. The DownloadFileManager itself is a singleton object owned by the |
| 8 // ResourceDispatcherHost. | 8 // ResourceDispatcherHost. |
| 9 // | 9 // |
| 10 // The DownloadFileManager uses the file_thread for performing file write | 10 // The DownloadFileManager uses the file_thread for performing file write |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 #include "base/timer.h" | 50 #include "base/timer.h" |
| 51 #include "content/browser/download/download_id.h" | 51 #include "content/browser/download/download_id.h" |
| 52 #include "content/browser/download/interrupt_reasons.h" | 52 #include "content/browser/download/interrupt_reasons.h" |
| 53 #include "content/common/content_export.h" | 53 #include "content/common/content_export.h" |
| 54 #include "net/base/net_errors.h" | 54 #include "net/base/net_errors.h" |
| 55 #include "ui/gfx/native_widget_types.h" | 55 #include "ui/gfx/native_widget_types.h" |
| 56 | 56 |
| 57 struct DownloadCreateInfo; | 57 struct DownloadCreateInfo; |
| 58 struct DownloadSaveInfo; | 58 struct DownloadSaveInfo; |
| 59 class DownloadFile; | 59 class DownloadFile; |
| 60 class DownloadManager; | 60 class DownloadManagerInterface; |
| 61 class DownloadRequestHandle; | 61 class DownloadRequestHandle; |
| 62 class FilePath; | 62 class FilePath; |
| 63 class GURL; | 63 class GURL; |
| 64 class ResourceDispatcherHost; | 64 class ResourceDispatcherHost; |
| 65 | 65 |
| 66 namespace content { | 66 namespace content { |
| 67 class DownloadBuffer; | 67 class DownloadBuffer; |
| 68 } | 68 } |
| 69 | 69 |
| 70 namespace net { | 70 namespace net { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 99 | 99 |
| 100 // Handlers for notifications sent from the UI thread and run on the | 100 // Handlers for notifications sent from the UI thread and run on the |
| 101 // FILE thread. These are both terminal actions with respect to the | 101 // FILE thread. These are both terminal actions with respect to the |
| 102 // download file, as far as the DownloadFileManager is concerned -- if | 102 // download file, as far as the DownloadFileManager is concerned -- if |
| 103 // anything happens to the download file after they are called, it will | 103 // anything happens to the download file after they are called, it will |
| 104 // be ignored. | 104 // be ignored. |
| 105 void CancelDownload(DownloadId id); | 105 void CancelDownload(DownloadId id); |
| 106 void CompleteDownload(DownloadId id); | 106 void CompleteDownload(DownloadId id); |
| 107 | 107 |
| 108 // Called on FILE thread by DownloadManager at the beginning of its shutdown. | 108 // Called on FILE thread by DownloadManager at the beginning of its shutdown. |
| 109 void OnDownloadManagerShutdown(DownloadManager* manager); | 109 void OnDownloadManagerShutdown(DownloadManagerInterface* manager); |
| 110 | 110 |
| 111 // The DownloadManager in the UI thread has provided an intermediate | 111 // The DownloadManager in the UI thread has provided an intermediate |
| 112 // .crdownload name for the download specified by |id|. | 112 // .crdownload name for the download specified by |id|. |
| 113 void RenameInProgressDownloadFile(DownloadId id, const FilePath& full_path); | 113 void RenameInProgressDownloadFile(DownloadId id, const FilePath& full_path); |
| 114 | 114 |
| 115 // The DownloadManager in the UI thread has provided a final name for the | 115 // The DownloadManager in the UI thread has provided a final name for the |
| 116 // download specified by |id|. | 116 // download specified by |id|. |
| 117 // |overwrite_existing_file| prevents uniquification, and is used for SAFE | 117 // |overwrite_existing_file| prevents uniquification, and is used for SAFE |
| 118 // downloads, as the user may have decided to overwrite the file. | 118 // downloads, as the user may have decided to overwrite the file. |
| 119 // Sent from the UI thread and run on the FILE thread. | 119 // Sent from the UI thread and run on the FILE thread. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 139 void StopUpdateTimer(); | 139 void StopUpdateTimer(); |
| 140 void UpdateInProgressDownloads(); | 140 void UpdateInProgressDownloads(); |
| 141 | 141 |
| 142 // Clean up helper that runs on the download thread. | 142 // Clean up helper that runs on the download thread. |
| 143 void OnShutdown(); | 143 void OnShutdown(); |
| 144 | 144 |
| 145 // Creates DownloadFile on FILE thread and continues starting the download | 145 // Creates DownloadFile on FILE thread and continues starting the download |
| 146 // process. | 146 // process. |
| 147 void CreateDownloadFile(DownloadCreateInfo* info, | 147 void CreateDownloadFile(DownloadCreateInfo* info, |
| 148 const DownloadRequestHandle& request_handle, | 148 const DownloadRequestHandle& request_handle, |
| 149 DownloadManager* download_manager, | 149 DownloadManagerInterface* download_manager, |
| 150 bool hash_needed); | 150 bool hash_needed); |
| 151 | 151 |
| 152 // Called only on the download thread. | 152 // Called only on the download thread. |
| 153 DownloadFile* GetDownloadFile(DownloadId global_id); | 153 DownloadFile* GetDownloadFile(DownloadId global_id); |
| 154 | 154 |
| 155 // Called only from RenameInProgressDownloadFile and | 155 // Called only from RenameInProgressDownloadFile and |
| 156 // RenameCompletingDownloadFile on the FILE thread. | 156 // RenameCompletingDownloadFile on the FILE thread. |
| 157 // |rename_error| indicates what error caused the cancel. | 157 // |rename_error| indicates what error caused the cancel. |
| 158 void CancelDownloadOnRename(DownloadId global_id, net::Error rename_error); | 158 void CancelDownloadOnRename(DownloadId global_id, net::Error rename_error); |
| 159 | 159 |
| 160 // Erases the download file with the given the download |id| and removes | 160 // Erases the download file with the given the download |id| and removes |
| 161 // it from the maps. | 161 // it from the maps. |
| 162 void EraseDownload(DownloadId global_id); | 162 void EraseDownload(DownloadId global_id); |
| 163 | 163 |
| 164 typedef base::hash_map<DownloadId, DownloadFile*> DownloadFileMap; | 164 typedef base::hash_map<DownloadId, DownloadFile*> DownloadFileMap; |
| 165 | 165 |
| 166 // A map of all in progress downloads. It owns the download files. | 166 // A map of all in progress downloads. It owns the download files. |
| 167 DownloadFileMap downloads_; | 167 DownloadFileMap downloads_; |
| 168 | 168 |
| 169 // Schedule periodic updates of the download progress. This timer | 169 // Schedule periodic updates of the download progress. This timer |
| 170 // is controlled from the FILE thread, and posts updates to the UI thread. | 170 // is controlled from the FILE thread, and posts updates to the UI thread. |
| 171 base::RepeatingTimer<DownloadFileManager> update_timer_; | 171 base::RepeatingTimer<DownloadFileManager> update_timer_; |
| 172 | 172 |
| 173 ResourceDispatcherHost* resource_dispatcher_host_; | 173 ResourceDispatcherHost* resource_dispatcher_host_; |
| 174 | 174 |
| 175 DISALLOW_COPY_AND_ASSIGN(DownloadFileManager); | 175 DISALLOW_COPY_AND_ASSIGN(DownloadFileManager); |
| 176 }; | 176 }; |
| 177 | 177 |
| 178 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_ | 178 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_ |
| OLD | NEW |