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

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

Issue 7646025: Detect file system errors during downloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed illegal include from content. Created 9 years, 3 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 DownloadManager object manages the process of downloading, including 5 // The DownloadManager object manages the process of downloading, including
6 // updates to the history system and providing the information for displaying 6 // updates to the history system and providing the information for displaying
7 // the downloads view in the Destinations tab. There is one DownloadManager per 7 // the downloads view in the Destinations tab. There is one DownloadManager per
8 // active browser context in Chrome. 8 // active browser context in Chrome.
9 // 9 //
10 // Download observers: 10 // Download observers:
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // Returns all non-temporary downloads matching |query|. Empty query matches 105 // Returns all non-temporary downloads matching |query|. Empty query matches
106 // everything. 106 // everything.
107 void SearchDownloads(const string16& query, DownloadVector* result); 107 void SearchDownloads(const string16& query, DownloadVector* result);
108 108
109 // Returns true if initialized properly. 109 // Returns true if initialized properly.
110 bool Init(content::BrowserContext* browser_context); 110 bool Init(content::BrowserContext* browser_context);
111 111
112 // Notifications sent from the download thread to the UI thread 112 // Notifications sent from the download thread to the UI thread
113 void StartDownload(int32 id); 113 void StartDownload(int32 id);
114 void UpdateDownload(int32 download_id, int64 size); 114 void UpdateDownload(int32 download_id, int64 size);
115
116 // |download_id| is the ID of the download.
117 // |size| is the number of bytes that have been downloaded.
115 // |hash| is sha256 hash for the downloaded file. It is empty when the hash 118 // |hash| is sha256 hash for the downloaded file. It is empty when the hash
116 // is not available. 119 // is not available.
117 void OnResponseCompleted(int32 download_id, int64 size, int os_error, 120 void OnResponseCompleted(int32 download_id, int64 size,
118 const std::string& hash); 121 const std::string& hash);
119 122
120 // Called from a view when a user clicks a UI button or link. 123 // Called from a view when a user clicks a UI button or link.
121 void DownloadCancelled(int32 download_id); 124 void DownloadCancelled(int32 download_id);
125
126 // Called when there is an error in the download.
127 // |download_id| is the ID of the download.
128 // |size| is the number of bytes that are currently downloaded.
129 // |error| is a download error code. Indicates what caused the interruption.
130 void OnDownloadError(int32 download_id, int64 size, int error);
131
122 void RemoveDownload(int64 download_handle); 132 void RemoveDownload(int64 download_handle);
123 133
124 // Determine if the download is ready for completion, i.e. has had 134 // Determine if the download is ready for completion, i.e. has had
125 // all data saved, and completed the filename determination and 135 // all data saved, and completed the filename determination and
126 // history insertion. 136 // history insertion.
127 bool IsDownloadReadyForCompletion(DownloadItem* download); 137 bool IsDownloadReadyForCompletion(DownloadItem* download);
128 138
129 // If all pre-requisites have been met, complete download processing, i.e. 139 // If all pre-requisites have been met, complete download processing, i.e.
130 // do internal cleanup, file rename, and potentially auto-open. 140 // do internal cleanup, file rename, and potentially auto-open.
131 // (Dangerous downloads still may block on user acceptance after this 141 // (Dangerous downloads still may block on user acceptance after this
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 // Called back after a target path for the file to be downloaded to has been 285 // Called back after a target path for the file to be downloaded to has been
276 // determined, either automatically based on the suggested file name, or by 286 // determined, either automatically based on the suggested file name, or by
277 // the user in a Save As dialog box. 287 // the user in a Save As dialog box.
278 void ContinueDownloadWithPath(DownloadItem* download, 288 void ContinueDownloadWithPath(DownloadItem* download,
279 const FilePath& chosen_file); 289 const FilePath& chosen_file);
280 290
281 // Download cancel helper function. 291 // Download cancel helper function.
282 void DownloadCancelledInternal(int download_id, 292 void DownloadCancelledInternal(int download_id,
283 const DownloadRequestHandle& request_handle); 293 const DownloadRequestHandle& request_handle);
284 294
285 // All data has been downloaded. 295 // Retrieves the download from the |download_id|.
286 // |hash| is sha256 hash for the downloaded file. It is empty when the hash 296 // Returns NULL if the download is not active.
287 // is not available. 297 DownloadItem* GetActiveDownload(int32 download_id);
288 void OnAllDataSaved(int32 download_id, int64 size, const std::string& hash);
289 298
290 // An error occurred in the download. 299 // Removes |download| from the active and in progress maps.
291 void OnDownloadError(int32 download_id, int64 size, int os_error); 300 // Called when the download is cancelled or has an error.
301 // Does nothing if the download is not in the history DB.
302 void RemoveFromActiveList(DownloadItem* download);
292 303
293 // Updates the delegate about the overall download progress. 304 // Updates the delegate about the overall download progress.
294 void UpdateDownloadProgress(); 305 void UpdateDownloadProgress();
295 306
296 // Inform observers that the model has changed. 307 // Inform observers that the model has changed.
297 void NotifyModelChanged(); 308 void NotifyModelChanged();
298 309
299 // Debugging routine to confirm relationship between below 310 // Debugging routine to confirm relationship between below
300 // containers; no-op if NDEBUG. 311 // containers; no-op if NDEBUG.
301 void AssertContainersConsistent() const; 312 void AssertContainersConsistent() const;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 // user wants us to prompt for a save location for each download. 386 // user wants us to prompt for a save location for each download.
376 FilePath last_download_path_; 387 FilePath last_download_path_;
377 388
378 // Allows an embedder to control behavior. Guaranteed to outlive this object. 389 // Allows an embedder to control behavior. Guaranteed to outlive this object.
379 DownloadManagerDelegate* delegate_; 390 DownloadManagerDelegate* delegate_;
380 391
381 DISALLOW_COPY_AND_ASSIGN(DownloadManager); 392 DISALLOW_COPY_AND_ASSIGN(DownloadManager);
382 }; 393 };
383 394
384 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_ 395 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698