| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 // Called on the IO or UI threads. | 76 // Called on the IO or UI threads. |
| 77 int GetNextId(); | 77 int GetNextId(); |
| 78 | 78 |
| 79 // Called on UI thread to make DownloadFileManager start the download. | 79 // Called on UI thread to make DownloadFileManager start the download. |
| 80 void StartDownload(DownloadCreateInfo* info); | 80 void StartDownload(DownloadCreateInfo* info); |
| 81 | 81 |
| 82 // Handlers for notifications sent from the IO thread and run on the | 82 // Handlers for notifications sent from the IO thread and run on the |
| 83 // FILE thread. | 83 // FILE thread. |
| 84 void UpdateDownload(int id, DownloadBuffer* buffer); | 84 void UpdateDownload(int id, DownloadBuffer* buffer); |
| 85 // |os_error| is 0 for normal completions, and non-0 for errors. | 85 // |net_error| is 0 for normal completions, and non-0 for errors. |
| 86 // |security_info| contains SSL information (cert_id, cert_status, | 86 // |security_info| contains SSL information (cert_id, cert_status, |
| 87 // security_bits, ssl_connection_status), which can be used to | 87 // security_bits, ssl_connection_status), which can be used to |
| 88 // fine-tune the error message. It is empty if the transaction | 88 // fine-tune the error message. It is empty if the transaction |
| 89 // was not performed securely. | 89 // was not performed securely. |
| 90 void OnResponseCompleted(int id, | 90 void OnResponseCompleted(int id, |
| 91 DownloadBuffer* buffer, | 91 DownloadBuffer* buffer, |
| 92 int os_error, | 92 int net_error, |
| 93 const std::string& security_info); | 93 const std::string& security_info); |
| 94 | 94 |
| 95 // Handlers for notifications sent from the UI thread and run on the | 95 // Handlers for notifications sent from the UI thread and run on the |
| 96 // FILE thread. These are both terminal actions with respect to the | 96 // FILE thread. These are both terminal actions with respect to the |
| 97 // download file, as far as the DownloadFileManager is concerned -- if | 97 // download file, as far as the DownloadFileManager is concerned -- if |
| 98 // anything happens to the download file after they are called, it will | 98 // anything happens to the download file after they are called, it will |
| 99 // be ignored. | 99 // be ignored. |
| 100 void CancelDownload(int id); | 100 void CancelDownload(int id); |
| 101 void CompleteDownload(int id); | 101 void CompleteDownload(int id); |
| 102 | 102 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 // process. | 141 // process. |
| 142 void CreateDownloadFile(DownloadCreateInfo* info, | 142 void CreateDownloadFile(DownloadCreateInfo* info, |
| 143 DownloadManager* download_manager, | 143 DownloadManager* download_manager, |
| 144 bool hash_needed); | 144 bool hash_needed); |
| 145 | 145 |
| 146 // Called only on the download thread. | 146 // Called only on the download thread. |
| 147 DownloadFile* GetDownloadFile(int id); | 147 DownloadFile* GetDownloadFile(int id); |
| 148 | 148 |
| 149 // Called only from RenameInProgressDownloadFile and | 149 // Called only from RenameInProgressDownloadFile and |
| 150 // RenameCompletingDownloadFile on the FILE thread. | 150 // RenameCompletingDownloadFile on the FILE thread. |
| 151 void CancelDownloadOnRename(int id); | 151 // |rename_error| indicates what network error caused the cancel. |
| 152 void CancelDownloadOnRename(int id, int rename_error); |
| 152 | 153 |
| 153 // Erases the download file with the given the download |id| and removes | 154 // Erases the download file with the given the download |id| and removes |
| 154 // it from the maps. | 155 // it from the maps. |
| 155 void EraseDownload(int id); | 156 void EraseDownload(int id); |
| 156 | 157 |
| 157 // Unique ID for each DownloadItem. | 158 // Unique ID for each DownloadItem. |
| 158 base::AtomicSequenceNumber next_id_; | 159 base::AtomicSequenceNumber next_id_; |
| 159 | 160 |
| 160 typedef base::hash_map<int, DownloadFile*> DownloadFileMap; | 161 typedef base::hash_map<int, DownloadFile*> DownloadFileMap; |
| 161 | 162 |
| 162 // A map of all in progress downloads. It owns the download files. | 163 // A map of all in progress downloads. It owns the download files. |
| 163 DownloadFileMap downloads_; | 164 DownloadFileMap downloads_; |
| 164 | 165 |
| 165 // Schedule periodic updates of the download progress. This timer | 166 // Schedule periodic updates of the download progress. This timer |
| 166 // is controlled from the FILE thread, and posts updates to the UI thread. | 167 // is controlled from the FILE thread, and posts updates to the UI thread. |
| 167 base::RepeatingTimer<DownloadFileManager> update_timer_; | 168 base::RepeatingTimer<DownloadFileManager> update_timer_; |
| 168 | 169 |
| 169 ResourceDispatcherHost* resource_dispatcher_host_; | 170 ResourceDispatcherHost* resource_dispatcher_host_; |
| 170 | 171 |
| 171 DISALLOW_COPY_AND_ASSIGN(DownloadFileManager); | 172 DISALLOW_COPY_AND_ASSIGN(DownloadFileManager); |
| 172 }; | 173 }; |
| 173 | 174 |
| 174 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_ | 175 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_ |
| OLD | NEW |