| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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: |
| 11 // DownloadItem::Observer: | 11 // DownloadItem::Observer: |
| 12 // - allows observers to receive notifications about one download from start | 12 // - allows observers to receive notifications about one download from start |
| 13 // to completion | 13 // to completion |
| 14 // Use AddObserver() / RemoveObserver() on the appropriate download object to | 14 // Use AddObserver() / RemoveObserver() on the appropriate download object to |
| 15 // receive state updates. | 15 // receive state updates. |
| 16 | 16 |
| 17 #ifndef CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ | 17 #ifndef CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ |
| 18 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ | 18 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ |
| 19 #pragma once | 19 #pragma once |
| 20 | 20 |
| 21 #include <map> | 21 #include <map> |
| 22 #include <string> | 22 #include <string> |
| 23 | 23 |
| 24 #include "base/string16.h" | 24 #include "base/string16.h" |
| 25 #include "content/browser/download/download_state_info.h" | 25 #include "content/browser/download/download_state_info.h" |
| 26 #include "content/browser/download/interrupt_reasons.h" | |
| 27 #include "content/public/browser/download_danger_type.h" | 26 #include "content/public/browser/download_danger_type.h" |
| 27 #include "content/public/browser/download_interrupt_reasons.h" |
| 28 | 28 |
| 29 class DownloadFileManager; | 29 class DownloadFileManager; |
| 30 class FilePath; | 30 class FilePath; |
| 31 class GURL; | 31 class GURL; |
| 32 struct DownloadCreateInfo; | 32 struct DownloadCreateInfo; |
| 33 struct DownloadPersistentStoreInfo; | 33 struct DownloadPersistentStoreInfo; |
| 34 | 34 |
| 35 namespace base { | 35 namespace base { |
| 36 class Time; | 36 class Time; |
| 37 class TimeDelta; | 37 class TimeDelta; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 // (Dangerous downloads still may block on user acceptance after this | 176 // (Dangerous downloads still may block on user acceptance after this |
| 177 // point.) | 177 // point.) |
| 178 virtual void MaybeCompleteDownload() = 0; | 178 virtual void MaybeCompleteDownload() = 0; |
| 179 | 179 |
| 180 // Download operation had an error. | 180 // Download operation had an error. |
| 181 // |size| is the amount of data received at interruption. | 181 // |size| is the amount of data received at interruption. |
| 182 // |hash_state| is the current hash state at interruption. | 182 // |hash_state| is the current hash state at interruption. |
| 183 // |reason| is the download interrupt reason code that the operation received. | 183 // |reason| is the download interrupt reason code that the operation received. |
| 184 virtual void Interrupted(int64 size, | 184 virtual void Interrupted(int64 size, |
| 185 const std::string& hash_state, | 185 const std::string& hash_state, |
| 186 InterruptReason reason) = 0; | 186 DownloadInterruptReason reason) = 0; |
| 187 | 187 |
| 188 // Deletes the file from disk and removes the download from the views and | 188 // Deletes the file from disk and removes the download from the views and |
| 189 // history. |user| should be true if this is the result of the user clicking | 189 // history. |user| should be true if this is the result of the user clicking |
| 190 // the discard button, and false if it is being deleted for other reasons like | 190 // the discard button, and false if it is being deleted for other reasons like |
| 191 // browser shutdown. | 191 // browser shutdown. |
| 192 virtual void Delete(DeleteReason reason) = 0; | 192 virtual void Delete(DeleteReason reason) = 0; |
| 193 | 193 |
| 194 // Removes the download from the views and history. | 194 // Removes the download from the views and history. |
| 195 virtual void Remove() = 0; | 195 virtual void Remove() = 0; |
| 196 | 196 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 virtual bool PromptUserForSaveLocation() const = 0; | 294 virtual bool PromptUserForSaveLocation() const = 0; |
| 295 virtual bool IsOtr() const = 0; | 295 virtual bool IsOtr() const = 0; |
| 296 virtual const FilePath& GetSuggestedPath() const = 0; | 296 virtual const FilePath& GetSuggestedPath() const = 0; |
| 297 virtual bool IsTemporary() const = 0; | 297 virtual bool IsTemporary() const = 0; |
| 298 virtual void SetOpened(bool opened) = 0; | 298 virtual void SetOpened(bool opened) = 0; |
| 299 virtual bool GetOpened() const = 0; | 299 virtual bool GetOpened() const = 0; |
| 300 | 300 |
| 301 virtual const std::string& GetLastModifiedTime() const = 0; | 301 virtual const std::string& GetLastModifiedTime() const = 0; |
| 302 virtual const std::string& GetETag() const = 0; | 302 virtual const std::string& GetETag() const = 0; |
| 303 | 303 |
| 304 virtual InterruptReason GetLastReason() const = 0; | 304 virtual DownloadInterruptReason GetLastReason() const = 0; |
| 305 virtual DownloadPersistentStoreInfo GetPersistentStoreInfo() const = 0; | 305 virtual DownloadPersistentStoreInfo GetPersistentStoreInfo() const = 0; |
| 306 virtual DownloadStateInfo GetStateInfo() const = 0; | 306 virtual DownloadStateInfo GetStateInfo() const = 0; |
| 307 virtual BrowserContext* GetBrowserContext() const = 0; | 307 virtual BrowserContext* GetBrowserContext() const = 0; |
| 308 virtual WebContents* GetWebContents() const = 0; | 308 virtual WebContents* GetWebContents() const = 0; |
| 309 | 309 |
| 310 // Returns the final target file path for the download. | 310 // Returns the final target file path for the download. |
| 311 virtual FilePath GetTargetFilePath() const = 0; | 311 virtual FilePath GetTargetFilePath() const = 0; |
| 312 | 312 |
| 313 // Returns the file-name that should be reported to the user. If a display | 313 // Returns the file-name that should be reported to the user. If a display |
| 314 // name has been explicitly set using SetDisplayName(), this function returns | 314 // name has been explicitly set using SetDisplayName(), this function returns |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 virtual void SetExternalData(const void* key, ExternalData* data) = 0; | 353 virtual void SetExternalData(const void* key, ExternalData* data) = 0; |
| 354 | 354 |
| 355 virtual std::string DebugString(bool verbose) const = 0; | 355 virtual std::string DebugString(bool verbose) const = 0; |
| 356 | 356 |
| 357 virtual void MockDownloadOpenForTesting() = 0; | 357 virtual void MockDownloadOpenForTesting() = 0; |
| 358 }; | 358 }; |
| 359 | 359 |
| 360 } // namespace content | 360 } // namespace content |
| 361 | 361 |
| 362 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ | 362 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ |
| OLD | NEW |