OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 #define CHROME_BROWSER_DOWNLOAD_SAVE_FILE_MANAGER_H__ | 59 #define CHROME_BROWSER_DOWNLOAD_SAVE_FILE_MANAGER_H__ |
60 | 60 |
61 #include <utility> | 61 #include <utility> |
62 | 62 |
63 #include "base/basictypes.h" | 63 #include "base/basictypes.h" |
64 #include "base/hash_tables.h" | 64 #include "base/hash_tables.h" |
65 #include "base/ref_counted.h" | 65 #include "base/ref_counted.h" |
66 #include "base/thread.h" | 66 #include "base/thread.h" |
67 #include "chrome/browser/download/save_types.h" | 67 #include "chrome/browser/download/save_types.h" |
68 | 68 |
| 69 namespace net { |
| 70 class IOBuffer; |
| 71 } |
69 class GURL; | 72 class GURL; |
70 class SaveFile; | 73 class SaveFile; |
71 class SavePackage; | 74 class SavePackage; |
72 class MessageLoop; | 75 class MessageLoop; |
73 class ResourceDispatcherHost; | 76 class ResourceDispatcherHost; |
74 class Task; | 77 class Task; |
75 class URLRequestContext; | 78 class URLRequestContext; |
76 | 79 |
77 class SaveFileManager | 80 class SaveFileManager |
78 : public base::RefCountedThreadSafe<SaveFileManager> { | 81 : public base::RefCountedThreadSafe<SaveFileManager> { |
(...skipping 15 matching lines...) Expand all Loading... |
94 const std::wstring& referrer, | 97 const std::wstring& referrer, |
95 int render_process_host_id, | 98 int render_process_host_id, |
96 int render_view_id, | 99 int render_view_id, |
97 SaveFileCreateInfo::SaveFileSource save_source, | 100 SaveFileCreateInfo::SaveFileSource save_source, |
98 const std::wstring& file_full_path, | 101 const std::wstring& file_full_path, |
99 URLRequestContext* request_context, | 102 URLRequestContext* request_context, |
100 SavePackage* save_package); | 103 SavePackage* save_package); |
101 | 104 |
102 // Notifications sent from the IO thread and run on the file thread: | 105 // Notifications sent from the IO thread and run on the file thread: |
103 void StartSave(SaveFileCreateInfo* info); | 106 void StartSave(SaveFileCreateInfo* info); |
104 void UpdateSaveProgress(int save_id, char* data, int size); | 107 void UpdateSaveProgress(int save_id, net::IOBuffer* data, int size); |
105 void SaveFinished(int save_id, std::wstring save_url, | 108 void SaveFinished(int save_id, std::wstring save_url, |
106 int render_process_id, bool is_success); | 109 int render_process_id, bool is_success); |
107 | 110 |
108 // Notifications sent from the UI thread and run on the file thread. | 111 // Notifications sent from the UI thread and run on the file thread. |
109 // Cancel a SaveFile instance which has specified save id. | 112 // Cancel a SaveFile instance which has specified save id. |
110 void CancelSave(int save_id); | 113 void CancelSave(int save_id); |
111 | 114 |
112 // Called on the UI thread to remove a save package from SaveFileManager's | 115 // Called on the UI thread to remove a save package from SaveFileManager's |
113 // tracking map. | 116 // tracking map. |
114 void RemoveSaveFile(int save_id, const std::wstring& save_url, | 117 void RemoveSaveFile(int save_id, const std::wstring& save_url, |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 // hashmap since it is possible to save same URL in different tab at | 256 // hashmap since it is possible to save same URL in different tab at |
254 // same time. | 257 // same time. |
255 typedef base::hash_map<std::wstring, SavePackage*> StartingRequestsMap; | 258 typedef base::hash_map<std::wstring, SavePackage*> StartingRequestsMap; |
256 typedef base::hash_map<int, StartingRequestsMap> TabToStartingRequestsMap; | 259 typedef base::hash_map<int, StartingRequestsMap> TabToStartingRequestsMap; |
257 TabToStartingRequestsMap tab_starting_requests_; | 260 TabToStartingRequestsMap tab_starting_requests_; |
258 | 261 |
259 DISALLOW_EVIL_CONSTRUCTORS(SaveFileManager); | 262 DISALLOW_EVIL_CONSTRUCTORS(SaveFileManager); |
260 }; | 263 }; |
261 | 264 |
262 #endif // CHROME_BROWSER_DOWNLOAD_SAVE_FILE_MANAGER_H__ | 265 #endif // CHROME_BROWSER_DOWNLOAD_SAVE_FILE_MANAGER_H__ |
OLD | NEW |