| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // Open the file associated with this download (wait for the download to | 117 // Open the file associated with this download (wait for the download to |
| 118 // complete if it is in progress). | 118 // complete if it is in progress). |
| 119 virtual void OpenDownload() = 0; | 119 virtual void OpenDownload() = 0; |
| 120 | 120 |
| 121 // Show the download via the OS shell. | 121 // Show the download via the OS shell. |
| 122 virtual void ShowDownloadInShell() = 0; | 122 virtual void ShowDownloadInShell() = 0; |
| 123 | 123 |
| 124 // Called when the user has validated the download of a dangerous file. | 124 // Called when the user has validated the download of a dangerous file. |
| 125 virtual void DangerousDownloadValidated() = 0; | 125 virtual void DangerousDownloadValidated() = 0; |
| 126 | 126 |
| 127 // Received a new chunk of data | 127 // Received a new chunk of data. |
| 128 virtual void Update(int64 bytes_so_far) = 0; | 128 // |bytes_so_far| is the number of bytes received so far. |
| 129 // |hash_state| is the current hash state. |
| 130 virtual void Update(int64 bytes_so_far, const std::string& hash_state) = 0; |
| 129 | 131 |
| 130 // Cancel the download operation. We need to distinguish between cancels at | 132 // Cancel the download operation. We need to distinguish between cancels at |
| 131 // exit (DownloadManager destructor) from user interface initiated cancels | 133 // exit (DownloadManager destructor) from user interface initiated cancels |
| 132 // because at exit, the history system may not exist, and any updates to it | 134 // because at exit, the history system may not exist, and any updates to it |
| 133 // require AddRef'ing the DownloadManager in the destructor which results in | 135 // require AddRef'ing the DownloadManager in the destructor which results in |
| 134 // a DCHECK failure. Set |user_cancel| to false when canceling from at | 136 // a DCHECK failure. Set |user_cancel| to false when canceling from at |
| 135 // exit to prevent this crash. This may result in a difference between the | 137 // exit to prevent this crash. This may result in a difference between the |
| 136 // downloaded file's size on disk, and what the history system's last record | 138 // downloaded file's size on disk, and what the history system's last record |
| 137 // of it is. At worst, we'll end up re-downloading a small portion of the file | 139 // of it is. At worst, we'll end up re-downloading a small portion of the file |
| 138 // when resuming a download (assuming the server supports byte ranges). | 140 // when resuming a download (assuming the server supports byte ranges). |
| 139 virtual void Cancel(bool user_cancel) = 0; | 141 virtual void Cancel(bool user_cancel) = 0; |
| 140 | 142 |
| 141 // Called by external code (SavePackage) using the DownloadItem interface | 143 // Called by external code (SavePackage) using the DownloadItem interface |
| 142 // to display progress when the DownloadItem should be considered complete. | 144 // to display progress when the DownloadItem should be considered complete. |
| 143 virtual void MarkAsComplete() = 0; | 145 virtual void MarkAsComplete() = 0; |
| 144 | 146 |
| 145 // Called by the delegate after it delayed opening the download in | 147 // Called by the delegate after it delayed opening the download in |
| 146 // DownloadManagerDelegate::ShouldOpenDownload. | 148 // DownloadManagerDelegate::ShouldOpenDownload. |
| 147 virtual void DelayedDownloadOpened() = 0; | 149 virtual void DelayedDownloadOpened() = 0; |
| 148 | 150 |
| 149 // Called when all data has been saved. Only has display effects. | 151 // Called when all data has been saved. Only has display effects. |
| 150 virtual void OnAllDataSaved(int64 size, const std::string& final_hash) = 0; | 152 virtual void OnAllDataSaved(int64 size, const std::string& final_hash) = 0; |
| 151 | 153 |
| 152 // Called when the downloaded file is removed. | 154 // Called when the downloaded file is removed. |
| 153 virtual void OnDownloadedFileRemoved() = 0; | 155 virtual void OnDownloadedFileRemoved() = 0; |
| 154 | 156 |
| 155 // Download operation had an error. | 157 // Download operation had an error. |
| 156 // |size| is the amount of data received at interruption. | 158 // |size| is the amount of data received at interruption. |
| 159 // |hash_state| is the current hash state at interruption. |
| 157 // |reason| is the download interrupt reason code that the operation received. | 160 // |reason| is the download interrupt reason code that the operation received. |
| 158 virtual void Interrupted(int64 size, InterruptReason reason) = 0; | 161 virtual void Interrupted(int64 size, |
| 162 const std::string& hash_state, |
| 163 InterruptReason reason) = 0; |
| 159 | 164 |
| 160 // Deletes the file from disk and removes the download from the views and | 165 // Deletes the file from disk and removes the download from the views and |
| 161 // history. |user| should be true if this is the result of the user clicking | 166 // history. |user| should be true if this is the result of the user clicking |
| 162 // the discard button, and false if it is being deleted for other reasons like | 167 // the discard button, and false if it is being deleted for other reasons like |
| 163 // browser shutdown. | 168 // browser shutdown. |
| 164 virtual void Delete(DeleteReason reason) = 0; | 169 virtual void Delete(DeleteReason reason) = 0; |
| 165 | 170 |
| 166 // Removes the download from the views and history. | 171 // Removes the download from the views and history. |
| 167 virtual void Remove() = 0; | 172 virtual void Remove() = 0; |
| 168 | 173 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 virtual const GURL& GetOriginalUrl() const = 0; | 238 virtual const GURL& GetOriginalUrl() const = 0; |
| 234 virtual const GURL& GetReferrerUrl() const = 0; | 239 virtual const GURL& GetReferrerUrl() const = 0; |
| 235 virtual std::string GetSuggestedFilename() const = 0; | 240 virtual std::string GetSuggestedFilename() const = 0; |
| 236 virtual std::string GetContentDisposition() const = 0; | 241 virtual std::string GetContentDisposition() const = 0; |
| 237 virtual std::string GetMimeType() const = 0; | 242 virtual std::string GetMimeType() const = 0; |
| 238 virtual std::string GetOriginalMimeType() const = 0; | 243 virtual std::string GetOriginalMimeType() const = 0; |
| 239 virtual std::string GetReferrerCharset() const = 0; | 244 virtual std::string GetReferrerCharset() const = 0; |
| 240 virtual int64 GetTotalBytes() const = 0; | 245 virtual int64 GetTotalBytes() const = 0; |
| 241 virtual void SetTotalBytes(int64 total_bytes) = 0; | 246 virtual void SetTotalBytes(int64 total_bytes) = 0; |
| 242 virtual int64 GetReceivedBytes() const = 0; | 247 virtual int64 GetReceivedBytes() const = 0; |
| 248 virtual const std::string& GetHashState() const = 0; |
| 243 virtual int32 GetId() const = 0; | 249 virtual int32 GetId() const = 0; |
| 244 virtual DownloadId GetGlobalId() const = 0; | 250 virtual DownloadId GetGlobalId() const = 0; |
| 245 virtual base::Time GetStartTime() const = 0; | 251 virtual base::Time GetStartTime() const = 0; |
| 246 virtual base::Time GetEndTime() const = 0; | 252 virtual base::Time GetEndTime() const = 0; |
| 247 virtual void SetDbHandle(int64 handle) = 0; | 253 virtual void SetDbHandle(int64 handle) = 0; |
| 248 virtual int64 GetDbHandle() const = 0; | 254 virtual int64 GetDbHandle() const = 0; |
| 249 virtual DownloadManager* GetDownloadManager() = 0; | 255 virtual DownloadManager* GetDownloadManager() = 0; |
| 250 virtual bool IsPaused() const = 0; | 256 virtual bool IsPaused() const = 0; |
| 251 virtual bool GetOpenWhenComplete() const = 0; | 257 virtual bool GetOpenWhenComplete() const = 0; |
| 252 virtual void SetOpenWhenComplete(bool open) = 0; | 258 virtual void SetOpenWhenComplete(bool open) = 0; |
| 253 virtual bool GetFileExternallyRemoved() const = 0; | 259 virtual bool GetFileExternallyRemoved() const = 0; |
| 254 virtual SafetyState GetSafetyState() const = 0; | 260 virtual SafetyState GetSafetyState() const = 0; |
| 255 // Why |safety_state_| is not SAFE. | 261 // Why |safety_state_| is not SAFE. |
| 256 virtual DownloadStateInfo::DangerType GetDangerType() const = 0; | 262 virtual DownloadStateInfo::DangerType GetDangerType() const = 0; |
| 257 virtual bool IsDangerous() const = 0; | 263 virtual bool IsDangerous() const = 0; |
| 258 virtual void MarkContentDangerous() = 0; | 264 virtual void MarkContentDangerous() = 0; |
| 259 virtual void MarkFileDangerous() = 0; | 265 virtual void MarkFileDangerous() = 0; |
| 260 virtual void MarkUrlDangerous() = 0; | 266 virtual void MarkUrlDangerous() = 0; |
| 261 | 267 |
| 262 virtual bool GetAutoOpened() = 0; | 268 virtual bool GetAutoOpened() = 0; |
| 263 virtual const FilePath& GetTargetName() const = 0; | 269 virtual const FilePath& GetTargetName() const = 0; |
| 264 virtual bool PromptUserForSaveLocation() const = 0; | 270 virtual bool PromptUserForSaveLocation() const = 0; |
| 265 virtual bool IsOtr() const = 0; | 271 virtual bool IsOtr() const = 0; |
| 266 virtual const FilePath& GetSuggestedPath() const = 0; | 272 virtual const FilePath& GetSuggestedPath() const = 0; |
| 267 virtual bool IsTemporary() const = 0; | 273 virtual bool IsTemporary() const = 0; |
| 268 virtual void SetOpened(bool opened) = 0; | 274 virtual void SetOpened(bool opened) = 0; |
| 269 virtual bool GetOpened() const = 0; | 275 virtual bool GetOpened() const = 0; |
| 270 | 276 |
| 277 virtual const std::string& GetLastModifiedTime() const = 0; |
| 278 virtual const std::string& GetETag() const = 0; |
| 279 |
| 271 virtual InterruptReason GetLastReason() const = 0; | 280 virtual InterruptReason GetLastReason() const = 0; |
| 272 virtual DownloadPersistentStoreInfo GetPersistentStoreInfo() const = 0; | 281 virtual DownloadPersistentStoreInfo GetPersistentStoreInfo() const = 0; |
| 273 virtual DownloadStateInfo GetStateInfo() const = 0; | 282 virtual DownloadStateInfo GetStateInfo() const = 0; |
| 274 virtual TabContents* GetTabContents() const = 0; | 283 virtual TabContents* GetTabContents() const = 0; |
| 275 | 284 |
| 276 // Returns the final target file path for the download. | 285 // Returns the final target file path for the download. |
| 277 virtual FilePath GetTargetFilePath() const = 0; | 286 virtual FilePath GetTargetFilePath() const = 0; |
| 278 | 287 |
| 279 // Returns the file-name that should be reported to the user, which is | 288 // Returns the file-name that should be reported to the user, which is |
| 280 // target_name possibly with the uniquifier number. | 289 // target_name possibly with the uniquifier number. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 295 // DownloadManager::FileSelectionCancelled() without doing some | 304 // DownloadManager::FileSelectionCancelled() without doing some |
| 296 // rewrites of the DownloadManager queues. | 305 // rewrites of the DownloadManager queues. |
| 297 virtual void OffThreadCancel(DownloadFileManager* file_manager) = 0; | 306 virtual void OffThreadCancel(DownloadFileManager* file_manager) = 0; |
| 298 | 307 |
| 299 virtual std::string DebugString(bool verbose) const = 0; | 308 virtual std::string DebugString(bool verbose) const = 0; |
| 300 | 309 |
| 301 virtual void MockDownloadOpenForTesting() = 0; | 310 virtual void MockDownloadOpenForTesting() = 0; |
| 302 }; | 311 }; |
| 303 | 312 |
| 304 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ | 313 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ |
| OLD | NEW |