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

Unified Diff: content/public/browser/download_url_parameters.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/public/browser/download_save_info.cc ('k') | content/public/test/mock_download_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/browser/download_url_parameters.h
diff --git a/content/public/browser/download_url_parameters.h b/content/public/browser/download_url_parameters.h
index 5734e91cd2d1059694eeb8d85265cb4dcf962dbc..1f49274c49513cf7688d5766a111e69f5229500d 100644
--- a/content/public/browser/download_url_parameters.h
+++ b/content/public/browser/download_url_parameters.h
@@ -155,8 +155,21 @@ class CONTENT_EXPORT DownloadUrlParameters {
// If |offset| is non-zero, then a byte range request will be issued to fetch
// the range of bytes starting at |offset| through to the end of thedownload.
void set_offset(int64_t offset) { save_info_.offset = offset; }
- void set_hash_state(const std::string& hash_state) {
- save_info_.hash_state = hash_state;
+
+ // If |offset| is non-zero, then |hash_of_partial_file| contains the raw
+ // SHA-256 hash of the first |offset| bytes of the target file. Only
+ // meaningful if a partial file exists and is identified by either the
+ // |file_path()| or |file()|.
+ void set_hash_of_partial_file(const std::string& hash_of_partial_file) {
+ save_info_.hash_of_partial_file = hash_of_partial_file;
+ }
+
+ // If |offset| is non-zero, then |hash_state| indicates the SHA-256 hash state
+ // of the first |offset| bytes of the target file. In this case, the prefix
+ // hash will be ignored since the |hash_state| is assumed to be correct if
+ // provided.
+ void set_hash_state(scoped_ptr<crypto::SecureHash> hash_state) {
+ save_info_.hash_state = std::move(hash_state);
}
// If |prompt| is true, then the user will be prompted for a filename. Ignored
@@ -191,14 +204,16 @@ class CONTENT_EXPORT DownloadUrlParameters {
return save_info_.suggested_name;
}
int64_t offset() const { return save_info_.offset; }
- const std::string& hash_state() const { return save_info_.hash_state; }
+ const std::string& hash_of_partial_file() const {
+ return save_info_.hash_of_partial_file;
+ }
bool prompt() const { return save_info_.prompt_for_save_location; }
const GURL& url() const { return url_; }
bool do_not_prompt_for_login() const { return do_not_prompt_for_login_; }
- // Note that this is state changing--the DownloadUrlParameters object
- // will not have a file attached to it after this call.
- base::File GetFile() { return std::move(save_info_.file); }
+ // STATE CHANGING: All save_info_ sub-objects will be in an indeterminate
+ // state following this call.
+ DownloadSaveInfo GetSaveInfo() { return std::move(save_info_); }
private:
OnStartedCallback callback_;
« no previous file with comments | « content/public/browser/download_save_info.cc ('k') | content/public/test/mock_download_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698