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

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

Issue 7796014: Make cancel remove cancelled download from active queues at time of cancel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Final Cancel arg fix. 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 // Each download is represented by a DownloadItem, and all DownloadItems 5 // Each download is represented by a DownloadItem, and all DownloadItems
6 // are owned by the DownloadManager which maintains a global list of all 6 // are owned by the DownloadManager which maintains a global list of all
7 // downloads. DownloadItems are created when a user initiates a download, 7 // downloads. DownloadItems are created when a user initiates a download,
8 // and exist for the duration of the browser life time. 8 // and exist for the duration of the browser life time.
9 // 9 //
10 // Download observers: 10 // Download observers:
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 149
150 // Show the download via the OS shell. 150 // Show the download via the OS shell.
151 void ShowDownloadInShell(); 151 void ShowDownloadInShell();
152 152
153 // Called when the user has validated the download of a dangerous file. 153 // Called when the user has validated the download of a dangerous file.
154 void DangerousDownloadValidated(); 154 void DangerousDownloadValidated();
155 155
156 // Received a new chunk of data 156 // Received a new chunk of data
157 void Update(int64 bytes_so_far); 157 void Update(int64 bytes_so_far);
158 158
159 // Cancel the download operation. We need to distinguish between cancels at 159 // Cancel the download operation. This may be called at any time; if
160 // exit (DownloadManager destructor) from user interface initiated cancels 160 // it is called before all download attributes have been finalized and
161 // because at exit, the history system may not exist, and any updates to it 161 // the download entered into the history, it will remove the download from
162 // require AddRef'ing the DownloadManager in the destructor which results in 162 // the system.
163 // a DCHECK failure. Set 'update_history' to false when canceling from at 163 void Cancel();
164 // exit to prevent this crash. This may result in a difference between the
165 // downloaded file's size on disk, and what the history system's last record
166 // of it is. At worst, we'll end up re-downloading a small portion of the file
167 // when resuming a download (assuming the server supports byte ranges).
168 void Cancel(bool update_history);
169 164
170 // Called by external code (SavePackage) using the DownloadItem interface 165 // Called by external code (SavePackage) using the DownloadItem interface
171 // to display progress when the DownloadItem should be considered complete. 166 // to display progress when the DownloadItem should be considered complete.
172 void MarkAsComplete(); 167 void MarkAsComplete();
173 168
174 // Called by the delegate after it delayed completing the download in 169 // Called by the delegate after it delayed completing the download in
175 // DownloadManagerDelegate::ShouldCompleteDownload. 170 // DownloadManagerDelegate::ShouldCompleteDownload.
176 void CompleteDelayedDownload(); 171 void CompleteDelayedDownload();
177 172
178 // Called when all data has been saved. Only has display effects. 173 // Called when all data has been saved. Only has display effects.
179 void OnAllDataSaved(int64 size); 174 void OnAllDataSaved(int64 size);
180 175
181 // Called when the downloaded file is removed. 176 // Called when the downloaded file is removed.
182 void OnDownloadedFileRemoved(); 177 void OnDownloadedFileRemoved();
183 178
184 // Download operation had an error. 179 // Download operation had an error; call to interrupt the processing.
185 // |size| is the amount of data received at interruption. 180 // Note that if the download attributes haven't yet been finalized and
186 // |error| is the network error code that the operation received. 181 // the download entered into the history (which implies that it hasn't
187 void Interrupted(int64 size, net::Error error); 182 // yet been made visible in the UI), this call will remove the
183 // download from the system.
184 // |size| is the amount of data received so far, and |os_error| is the error
ahendrickson 2011/09/11 15:57:02 Nit: |net_error| (or change it to |error|, as it w
Randy Smith (Not in Mondays) 2011/09/12 18:00:27 Done.
185 // code that the operation received.
186 void Interrupt(int64 size, net::Error net_error);
188 187
189 // Deletes the file from disk and removes the download from the views and 188 // Deletes the file from disk and removes the download from the views and
190 // history. |user| should be true if this is the result of the user clicking 189 // history. |user| should be true if this is the result of the user clicking
191 // the discard button, and false if it is being deleted for other reasons like 190 // the discard button, and false if it is being deleted for other reasons like
192 // browser shutdown. 191 // browser shutdown.
193 void Delete(DeleteReason reason); 192 void Delete(DeleteReason reason);
194 193
195 // Removes the download from the views and history. 194 // Removes the download from the views and history.
196 void Remove(); 195 void Remove();
197 196
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 #endif 338 #endif
340 339
341 private: 340 private:
342 // Construction common to all constructors. |active| should be true for new 341 // Construction common to all constructors. |active| should be true for new
343 // downloads and false for downloads from the history. 342 // downloads and false for downloads from the history.
344 void Init(bool active); 343 void Init(bool active);
345 344
346 // Internal helper for maintaining consistent received and total sizes. 345 // Internal helper for maintaining consistent received and total sizes.
347 void UpdateSize(int64 size); 346 void UpdateSize(int64 size);
348 347
348 // Internal function to do the main work of cancelling or
349 // interrupting a download.
350 void StopInternal(DownloadState target_state);
351
349 // Called when the entire download operation (including renaming etc) 352 // Called when the entire download operation (including renaming etc)
350 // is completed. 353 // is completed.
351 void Completed(); 354 void Completed();
352 355
353 // Start/stop sending periodic updates to our observers 356 // Start/stop sending periodic updates to our observers
354 void StartProgressTimer(); 357 void StartProgressTimer();
355 void StopProgressTimer(); 358 void StopProgressTimer();
356 359
357 // Call to transition state; all state transitions should go through this. 360 // Call to transition state; all state transitions should go through this.
358 void TransitionTo(DownloadState new_state); 361 void TransitionTo(DownloadState new_state);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 // only. 479 // only.
477 bool open_enabled_; 480 bool open_enabled_;
478 481
479 // Did the delegate delay calling Complete on this download? 482 // Did the delegate delay calling Complete on this download?
480 bool delegate_delayed_complete_; 483 bool delegate_delayed_complete_;
481 484
482 DISALLOW_COPY_AND_ASSIGN(DownloadItem); 485 DISALLOW_COPY_AND_ASSIGN(DownloadItem);
483 }; 486 };
484 487
485 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ 488 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698