OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 class DownloadRequestHandle; | 59 class DownloadRequestHandle; |
60 class FilePath; | 60 class FilePath; |
61 class ResourceDispatcherHost; | 61 class ResourceDispatcherHost; |
62 | 62 |
63 namespace content { | 63 namespace content { |
64 class DownloadBuffer; | 64 class DownloadBuffer; |
65 class DownloadFile; | 65 class DownloadFile; |
66 class DownloadManager; | 66 class DownloadManager; |
67 } | 67 } |
68 | 68 |
| 69 namespace net { |
| 70 class BoundNetLog; |
| 71 } |
| 72 |
69 // Manages all in progress downloads. | 73 // Manages all in progress downloads. |
70 class CONTENT_EXPORT DownloadFileManager | 74 class CONTENT_EXPORT DownloadFileManager |
71 : public base::RefCountedThreadSafe<DownloadFileManager> { | 75 : public base::RefCountedThreadSafe<DownloadFileManager> { |
72 public: | 76 public: |
73 class DownloadFileFactory { | 77 class DownloadFileFactory { |
74 public: | 78 public: |
75 virtual ~DownloadFileFactory() {} | 79 virtual ~DownloadFileFactory() {} |
76 | 80 |
77 virtual content::DownloadFile* CreateFile( | 81 virtual content::DownloadFile* CreateFile( |
78 DownloadCreateInfo* info, | 82 DownloadCreateInfo* info, |
79 const DownloadRequestHandle& request_handle, | 83 const DownloadRequestHandle& request_handle, |
80 content::DownloadManager* download_manager, | 84 content::DownloadManager* download_manager, |
81 bool calculate_hash) = 0; | 85 bool calculate_hash, |
| 86 const net::BoundNetLog& bound_net_log) = 0; |
82 }; | 87 }; |
83 | 88 |
84 // Takes ownership of the factory. | 89 // Takes ownership of the factory. |
85 // Passing in a NULL for |factory| will cause a default | 90 // Passing in a NULL for |factory| will cause a default |
86 // |DownloadFileFactory| to be used. | 91 // |DownloadFileFactory| to be used. |
87 DownloadFileManager(ResourceDispatcherHost* rdh, | 92 DownloadFileManager(ResourceDispatcherHost* rdh, |
88 DownloadFileFactory* factory); | 93 DownloadFileFactory* factory); |
89 | 94 |
90 // Called on shutdown on the UI thread. | 95 // Called on shutdown on the UI thread. |
91 void Shutdown(); | 96 void Shutdown(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 void UpdateInProgressDownloads(); | 158 void UpdateInProgressDownloads(); |
154 | 159 |
155 // Clean up helper that runs on the download thread. | 160 // Clean up helper that runs on the download thread. |
156 void OnShutdown(); | 161 void OnShutdown(); |
157 | 162 |
158 // Creates DownloadFile on FILE thread and continues starting the download | 163 // Creates DownloadFile on FILE thread and continues starting the download |
159 // process. | 164 // process. |
160 void CreateDownloadFile(DownloadCreateInfo* info, | 165 void CreateDownloadFile(DownloadCreateInfo* info, |
161 const DownloadRequestHandle& request_handle, | 166 const DownloadRequestHandle& request_handle, |
162 content::DownloadManager* download_manager, | 167 content::DownloadManager* download_manager, |
163 bool hash_needed); | 168 bool hash_needed, |
| 169 const net::BoundNetLog& bound_net_log); |
164 | 170 |
165 // Called only on the download thread. | 171 // Called only on the download thread. |
166 content::DownloadFile* GetDownloadFile(content::DownloadId global_id); | 172 content::DownloadFile* GetDownloadFile(content::DownloadId global_id); |
167 | 173 |
168 // Called only from RenameInProgressDownloadFile and | 174 // Called only from RenameInProgressDownloadFile and |
169 // RenameCompletingDownloadFile on the FILE thread. | 175 // RenameCompletingDownloadFile on the FILE thread. |
170 // |rename_error| indicates what error caused the cancel. | 176 // |rename_error| indicates what error caused the cancel. |
171 void CancelDownloadOnRename(content::DownloadId global_id, | 177 void CancelDownloadOnRename(content::DownloadId global_id, |
172 net::Error rename_error); | 178 net::Error rename_error); |
173 | 179 |
(...skipping 11 matching lines...) Expand all Loading... |
185 // is controlled from the FILE thread, and posts updates to the UI thread. | 191 // is controlled from the FILE thread, and posts updates to the UI thread. |
186 base::RepeatingTimer<DownloadFileManager> update_timer_; | 192 base::RepeatingTimer<DownloadFileManager> update_timer_; |
187 | 193 |
188 ResourceDispatcherHost* resource_dispatcher_host_; | 194 ResourceDispatcherHost* resource_dispatcher_host_; |
189 scoped_ptr<DownloadFileFactory> download_file_factory_; | 195 scoped_ptr<DownloadFileFactory> download_file_factory_; |
190 | 196 |
191 DISALLOW_COPY_AND_ASSIGN(DownloadFileManager); | 197 DISALLOW_COPY_AND_ASSIGN(DownloadFileManager); |
192 }; | 198 }; |
193 | 199 |
194 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_ | 200 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_ |
OLD | NEW |