summaryrefslogtreecommitdiffstats
path: root/chrome/browser/download/download_item.h
diff options
context:
space:
mode:
authorrdsmith@chromium.org <rdsmith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-23 16:24:54 +0000
committerrdsmith@chromium.org <rdsmith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-23 16:24:54 +0000
commitadb2f3d15ea878991ff987e4d4740605f5e1417f (patch)
treee91c844feaa67d5e4f1f8057524d8d270d56ac1e /chrome/browser/download/download_item.h
parent7a028d30364d6712b0f13bf897714e0ce4f3787b (diff)
downloadchromium_src-adb2f3d15ea878991ff987e4d4740605f5e1417f.zip
chromium_src-adb2f3d15ea878991ff987e4d4740605f5e1417f.tar.gz
chromium_src-adb2f3d15ea878991ff987e4d4740605f5e1417f.tar.bz2
Put history insertion for downloads processing inline.
This change shifts standard download processing to wait on history insertion (note that actual data download does not wait). This makes the download process less racy and is expected to make the download tests less flaky. Note that it also brings the rename to the download intermediate file rename inline into standard download processing; i.e. now we always rename to the intermediate file name and then to the final file name. This again reduces raciness and possibly tset flakiness. BUG=63237 TEST=All current download tests. Review URL: http://codereview.chromium.org/6096003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72301 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download/download_item.h')
-rw-r--r--chrome/browser/download/download_item.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/chrome/browser/download/download_item.h b/chrome/browser/download/download_item.h
index bc32f63..eaa9a55 100644
--- a/chrome/browser/download/download_item.h
+++ b/chrome/browser/download/download_item.h
@@ -40,8 +40,19 @@ class DownloadItem {
public:
enum DownloadState {
IN_PROGRESS,
+
+ // Note that COMPLETE indicates that the download has gotten all of its
+ // data, has figured out its final destination file, has been entered
+ // into the history store, and has been shown in the UI. The only
+ // operations remaining are acceptance by the user of
+ // a dangerous download (if dangerous), renaming the file
+ // to the final name, and auto-opening it (if it auto-opens).
COMPLETE,
+
CANCELLED,
+
+ // This state indicates that the download item is about to be destroyed,
+ // and observers seeing this state should release all references.
REMOVING
};
@@ -128,9 +139,13 @@ class DownloadItem {
// when resuming a download (assuming the server supports byte ranges).
void Cancel(bool update_history);
- // Called when all data has been saved.
+ // Called when all data has been saved. Only has display effects.
void OnAllDataSaved(int64 size);
+ // Called when ready to consider the data received and move on to the
+ // next stage.
+ void MarkAsComplete();
+
// Called when the entire download operation (including renaming etc)
// is finished.
void Finished();
@@ -152,6 +167,9 @@ class DownloadItem {
// total size).
int PercentComplete() const;
+ // Whether or not this download has saved all of its data.
+ bool all_data_saved() const { return all_data_saved_; }
+
// Update the fields that may have changed in DownloadCreateInfo as a
// result of analyzing the file and figuring out its type, location, etc.
// May only be called once.
@@ -340,6 +358,9 @@ class DownloadItem {
// True if the item was downloaded temporarily.
bool is_temporary_;
+ // True if we've saved all the data for the download.
+ bool all_data_saved_;
+
// Did the user open the item either directly or indirectly (such as by
// setting always open files of this type)? The shelf also sets this field
// when the user closes the shelf before the item has been opened but should