| 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 | 19 |
| 20 #include <map> | 20 #include <map> |
| 21 #include <string> | 21 #include <string> |
| 22 #include <vector> | 22 #include <vector> |
| 23 | 23 |
| 24 #include "base/file_path.h" | 24 #include "base/file_path.h" |
| 25 #include "base/string16.h" | 25 #include "base/string16.h" |
| 26 #include "base/supports_user_data.h" | 26 #include "base/supports_user_data.h" |
| 27 #include "content/public/browser/download_danger_type.h" | 27 #include "content/public/browser/download_danger_type.h" |
| 28 #include "content/public/browser/download_interrupt_reasons.h" | 28 #include "content/public/browser/download_interrupt_reasons.h" |
| 29 #include "content/public/common/page_transition_types.h" | 29 #include "content/public/common/page_transition_types.h" |
| 30 #include "net/base/net_log.h" |
| 30 | 31 |
| 31 class FilePath; | 32 class FilePath; |
| 32 class GURL; | 33 class GURL; |
| 33 | 34 |
| 34 namespace base { | 35 namespace base { |
| 35 class Time; | 36 class Time; |
| 36 class TimeDelta; | 37 class TimeDelta; |
| 37 } | 38 } |
| 38 | 39 |
| 39 namespace content { | 40 namespace content { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 virtual void UpdateObservers() = 0; | 116 virtual void UpdateObservers() = 0; |
| 116 | 117 |
| 117 // User Actions -------------------------------------------------------------- | 118 // User Actions -------------------------------------------------------------- |
| 118 | 119 |
| 119 // Called when the user has validated the download of a dangerous file. | 120 // Called when the user has validated the download of a dangerous file. |
| 120 virtual void DangerousDownloadValidated() = 0; | 121 virtual void DangerousDownloadValidated() = 0; |
| 121 | 122 |
| 122 // Allow the user to temporarily pause a download or resume a paused download. | 123 // Allow the user to temporarily pause a download or resume a paused download. |
| 123 virtual void TogglePause() = 0; | 124 virtual void TogglePause() = 0; |
| 124 | 125 |
| 126 // Resume a download that's been interrupted. |
| 127 virtual void ResumeInterruptedDownload() = 0; |
| 128 |
| 125 // Cancel the download operation. We need to distinguish between cancels at | 129 // Cancel the download operation. We need to distinguish between cancels at |
| 126 // exit (DownloadManager destructor) from user interface initiated cancels | 130 // exit (DownloadManager destructor) from user interface initiated cancels |
| 127 // because at exit, the history system may not exist, and any updates to it | 131 // because at exit, the history system may not exist, and any updates to it |
| 128 // require AddRef'ing the DownloadManager in the destructor which results in | 132 // require AddRef'ing the DownloadManager in the destructor which results in |
| 129 // a DCHECK failure. Set |user_cancel| to false when canceling from at | 133 // a DCHECK failure. Set |user_cancel| to false when canceling from at |
| 130 // exit to prevent this crash. This may result in a difference between the | 134 // exit to prevent this crash. This may result in a difference between the |
| 131 // downloaded file's size on disk, and what the history system's last record | 135 // downloaded file's size on disk, and what the history system's last record |
| 132 // of it is. At worst, we'll end up re-downloading a small portion of the file | 136 // of it is. At worst, we'll end up re-downloading a small portion of the file |
| 133 // when resuming a download (assuming the server supports byte ranges). | 137 // when resuming a download (assuming the server supports byte ranges). |
| 134 virtual void Cancel(bool user_cancel) = 0; | 138 virtual void Cancel(bool user_cancel) = 0; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 150 // State accessors ----------------------------------------------------------- | 154 // State accessors ----------------------------------------------------------- |
| 151 | 155 |
| 152 virtual int32 GetId() const = 0; | 156 virtual int32 GetId() const = 0; |
| 153 virtual DownloadId GetGlobalId() const = 0; | 157 virtual DownloadId GetGlobalId() const = 0; |
| 154 virtual DownloadState GetState() const = 0; | 158 virtual DownloadState GetState() const = 0; |
| 155 | 159 |
| 156 // Only valid if |GetState() == DownloadItem::INTERRUPTED|. | 160 // Only valid if |GetState() == DownloadItem::INTERRUPTED|. |
| 157 virtual DownloadInterruptReason GetLastReason() const = 0; | 161 virtual DownloadInterruptReason GetLastReason() const = 0; |
| 158 | 162 |
| 159 virtual bool IsPaused() const = 0; | 163 virtual bool IsPaused() const = 0; |
| 164 virtual bool CanResumeInterrupted() const = 0; |
| 160 virtual bool IsTemporary() const = 0; | 165 virtual bool IsTemporary() const = 0; |
| 161 | 166 |
| 162 // Convenience routines for accessing GetState() results conceptually ----- | 167 // Convenience routines for accessing GetState() results conceptually ----- |
| 163 | 168 |
| 164 // Returns true if the download needs more data. | 169 // Returns true if the download needs more data. |
| 165 virtual bool IsPartialDownload() const = 0; | 170 virtual bool IsPartialDownload() const = 0; |
| 166 | 171 |
| 167 // Returns true if the download is still receiving data. | 172 // Returns true if the download is still receiving data. |
| 168 virtual bool IsInProgress() const = 0; | 173 virtual bool IsInProgress() const = 0; |
| 169 | 174 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 virtual base::Time GetEndTime() const = 0; | 275 virtual base::Time GetEndTime() const = 0; |
| 271 | 276 |
| 272 // Open/Show State accessors ---------------------------------------------- | 277 // Open/Show State accessors ---------------------------------------------- |
| 273 | 278 |
| 274 // Returns true if it is OK to open a folder which this file is inside. | 279 // Returns true if it is OK to open a folder which this file is inside. |
| 275 virtual bool CanShowInFolder() = 0; | 280 virtual bool CanShowInFolder() = 0; |
| 276 | 281 |
| 277 // Returns true if it is OK to open the download. | 282 // Returns true if it is OK to open the download. |
| 278 virtual bool CanOpenDownload() = 0; | 283 virtual bool CanOpenDownload() = 0; |
| 279 | 284 |
| 285 // Returns true if the download is paused or interrupted, and can be resumed. |
| 286 virtual bool CanResumeDownload() const = 0; |
| 287 |
| 280 // Tests if a file type should be opened automatically. | 288 // Tests if a file type should be opened automatically. |
| 281 virtual bool ShouldOpenFileBasedOnExtension() = 0; | 289 virtual bool ShouldOpenFileBasedOnExtension() = 0; |
| 282 | 290 |
| 283 // Returns true if the download will be auto-opened when complete. | 291 // Returns true if the download will be auto-opened when complete. |
| 284 virtual bool GetOpenWhenComplete() const = 0; | 292 virtual bool GetOpenWhenComplete() const = 0; |
| 285 | 293 |
| 286 // Returns true if the download has been auto-opened by the system. | 294 // Returns true if the download has been auto-opened by the system. |
| 287 virtual bool GetAutoOpened() = 0; | 295 virtual bool GetAutoOpened() = 0; |
| 288 | 296 |
| 289 // Returns true if the download has been opened. | 297 // Returns true if the download has been opened. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 319 virtual void SetDisplayName(const FilePath& name) = 0; | 327 virtual void SetDisplayName(const FilePath& name) = 0; |
| 320 | 328 |
| 321 // Debug/testing ------------------------------------------------------------- | 329 // Debug/testing ------------------------------------------------------------- |
| 322 virtual std::string DebugString(bool verbose) const = 0; | 330 virtual std::string DebugString(bool verbose) const = 0; |
| 323 virtual void MockDownloadOpenForTesting() = 0; | 331 virtual void MockDownloadOpenForTesting() = 0; |
| 324 }; | 332 }; |
| 325 | 333 |
| 326 } // namespace content | 334 } // namespace content |
| 327 | 335 |
| 328 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ | 336 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ |
| OLD | NEW |