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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 void RemoveSavedFileFromFileMap(const SaveIDList & save_ids); | 144 void RemoveSavedFileFromFileMap(const SaveIDList & save_ids); |
145 | 145 |
146 private: | 146 private: |
147 friend class base::RefCountedThreadSafe<SaveFileManager>; | 147 friend class base::RefCountedThreadSafe<SaveFileManager>; |
148 | 148 |
149 ~SaveFileManager(); | 149 ~SaveFileManager(); |
150 | 150 |
151 // A cleanup helper that runs on the file thread. | 151 // A cleanup helper that runs on the file thread. |
152 void OnShutdown(); | 152 void OnShutdown(); |
153 | 153 |
154 // Called only on UI thread to get the SavePackage for a tab's profile. | 154 // Called only on UI thread to get the SavePackage for a tab's browser |
| 155 // context. |
155 static SavePackage* GetSavePackageFromRenderIds(int render_process_id, | 156 static SavePackage* GetSavePackageFromRenderIds(int render_process_id, |
156 int review_view_id); | 157 int review_view_id); |
157 | 158 |
158 // Register a starting request. Associate the save URL with a | 159 // Register a starting request. Associate the save URL with a |
159 // SavePackage for further matching. | 160 // SavePackage for further matching. |
160 void RegisterStartingRequest(const GURL& save_url, | 161 void RegisterStartingRequest(const GURL& save_url, |
161 SavePackage* save_package); | 162 SavePackage* save_package); |
162 // Unregister a start request according save URL, disassociate | 163 // Unregister a start request according save URL, disassociate |
163 // the save URL and SavePackage. | 164 // the save URL and SavePackage. |
164 SavePackage* UnregisterStartingRequest(const GURL& save_url, | 165 SavePackage* UnregisterStartingRequest(const GURL& save_url, |
165 int tab_id); | 166 int tab_id); |
166 | 167 |
167 // Look up the SavePackage according to save id. | 168 // Look up the SavePackage according to save id. |
168 SavePackage* LookupPackage(int save_id); | 169 SavePackage* LookupPackage(int save_id); |
169 | 170 |
170 // Called only on the file thread. | 171 // Called only on the file thread. |
171 // Look up one in-progress saving item according to save id. | 172 // Look up one in-progress saving item according to save id. |
172 SaveFile* LookupSaveFile(int save_id); | 173 SaveFile* LookupSaveFile(int save_id); |
173 | 174 |
174 // Help function for sending notification of canceling specific request. | 175 // Help function for sending notification of canceling specific request. |
175 void SendCancelRequest(int save_id); | 176 void SendCancelRequest(int save_id); |
176 | 177 |
177 // Notifications sent from the file thread and run on the UI thread. | 178 // Notifications sent from the file thread and run on the UI thread. |
178 | 179 |
179 // Lookup the SaveManager for this TabContents' saving profile and inform it | 180 // Lookup the SaveManager for this TabContents' saving browser context and |
180 // the saving job has been started. | 181 // inform it the saving job has been started. |
181 void OnStartSave(const SaveFileCreateInfo* info); | 182 void OnStartSave(const SaveFileCreateInfo* info); |
182 // Update the SavePackage with the current state of a started saving job. | 183 // Update the SavePackage with the current state of a started saving job. |
183 // If the SavePackage for this saving job is gone, cancel the request. | 184 // If the SavePackage for this saving job is gone, cancel the request. |
184 void OnUpdateSaveProgress(int save_id, | 185 void OnUpdateSaveProgress(int save_id, |
185 int64 bytes_so_far, | 186 int64 bytes_so_far, |
186 bool write_success); | 187 bool write_success); |
187 // Update the SavePackage with the finish state, and remove the request | 188 // Update the SavePackage with the finish state, and remove the request |
188 // tracking entries. | 189 // tracking entries. |
189 void OnSaveFinished(int save_id, int64 bytes_so_far, bool is_success); | 190 void OnSaveFinished(int save_id, int64 bytes_so_far, bool is_success); |
190 // For those requests that do not have valid save id, use | 191 // For those requests that do not have valid save id, use |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 // hashmap since it is possible to save same URL in different tab at | 240 // hashmap since it is possible to save same URL in different tab at |
240 // same time. | 241 // same time. |
241 typedef base::hash_map<std::string, SavePackage*> StartingRequestsMap; | 242 typedef base::hash_map<std::string, SavePackage*> StartingRequestsMap; |
242 typedef base::hash_map<int, StartingRequestsMap> TabToStartingRequestsMap; | 243 typedef base::hash_map<int, StartingRequestsMap> TabToStartingRequestsMap; |
243 TabToStartingRequestsMap tab_starting_requests_; | 244 TabToStartingRequestsMap tab_starting_requests_; |
244 | 245 |
245 DISALLOW_COPY_AND_ASSIGN(SaveFileManager); | 246 DISALLOW_COPY_AND_ASSIGN(SaveFileManager); |
246 }; | 247 }; |
247 | 248 |
248 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_MANAGER_H_ | 249 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_MANAGER_H_ |
OLD | NEW |