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: |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 TARGET_DISPOSITION_PROMPT // Prompt the user for the actual | 75 TARGET_DISPOSITION_PROMPT // Prompt the user for the actual |
76 // target. Implies | 76 // target. Implies |
77 // TARGET_DISPOSITION_OVERWRITE. | 77 // TARGET_DISPOSITION_OVERWRITE. |
78 }; | 78 }; |
79 | 79 |
80 // Callback used with AcquireFileAndDeleteDownload(). | 80 // Callback used with AcquireFileAndDeleteDownload(). |
81 typedef base::Callback<void(const base::FilePath&)> AcquireFileCallback; | 81 typedef base::Callback<void(const base::FilePath&)> AcquireFileCallback; |
82 | 82 |
83 static const uint32_t kInvalidId; | 83 static const uint32_t kInvalidId; |
84 | 84 |
85 static const char kEmptyFileHash[]; | |
86 | |
87 // Interface that observers of a particular download must implement in order | 85 // Interface that observers of a particular download must implement in order |
88 // to receive updates to the download's status. | 86 // to receive updates to the download's status. |
89 class CONTENT_EXPORT Observer { | 87 class CONTENT_EXPORT Observer { |
90 public: | 88 public: |
91 virtual void OnDownloadUpdated(DownloadItem* download) {} | 89 virtual void OnDownloadUpdated(DownloadItem* download) {} |
92 virtual void OnDownloadOpened(DownloadItem* download) {} | 90 virtual void OnDownloadOpened(DownloadItem* download) {} |
93 virtual void OnDownloadRemoved(DownloadItem* download) {} | 91 virtual void OnDownloadRemoved(DownloadItem* download) {} |
94 | 92 |
95 // Called when the download is being destroyed. This happens after | 93 // Called when the download is being destroyed. This happens after |
96 // every OnDownloadRemoved() as well as when the DownloadManager is going | 94 // every OnDownloadRemoved() as well as when the DownloadManager is going |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 // return the path requested. | 219 // return the path requested. |
222 virtual const base::FilePath& GetForcedFilePath() const = 0; | 220 virtual const base::FilePath& GetForcedFilePath() const = 0; |
223 | 221 |
224 // Returns the file-name that should be reported to the user. If a display | 222 // Returns the file-name that should be reported to the user. If a display |
225 // name has been explicitly set using SetDisplayName(), this function returns | 223 // name has been explicitly set using SetDisplayName(), this function returns |
226 // that display name. Otherwise returns the final target filename. | 224 // that display name. Otherwise returns the final target filename. |
227 virtual base::FilePath GetFileNameToReportUser() const = 0; | 225 virtual base::FilePath GetFileNameToReportUser() const = 0; |
228 | 226 |
229 virtual TargetDisposition GetTargetDisposition() const = 0; | 227 virtual TargetDisposition GetTargetDisposition() const = 0; |
230 | 228 |
231 // Final hash of completely downloaded file; not valid if | 229 // Final hash of completely downloaded file, or partial hash of an interrupted |
232 // GetState() != COMPLETED. | 230 // download; only valid if GetState() == COMPLETED or INTERRUPTED. |
233 virtual const std::string& GetHash() const = 0; | 231 virtual const std::string& GetHash() const = 0; |
234 | 232 |
235 // Intermediate hash state, for persisting partial downloads. | |
236 virtual const std::string& GetHashState() const = 0; | |
237 | |
238 // True if the file associated with the download has been removed by | 233 // True if the file associated with the download has been removed by |
239 // external action. | 234 // external action. |
240 virtual bool GetFileExternallyRemoved() const = 0; | 235 virtual bool GetFileExternallyRemoved() const = 0; |
241 | 236 |
242 // If the file is successfully deleted, then GetFileExternallyRemoved() will | 237 // If the file is successfully deleted, then GetFileExternallyRemoved() will |
243 // become true, GetFullPath() will become empty, and | 238 // become true, GetFullPath() will become empty, and |
244 // DownloadItem::OnDownloadUpdated() will be called. Does nothing if | 239 // DownloadItem::OnDownloadUpdated() will be called. Does nothing if |
245 // GetState() == COMPLETE or GetFileExternallyRemoved() is already true or | 240 // GetState() == COMPLETE or GetFileExternallyRemoved() is already true or |
246 // GetFullPath() is already empty. The callback is always run, and it is | 241 // GetFullPath() is already empty. The callback is always run, and it is |
247 // always run asynchronously. It will be passed true if the file is | 242 // always run asynchronously. It will be passed true if the file is |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 // return |name|. Has no effect on the final target filename. | 326 // return |name|. Has no effect on the final target filename. |
332 virtual void SetDisplayName(const base::FilePath& name) = 0; | 327 virtual void SetDisplayName(const base::FilePath& name) = 0; |
333 | 328 |
334 // Debug/testing ------------------------------------------------------------- | 329 // Debug/testing ------------------------------------------------------------- |
335 virtual std::string DebugString(bool verbose) const = 0; | 330 virtual std::string DebugString(bool verbose) const = 0; |
336 }; | 331 }; |
337 | 332 |
338 } // namespace content | 333 } // namespace content |
339 | 334 |
340 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ | 335 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ |
OLD | NEW |