Index: content/browser/download/download_item.h |
=================================================================== |
--- content/browser/download/download_item.h (revision 102135) |
+++ content/browser/download/download_item.h (working copy) |
@@ -157,11 +157,16 @@ |
// Received a new chunk of data |
void Update(int64 bytes_so_far); |
- // Cancel the download operation. This may be called at any time; if |
- // it is called before all download attributes have been finalized and |
- // the download entered into the history, it will remove the download from |
- // the system. |
- void Cancel(); |
+ // Cancel the download operation. We need to distinguish between cancels at |
+ // exit (DownloadManager destructor) from user interface initiated cancels |
+ // because at exit, the history system may not exist, and any updates to it |
+ // require AddRef'ing the DownloadManager in the destructor which results in |
+ // a DCHECK failure. Set 'update_history' to false when canceling from at |
+ // exit to prevent this crash. This may result in a difference between the |
+ // downloaded file's size on disk, and what the history system's last record |
+ // of it is. At worst, we'll end up re-downloading a small portion of the file |
+ // when resuming a download (assuming the server supports byte ranges). |
+ void Cancel(bool update_history); |
// Called by external code (SavePackage) using the DownloadItem interface |
// to display progress when the DownloadItem should be considered complete. |
@@ -177,14 +182,10 @@ |
// Called when the downloaded file is removed. |
void OnDownloadedFileRemoved(); |
- // Download operation had an error; call to interrupt the processing. |
- // Note that if the download attributes haven't yet been finalized and |
- // the download entered into the history (which implies that it hasn't |
- // yet been made visible in the UI), this call will remove the |
- // download from the system. |
- // |size| is the amount of data received so far, and |net_error| is the |
- // error code that the operation received. |
- void Interrupt(int64 size, net::Error net_error); |
+ // Download operation had an error. |
+ // |size| is the amount of data received at interruption. |
+ // |error| is the network error code that the operation received. |
+ void Interrupted(int64 size, net::Error error); |
// Deletes the file from disk and removes the download from the views and |
// history. |user| should be true if this is the result of the user clicking |
@@ -356,8 +357,7 @@ |
void StartProgressTimer(); |
void StopProgressTimer(); |
- // Does the actual work of transition state; all state |
- // transitions should go through this. |
+ // Call to transition state; all state transitions should go through this. |
void TransitionTo(DownloadState new_state); |
// Called when safety_state_ should be recomputed from is_dangerous_file |