Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: content/public/browser/download_item.h

Issue 1751603002: [Downloads] Rework how hashes are calculated for download files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase on top of https://codereview.chromium.org/1781983002 since that's going in first. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 // return the path requested. 230 // return the path requested.
233 virtual const base::FilePath& GetForcedFilePath() const = 0; 231 virtual const base::FilePath& GetForcedFilePath() const = 0;
234 232
235 // Returns the file-name that should be reported to the user. If a display 233 // Returns the file-name that should be reported to the user. If a display
236 // name has been explicitly set using SetDisplayName(), this function returns 234 // name has been explicitly set using SetDisplayName(), this function returns
237 // that display name. Otherwise returns the final target filename. 235 // that display name. Otherwise returns the final target filename.
238 virtual base::FilePath GetFileNameToReportUser() const = 0; 236 virtual base::FilePath GetFileNameToReportUser() const = 0;
239 237
240 virtual TargetDisposition GetTargetDisposition() const = 0; 238 virtual TargetDisposition GetTargetDisposition() const = 0;
241 239
242 // Final hash of completely downloaded file; not valid if 240 // Final hash of completely downloaded file, or partial hash of an interrupted
243 // GetState() != COMPLETED. 241 // download; only valid if GetState() == COMPLETED or INTERRUPTED. If
242 // non-empty the returned string contains a raw SHA-256 hash (i.e. not hex
243 // encoded).
244 virtual const std::string& GetHash() const = 0; 244 virtual const std::string& GetHash() const = 0;
245 245
246 // Intermediate hash state, for persisting partial downloads.
247 virtual const std::string& GetHashState() const = 0;
248
249 // True if the file associated with the download has been removed by 246 // True if the file associated with the download has been removed by
250 // external action. 247 // external action.
251 virtual bool GetFileExternallyRemoved() const = 0; 248 virtual bool GetFileExternallyRemoved() const = 0;
252 249
253 // If the file is successfully deleted, then GetFileExternallyRemoved() will 250 // If the file is successfully deleted, then GetFileExternallyRemoved() will
254 // become true, GetFullPath() will become empty, and 251 // become true, GetFullPath() will become empty, and
255 // DownloadItem::OnDownloadUpdated() will be called. Does nothing if 252 // DownloadItem::OnDownloadUpdated() will be called. Does nothing if
256 // GetState() == COMPLETE or GetFileExternallyRemoved() is already true or 253 // GetState() == COMPLETE or GetFileExternallyRemoved() is already true or
257 // GetFullPath() is already empty. The callback is always run, and it is 254 // GetFullPath() is already empty. The callback is always run, and it is
258 // always run asynchronously. It will be passed true if the file is 255 // always run asynchronously. It will be passed true if the file is
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 // return |name|. Has no effect on the final target filename. 339 // return |name|. Has no effect on the final target filename.
343 virtual void SetDisplayName(const base::FilePath& name) = 0; 340 virtual void SetDisplayName(const base::FilePath& name) = 0;
344 341
345 // Debug/testing ------------------------------------------------------------- 342 // Debug/testing -------------------------------------------------------------
346 virtual std::string DebugString(bool verbose) const = 0; 343 virtual std::string DebugString(bool verbose) const = 0;
347 }; 344 };
348 345
349 } // namespace content 346 } // namespace content
350 347
351 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ 348 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_
OLDNEW
« no previous file with comments | « content/public/browser/download_interrupt_reason_values.h ('k') | content/public/browser/download_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698