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 // Objects that handle file operations for saving files, on the file thread. | 5 // Objects that handle file operations for saving files, on the file thread. |
6 // | 6 // |
7 // The SaveFileManager owns a set of SaveFile objects, each of which connects | 7 // The SaveFileManager owns a set of SaveFile objects, each of which connects |
8 // with a SaveItem object which belongs to one SavePackage and runs on the file | 8 // with a SaveItem object which belongs to one SavePackage and runs on the file |
9 // thread for saving data in order to avoid disk activity on either network IO | 9 // thread for saving data in order to avoid disk activity on either network IO |
10 // thread or the UI thread. It coordinates the notifications from the network | 10 // thread or the UI thread. It coordinates the notifications from the network |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 int GetNextId(); | 95 int GetNextId(); |
96 | 96 |
97 // Save the specified URL. Called on the UI thread and forwarded to the | 97 // Save the specified URL. Called on the UI thread and forwarded to the |
98 // ResourceDispatcherHost on the IO thread. | 98 // ResourceDispatcherHost on the IO thread. |
99 void SaveURL(const GURL& url, | 99 void SaveURL(const GURL& url, |
100 const GURL& referrer, | 100 const GURL& referrer, |
101 int render_process_host_id, | 101 int render_process_host_id, |
102 int render_view_id, | 102 int render_view_id, |
103 SaveFileCreateInfo::SaveFileSource save_source, | 103 SaveFileCreateInfo::SaveFileSource save_source, |
104 const FilePath& file_full_path, | 104 const FilePath& file_full_path, |
105 const content::ResourceContext& context, | 105 content::ResourceContext* context, |
106 SavePackage* save_package); | 106 SavePackage* save_package); |
107 | 107 |
108 // Notifications sent from the IO thread and run on the file thread: | 108 // Notifications sent from the IO thread and run on the file thread: |
109 void StartSave(SaveFileCreateInfo* info); | 109 void StartSave(SaveFileCreateInfo* info); |
110 void UpdateSaveProgress(int save_id, net::IOBuffer* data, int size); | 110 void UpdateSaveProgress(int save_id, net::IOBuffer* data, int size); |
111 void SaveFinished(int save_id, | 111 void SaveFinished(int save_id, |
112 const GURL& save_url, | 112 const GURL& save_url, |
113 int render_process_id, | 113 int render_process_id, |
114 bool is_success); | 114 bool is_success); |
115 | 115 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 // Deletes a specified file on the file thread. | 203 // Deletes a specified file on the file thread. |
204 void OnDeleteDirectoryOrFile(const FilePath& full_path, bool is_dir); | 204 void OnDeleteDirectoryOrFile(const FilePath& full_path, bool is_dir); |
205 | 205 |
206 // Notifications sent from the UI thread and run on the IO thread | 206 // Notifications sent from the UI thread and run on the IO thread |
207 | 207 |
208 // Initiates a request for URL to be saved. | 208 // Initiates a request for URL to be saved. |
209 void OnSaveURL(const GURL& url, | 209 void OnSaveURL(const GURL& url, |
210 const GURL& referrer, | 210 const GURL& referrer, |
211 int render_process_host_id, | 211 int render_process_host_id, |
212 int render_view_id, | 212 int render_view_id, |
213 const content::ResourceContext* context); | 213 content::ResourceContext* context); |
214 // Handler for a notification sent to the IO thread for generating save id. | 214 // Handler for a notification sent to the IO thread for generating save id. |
215 void OnRequireSaveJobFromOtherSource(SaveFileCreateInfo* info); | 215 void OnRequireSaveJobFromOtherSource(SaveFileCreateInfo* info); |
216 // Call ResourceDispatcherHost's CancelRequest method to execute cancel | 216 // Call ResourceDispatcherHost's CancelRequest method to execute cancel |
217 // action in the IO thread. | 217 // action in the IO thread. |
218 void ExecuteCancelSaveRequest(int render_process_id, int request_id); | 218 void ExecuteCancelSaveRequest(int render_process_id, int request_id); |
219 | 219 |
220 // Unique ID for the next SaveFile object. | 220 // Unique ID for the next SaveFile object. |
221 int next_id_; | 221 int next_id_; |
222 | 222 |
223 // A map of all saving jobs by using save id. | 223 // A map of all saving jobs by using save id. |
(...skipping 18 matching lines...) Expand all Loading... |
242 // hashmap since it is possible to save same URL in different tab at | 242 // hashmap since it is possible to save same URL in different tab at |
243 // same time. | 243 // same time. |
244 typedef base::hash_map<std::string, SavePackage*> StartingRequestsMap; | 244 typedef base::hash_map<std::string, SavePackage*> StartingRequestsMap; |
245 typedef base::hash_map<int, StartingRequestsMap> TabToStartingRequestsMap; | 245 typedef base::hash_map<int, StartingRequestsMap> TabToStartingRequestsMap; |
246 TabToStartingRequestsMap tab_starting_requests_; | 246 TabToStartingRequestsMap tab_starting_requests_; |
247 | 247 |
248 DISALLOW_COPY_AND_ASSIGN(SaveFileManager); | 248 DISALLOW_COPY_AND_ASSIGN(SaveFileManager); |
249 }; | 249 }; |
250 | 250 |
251 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_MANAGER_H_ | 251 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_MANAGER_H_ |
OLD | NEW |