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

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

Issue 148133007: [Downloads] Always call DM::StartDownload() for explicit downloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Deal with downloads that are blocked by throttles. Created 4 years, 10 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 3b9b76055d1181fe7e01afb91e1b9f595bbee184..45368633c910cff0dbcf88d637d6457fb26d2257 100644
--- a/content/browser/download/download_item_impl.h
+++ b/content/browser/download/download_item_impl.h
@@ -73,6 +73,8 @@ class CONTENT_EXPORT DownloadItemImpl
// Constructing for a regular download.
// |bound_net_log| is constructed externally for our use.
+ // TODO(asanka): Get rid of the DownloadCreateInfo parameter since active
+ // downloads end up at Start() immediately after creation.
DownloadItemImpl(DownloadItemImplDelegate* delegate,
uint32_t id,
const DownloadCreateInfo& info,
@@ -167,18 +169,18 @@ class CONTENT_EXPORT DownloadItemImpl
// INTERRUPTED state.
virtual ResumeMode GetResumeMode() const;
- // Notify the download item that new origin information is available due to a
- // resumption request receiving a response.
- virtual void MergeOriginInfoOnResume(
- const DownloadCreateInfo& new_create_info);
-
// State transition operations on regular downloads --------------------------
// Start the download.
// |download_file| is the associated file on the storage medium.
// |req_handle| is the new request handle associated with the download.
+ // |new_create_info| is a DownloadCreateInfo containing the new response
+ // parameters. It may be different from the DownloadCreateInfo used to create
+ // the DownloadItem if Start() is being called in response for a download
+ // resumption request.
virtual void Start(scoped_ptr<DownloadFile> download_file,
- scoped_ptr<DownloadRequestHandleInterface> req_handle);
+ scoped_ptr<DownloadRequestHandleInterface> req_handle,
+ const DownloadCreateInfo& new_create_info);
// Needed because of intertwining with DownloadManagerImpl -------------------
@@ -246,6 +248,8 @@ class CONTENT_EXPORT DownloadItemImpl
// CANCELLED_INTERNAL: Cancelled.
TARGET_PENDING_INTERNAL,
+ INTERRUPTED_TARGET_PENDING_INTERNAL,
+
// Embedder has completed target determination. It is now safe to resolve
// the download target as well as process deferred DestinationError events.
// This state is differs from TARGET_PENDING_INTERNAL due to it being
@@ -322,13 +326,6 @@ class CONTENT_EXPORT DownloadItemImpl
MAX_DOWNLOAD_INTERNAL_STATE,
};
- // Used with TransitionTo() to indicate whether or not to call
- // UpdateObservers() after the state transition.
- enum ShouldUpdateObservers {
- UPDATE_OBSERVERS,
- DONT_UPDATE_OBSERVERS
- };
-
// Normal progression of a download ------------------------------------------
// These are listed in approximately chronological order. There are also
@@ -341,6 +338,13 @@ class CONTENT_EXPORT DownloadItemImpl
// this is.
void Init(bool active, DownloadType download_type);
+ // Callback from file thread when we initialize the DownloadFile.
+ void OnDownloadFileInitialized(DownloadInterruptReason result);
+
+ // Called to determine the target path. Will cause OnDownloadTargetDetermined
+ // to be called when the target information is available.
+ void DetermineDownloadTarget();
+
// Called when the target path has been determined. |target_path| is the
// suggested target path. |disposition| indicates how the target path should
// be used (see TargetDisposition). |danger_type| is the danger level of
@@ -352,9 +356,6 @@ class CONTENT_EXPORT DownloadItemImpl
DownloadDangerType danger_type,
const base::FilePath& intermediate_path);
- // Callback from file thread when we initialize the DownloadFile.
- void OnDownloadFileInitialized(DownloadInterruptReason result);
-
void OnDownloadRenamedToIntermediateName(
DownloadInterruptReason reason, const base::FilePath& full_path);
@@ -379,10 +380,6 @@ class CONTENT_EXPORT DownloadItemImpl
// is completed.
void Completed();
- // Callback invoked when the URLRequest for a download resumption has started.
- void OnResumeRequestStarted(DownloadItem* item,
- DownloadInterruptReason interrupt_reason);
-
// Helper routines -----------------------------------------------------------
// Indicate that an error has occurred on the download.
@@ -402,8 +399,7 @@ class CONTENT_EXPORT DownloadItemImpl
// Call to transition state; all state transitions should go through this.
// |notify_action| specifies whether or not to call UpdateObservers() after
// the state transition.
- void TransitionTo(DownloadInternalState new_state,
- ShouldUpdateObservers notify_action);
+ void TransitionTo(DownloadInternalState new_state);
// Set the |danger_type_| and invoke obserers if necessary.
void SetDangerType(DownloadDangerType danger_type);
@@ -414,6 +410,11 @@ class CONTENT_EXPORT DownloadItemImpl
void ResumeInterruptedDownload();
+ // Update origin information based on the response to a download resumption
+ // request. Should only be called if the resumption request was successful.
+ virtual void UpdateValidatorsOnResumption(
+ const DownloadCreateInfo& new_create_info);
+
static DownloadState InternalToExternalState(
DownloadInternalState internal_state);
static DownloadInternalState ExternalToInternalState(

Powered by Google App Engine
This is Rietveld 408576698