| 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 29 matching lines...) Expand all Loading... |
| 40 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_ | 40 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_ |
| 41 #pragma once | 41 #pragma once |
| 42 | 42 |
| 43 #include <map> | 43 #include <map> |
| 44 | 44 |
| 45 #include "base/basictypes.h" | 45 #include "base/basictypes.h" |
| 46 #include "base/gtest_prod_util.h" | 46 #include "base/gtest_prod_util.h" |
| 47 #include "base/hash_tables.h" | 47 #include "base/hash_tables.h" |
| 48 #include "base/memory/ref_counted.h" | 48 #include "base/memory/ref_counted.h" |
| 49 #include "base/timer.h" | 49 #include "base/timer.h" |
| 50 #include "chrome/browser/download/download_process_handle.h" | 50 #include "chrome/browser/download/download_request_handle.h" |
| 51 #include "ui/gfx/native_widget_types.h" | 51 #include "ui/gfx/native_widget_types.h" |
| 52 | 52 |
| 53 struct DownloadBuffer; | 53 struct DownloadBuffer; |
| 54 struct DownloadCreateInfo; | 54 struct DownloadCreateInfo; |
| 55 struct DownloadSaveInfo; | 55 struct DownloadSaveInfo; |
| 56 class DownloadFile; | 56 class DownloadFile; |
| 57 class DownloadManager; | 57 class DownloadManager; |
| 58 class FilePath; | 58 class FilePath; |
| 59 class GURL; | 59 class GURL; |
| 60 class ResourceDispatcherHost; | 60 class ResourceDispatcherHost; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 135 |
| 136 // Clean up helper that runs on the download thread. | 136 // Clean up helper that runs on the download thread. |
| 137 void OnShutdown(); | 137 void OnShutdown(); |
| 138 | 138 |
| 139 // Creates DownloadFile on FILE thread and continues starting the download | 139 // Creates DownloadFile on FILE thread and continues starting the download |
| 140 // process. | 140 // process. |
| 141 void CreateDownloadFile(DownloadCreateInfo* info, | 141 void CreateDownloadFile(DownloadCreateInfo* info, |
| 142 DownloadManager* download_manager, | 142 DownloadManager* download_manager, |
| 143 bool hash_needed); | 143 bool hash_needed); |
| 144 | 144 |
| 145 // Tells the ResourceDispatcherHost to resume a download request | |
| 146 // that was paused to wait for the on-disk file to be created. | |
| 147 // |process| is passed by value because this is called from other | |
| 148 // threads, and this way we don't have to worry about object lifetimes. | |
| 149 void ResumeDownloadRequest(DownloadProcessHandle process); | |
| 150 | |
| 151 // Called only on the download thread. | 145 // Called only on the download thread. |
| 152 DownloadFile* GetDownloadFile(int id); | 146 DownloadFile* GetDownloadFile(int id); |
| 153 | 147 |
| 154 // Called only from RenameInProgressDownloadFile and | 148 // Called only from RenameInProgressDownloadFile and |
| 155 // RenameCompletingDownloadFile on the FILE thread. | 149 // RenameCompletingDownloadFile on the FILE thread. |
| 156 void CancelDownloadOnRename(int id); | 150 void CancelDownloadOnRename(int id); |
| 157 | 151 |
| 158 // Erases the download file with the given the download |id| and removes | 152 // Erases the download file with the given the download |id| and removes |
| 159 // it from the maps. | 153 // it from the maps. |
| 160 void EraseDownload(int id); | 154 void EraseDownload(int id); |
| 161 | 155 |
| 162 // Unique ID for each DownloadFile. | 156 // Unique ID for each DownloadFile. |
| 163 int next_id_; | 157 int next_id_; |
| 164 | 158 |
| 165 typedef base::hash_map<int, DownloadFile*> DownloadFileMap; | 159 typedef base::hash_map<int, DownloadFile*> DownloadFileMap; |
| 166 | 160 |
| 167 // A map of all in progress downloads. It owns the download files. | 161 // A map of all in progress downloads. It owns the download files. |
| 168 DownloadFileMap downloads_; | 162 DownloadFileMap downloads_; |
| 169 | 163 |
| 170 // Schedule periodic updates of the download progress. This timer | 164 // Schedule periodic updates of the download progress. This timer |
| 171 // is controlled from the FILE thread, and posts updates to the UI thread. | 165 // is controlled from the FILE thread, and posts updates to the UI thread. |
| 172 base::RepeatingTimer<DownloadFileManager> update_timer_; | 166 base::RepeatingTimer<DownloadFileManager> update_timer_; |
| 173 | 167 |
| 174 ResourceDispatcherHost* resource_dispatcher_host_; | 168 ResourceDispatcherHost* resource_dispatcher_host_; |
| 175 | 169 |
| 176 DISALLOW_COPY_AND_ASSIGN(DownloadFileManager); | 170 DISALLOW_COPY_AND_ASSIGN(DownloadFileManager); |
| 177 }; | 171 }; |
| 178 | 172 |
| 179 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_ | 173 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_ |
| OLD | NEW |