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

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

Issue 8404049: Added member data to classes to support download resumption. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated comment. Created 9 years 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 virtual void OpenDownload() = 0; 131 virtual void OpenDownload() = 0;
132 132
133 // Show the download via the OS shell. 133 // Show the download via the OS shell.
134 virtual void ShowDownloadInShell() = 0; 134 virtual void ShowDownloadInShell() = 0;
135 135
136 // Called when the user has validated the download of a dangerous file. 136 // Called when the user has validated the download of a dangerous file.
137 virtual void DangerousDownloadValidated() = 0; 137 virtual void DangerousDownloadValidated() = 0;
138 138
139 // Called periodically from the download thread, or from the UI thread 139 // Called periodically from the download thread, or from the UI thread
140 // for saving packages. 140 // for saving packages.
141 virtual void UpdateProgress(int64 bytes_so_far, int64 bytes_per_sec) = 0; 141 // |bytes_so_far| is the number of bytes received so far.
142 // |hash_state| is the current hash state.
143 virtual void UpdateProgress(int64 bytes_so_far,
144 int64 bytes_per_sec,
145 const std::string& hash_state) = 0;
142 146
143 // Cancel the download operation. We need to distinguish between cancels at 147 // Cancel the download operation. We need to distinguish between cancels at
144 // exit (DownloadManager destructor) from user interface initiated cancels 148 // exit (DownloadManager destructor) from user interface initiated cancels
145 // because at exit, the history system may not exist, and any updates to it 149 // because at exit, the history system may not exist, and any updates to it
146 // require AddRef'ing the DownloadManager in the destructor which results in 150 // require AddRef'ing the DownloadManager in the destructor which results in
147 // a DCHECK failure. Set |user_cancel| to false when canceling from at 151 // a DCHECK failure. Set |user_cancel| to false when canceling from at
148 // exit to prevent this crash. This may result in a difference between the 152 // exit to prevent this crash. This may result in a difference between the
149 // downloaded file's size on disk, and what the history system's last record 153 // downloaded file's size on disk, and what the history system's last record
150 // of it is. At worst, we'll end up re-downloading a small portion of the file 154 // of it is. At worst, we'll end up re-downloading a small portion of the file
151 // when resuming a download (assuming the server supports byte ranges). 155 // when resuming a download (assuming the server supports byte ranges).
(...skipping 14 matching lines...) Expand all
166 virtual void OnDownloadedFileRemoved() = 0; 170 virtual void OnDownloadedFileRemoved() = 0;
167 171
168 // If all pre-requisites have been met, complete download processing, i.e. 172 // If all pre-requisites have been met, complete download processing, i.e.
169 // do internal cleanup, file rename, and potentially auto-open. 173 // do internal cleanup, file rename, and potentially auto-open.
170 // (Dangerous downloads still may block on user acceptance after this 174 // (Dangerous downloads still may block on user acceptance after this
171 // point.) 175 // point.)
172 virtual void MaybeCompleteDownload() = 0; 176 virtual void MaybeCompleteDownload() = 0;
173 177
174 // Download operation had an error. 178 // Download operation had an error.
175 // |size| is the amount of data received at interruption. 179 // |size| is the amount of data received at interruption.
180 // |hash_state| is the current hash state at interruption.
176 // |reason| is the download interrupt reason code that the operation received. 181 // |reason| is the download interrupt reason code that the operation received.
177 virtual void Interrupted(int64 size, InterruptReason reason) = 0; 182 virtual void Interrupted(int64 size,
183 const std::string& hash_state,
184 InterruptReason reason) = 0;
178 185
179 // Deletes the file from disk and removes the download from the views and 186 // Deletes the file from disk and removes the download from the views and
180 // history. |user| should be true if this is the result of the user clicking 187 // history. |user| should be true if this is the result of the user clicking
181 // the discard button, and false if it is being deleted for other reasons like 188 // the discard button, and false if it is being deleted for other reasons like
182 // browser shutdown. 189 // browser shutdown.
183 virtual void Delete(DeleteReason reason) = 0; 190 virtual void Delete(DeleteReason reason) = 0;
184 191
185 // Removes the download from the views and history. 192 // Removes the download from the views and history.
186 virtual void Remove() = 0; 193 virtual void Remove() = 0;
187 194
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 virtual const GURL& GetReferrerUrl() const = 0; 260 virtual const GURL& GetReferrerUrl() const = 0;
254 virtual std::string GetSuggestedFilename() const = 0; 261 virtual std::string GetSuggestedFilename() const = 0;
255 virtual std::string GetContentDisposition() const = 0; 262 virtual std::string GetContentDisposition() const = 0;
256 virtual std::string GetMimeType() const = 0; 263 virtual std::string GetMimeType() const = 0;
257 virtual std::string GetOriginalMimeType() const = 0; 264 virtual std::string GetOriginalMimeType() const = 0;
258 virtual std::string GetReferrerCharset() const = 0; 265 virtual std::string GetReferrerCharset() const = 0;
259 virtual std::string GetRemoteAddress() const = 0; 266 virtual std::string GetRemoteAddress() const = 0;
260 virtual int64 GetTotalBytes() const = 0; 267 virtual int64 GetTotalBytes() const = 0;
261 virtual void SetTotalBytes(int64 total_bytes) = 0; 268 virtual void SetTotalBytes(int64 total_bytes) = 0;
262 virtual int64 GetReceivedBytes() const = 0; 269 virtual int64 GetReceivedBytes() const = 0;
270 virtual const std::string& GetHashState() const = 0;
263 virtual int32 GetId() const = 0; 271 virtual int32 GetId() const = 0;
264 virtual DownloadId GetGlobalId() const = 0; 272 virtual DownloadId GetGlobalId() const = 0;
265 virtual base::Time GetStartTime() const = 0; 273 virtual base::Time GetStartTime() const = 0;
266 virtual base::Time GetEndTime() const = 0; 274 virtual base::Time GetEndTime() const = 0;
267 virtual void SetDbHandle(int64 handle) = 0; 275 virtual void SetDbHandle(int64 handle) = 0;
268 virtual int64 GetDbHandle() const = 0; 276 virtual int64 GetDbHandle() const = 0;
269 virtual bool IsPaused() const = 0; 277 virtual bool IsPaused() const = 0;
270 virtual bool GetOpenWhenComplete() const = 0; 278 virtual bool GetOpenWhenComplete() const = 0;
271 virtual void SetOpenWhenComplete(bool open) = 0; 279 virtual void SetOpenWhenComplete(bool open) = 0;
272 virtual bool GetFileExternallyRemoved() const = 0; 280 virtual bool GetFileExternallyRemoved() const = 0;
273 virtual SafetyState GetSafetyState() const = 0; 281 virtual SafetyState GetSafetyState() const = 0;
274 // Why |safety_state_| is not SAFE. 282 // Why |safety_state_| is not SAFE.
275 virtual DownloadStateInfo::DangerType GetDangerType() const = 0; 283 virtual DownloadStateInfo::DangerType GetDangerType() const = 0;
276 virtual bool IsDangerous() const = 0; 284 virtual bool IsDangerous() const = 0;
277 virtual void MarkContentDangerous() = 0; 285 virtual void MarkContentDangerous() = 0;
278 virtual void MarkFileDangerous() = 0; 286 virtual void MarkFileDangerous() = 0;
279 virtual void MarkUrlDangerous() = 0; 287 virtual void MarkUrlDangerous() = 0;
280 288
281 virtual bool GetAutoOpened() = 0; 289 virtual bool GetAutoOpened() = 0;
282 virtual const FilePath& GetTargetName() const = 0; 290 virtual const FilePath& GetTargetName() const = 0;
283 virtual bool PromptUserForSaveLocation() const = 0; 291 virtual bool PromptUserForSaveLocation() const = 0;
284 virtual bool IsOtr() const = 0; 292 virtual bool IsOtr() const = 0;
285 virtual const FilePath& GetSuggestedPath() const = 0; 293 virtual const FilePath& GetSuggestedPath() const = 0;
286 virtual bool IsTemporary() const = 0; 294 virtual bool IsTemporary() const = 0;
287 virtual void SetOpened(bool opened) = 0; 295 virtual void SetOpened(bool opened) = 0;
288 virtual bool GetOpened() const = 0; 296 virtual bool GetOpened() const = 0;
289 297
298 virtual const std::string& GetLastModifiedTime() const = 0;
299 virtual const std::string& GetETag() const = 0;
300
290 virtual InterruptReason GetLastReason() const = 0; 301 virtual InterruptReason GetLastReason() const = 0;
291 virtual DownloadPersistentStoreInfo GetPersistentStoreInfo() const = 0; 302 virtual DownloadPersistentStoreInfo GetPersistentStoreInfo() const = 0;
292 virtual DownloadStateInfo GetStateInfo() const = 0; 303 virtual DownloadStateInfo GetStateInfo() const = 0;
293 virtual content::BrowserContext* BrowserContext() const = 0; 304 virtual content::BrowserContext* BrowserContext() const = 0;
294 virtual TabContents* GetTabContents() const = 0; 305 virtual TabContents* GetTabContents() const = 0;
295 306
296 // Returns the final target file path for the download. 307 // Returns the final target file path for the download.
297 virtual FilePath GetTargetFilePath() const = 0; 308 virtual FilePath GetTargetFilePath() const = 0;
298 309
299 // Returns the file-name that should be reported to the user, which is 310 // Returns the file-name that should be reported to the user, which is
(...skipping 30 matching lines...) Expand all
330 // (overwrites by the same pointer are ignored). 341 // (overwrites by the same pointer are ignored).
331 virtual ExternalData* GetExternalData(const void* key) = 0; 342 virtual ExternalData* GetExternalData(const void* key) = 0;
332 virtual void SetExternalData(const void* key, ExternalData* data) = 0; 343 virtual void SetExternalData(const void* key, ExternalData* data) = 0;
333 344
334 virtual std::string DebugString(bool verbose) const = 0; 345 virtual std::string DebugString(bool verbose) const = 0;
335 346
336 virtual void MockDownloadOpenForTesting() = 0; 347 virtual void MockDownloadOpenForTesting() = 0;
337 }; 348 };
338 349
339 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ 350 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698