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

Unified Diff: content/browser/download/download_item_impl.h

Issue 10950015: Shift "commit point" for when a download will no longer accept cancels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporated comments. Created 8 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/download/download_item_impl.h
diff --git a/content/browser/download/download_item_impl.h b/content/browser/download/download_item_impl.h
index ad8ed4db2fe8bc2d999a1149777831f7503bc0b2..bf7d1bdcbb50ac488114a979a2030589d2bdd133 100644
--- a/content/browser/download/download_item_impl.h
+++ b/content/browser/download/download_item_impl.h
@@ -207,6 +207,41 @@ class CONTENT_EXPORT DownloadItemImpl : public content::DownloadItem {
virtual void SetDbHandle(int64 handle);
private:
+ // Fine grained states of a download.
+ enum DownloadInternalState {
+ // Unless otherwise specified, state transitions are linear forward
+ // in this list.
+
+ // Includes both before and after file name determination.
+ // TODO(rdsmith): Put in state variable for file name determination.
+ IN_PROGRESS_INTERNAL,
+
+ // Between commit point (dispatch of download file release) and
+ // completed. Embedder may be opening the file in this state.
+ COMPLETING_INTERNAL,
+
+ // After embedder has had a chance to auto-open. User may now open
+ // or auto-open based on extension.
+ COMPLETE_INTERNAL,
+
+ // User has cancelled the download.
+ // Only incoming transition IN_PROGRESS->
+ CANCELLED_INTERNAL,
+
+ // An error has interrupted the download.
+ // Only incoming transition IN_PROGRESS->
+ INTERRUPTED_INTERNAL,
+
+ MAX_DOWNLOAD_INTERNAL_STATE,
+ };
+
+ // Map from DownloadInternalState -> DownloadState.
+ static const DownloadState kInternalStateMap[];
+
+ // Map from DownloadState -> DownloadInternalState (for external
+ // initialization).
+ static const DownloadInternalState kExternalStateMap[];
+
// Normal progression of a download ------------------------------------------
// These are listed in approximately chronological order. There are also
@@ -249,13 +284,16 @@ class CONTENT_EXPORT DownloadItemImpl : public content::DownloadItem {
const std::string& final_hash);
// Call to transition state; all state transitions should go through this.
- void TransitionTo(DownloadState new_state);
+ void TransitionTo(DownloadInternalState new_state);
// Set the |danger_type_| and invoke obserers if necessary.
void SetDangerType(content::DownloadDangerType danger_type);
void SetFullPath(const FilePath& new_path);
+ // Debugging routines --------------------------------------------------------
+ static const char* DebugDownloadStateString(DownloadInternalState state);
+
// The handle to the request information. Used for operations outside the
// download system.
scoped_ptr<DownloadRequestHandleInterface> request_handle_;
@@ -353,7 +391,7 @@ class CONTENT_EXPORT DownloadItemImpl : public content::DownloadItem {
base::TimeTicks start_tick_;
// The current state of this download.
- DownloadState state_;
+ DownloadInternalState state_;
// Current danger type for the download.
content::DownloadDangerType danger_type_;

Powered by Google App Engine
This is Rietveld 408576698