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