Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: content/browser/download/download_file_manager.h

Issue 7646025: Detect file system errors during downloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed comment. Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 // Called on the IO thread 75 // Called on the IO thread
76 int GetNextId(); 76 int GetNextId();
77 77
78 // Called on UI thread to make DownloadFileManager start the download. 78 // Called on UI thread to make DownloadFileManager start the download.
79 void StartDownload(DownloadCreateInfo* info); 79 void StartDownload(DownloadCreateInfo* info);
80 80
81 // Handlers for notifications sent from the IO thread and run on the 81 // Handlers for notifications sent from the IO thread and run on the
82 // FILE thread. 82 // FILE thread.
83 void UpdateDownload(int id, DownloadBuffer* buffer); 83 void UpdateDownload(int id, DownloadBuffer* buffer);
84 // |os_error| is 0 for normal completions, and non-0 for errors. 84 // |net_error| is 0 for normal completions, and non-0 for errors.
85 // |security_info| contains SSL information (cert_id, cert_status, 85 // |security_info| contains SSL information (cert_id, cert_status,
86 // security_bits, ssl_connection_status), which can be used to 86 // security_bits, ssl_connection_status), which can be used to
87 // fine-tune the error message. It is empty if the transaction 87 // fine-tune the error message. It is empty if the transaction
88 // was not performed securely. 88 // was not performed securely.
89 void OnResponseCompleted(int id, 89 void OnResponseCompleted(int id,
90 DownloadBuffer* buffer, 90 DownloadBuffer* buffer,
91 int os_error, 91 int net_error,
92 const std::string& security_info); 92 const std::string& security_info);
93 93
94 // Handlers for notifications sent from the UI thread and run on the 94 // Handlers for notifications sent from the UI thread and run on the
95 // FILE thread. These are both terminal actions with respect to the 95 // FILE thread. These are both terminal actions with respect to the
96 // download file, as far as the DownloadFileManager is concerned -- if 96 // download file, as far as the DownloadFileManager is concerned -- if
97 // anything happens to the download file after they are called, it will 97 // anything happens to the download file after they are called, it will
98 // be ignored. 98 // be ignored.
99 void CancelDownload(int id); 99 void CancelDownload(int id);
100 void CompleteDownload(int id); 100 void CompleteDownload(int id);
101 101
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // Called only on the download thread. 145 // Called only on the download thread.
146 DownloadFile* GetDownloadFile(int id); 146 DownloadFile* GetDownloadFile(int id);
147 147
148 // Called only from RenameInProgressDownloadFile and 148 // Called only from RenameInProgressDownloadFile and
149 // RenameCompletingDownloadFile on the FILE thread. 149 // RenameCompletingDownloadFile on the FILE thread.
150 void CancelDownloadOnRename(int id); 150 // |rename_error| indicates what network error caused the cancel.
151 void CancelDownloadOnRename(int id, int rename_error);
151 152
152 // Erases the download file with the given the download |id| and removes 153 // Erases the download file with the given the download |id| and removes
153 // it from the maps. 154 // it from the maps.
154 void EraseDownload(int id); 155 void EraseDownload(int id);
155 156
156 // Unique ID for each DownloadFile. 157 // Unique ID for each DownloadFile.
157 int next_id_; 158 int next_id_;
158 159
159 typedef base::hash_map<int, DownloadFile*> DownloadFileMap; 160 typedef base::hash_map<int, DownloadFile*> DownloadFileMap;
160 161
161 // A map of all in progress downloads. It owns the download files. 162 // A map of all in progress downloads. It owns the download files.
162 DownloadFileMap downloads_; 163 DownloadFileMap downloads_;
163 164
164 // Schedule periodic updates of the download progress. This timer 165 // Schedule periodic updates of the download progress. This timer
165 // is controlled from the FILE thread, and posts updates to the UI thread. 166 // is controlled from the FILE thread, and posts updates to the UI thread.
166 base::RepeatingTimer<DownloadFileManager> update_timer_; 167 base::RepeatingTimer<DownloadFileManager> update_timer_;
167 168
168 ResourceDispatcherHost* resource_dispatcher_host_; 169 ResourceDispatcherHost* resource_dispatcher_host_;
169 170
170 DISALLOW_COPY_AND_ASSIGN(DownloadFileManager); 171 DISALLOW_COPY_AND_ASSIGN(DownloadFileManager);
171 }; 172 };
172 173
173 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_ 174 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698