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

Unified Diff: content/browser/download/base_file.h

Issue 8404049: Added member data to classes to support download resumption. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated comment. Created 9 years 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
Index: content/browser/download/base_file.h
diff --git a/content/browser/download/base_file.h b/content/browser/download/base_file.h
index 08a0a981618ec2cc43207f6ca6077ac1a18c1972..69c937f482ca215528813905de1ba79bf03c0e93 100644
--- a/content/browser/download/base_file.h
+++ b/content/browser/download/base_file.h
@@ -34,12 +34,13 @@ class CONTENT_EXPORT BaseFile {
const GURL& source_url,
const GURL& referrer_url,
int64 received_bytes,
+ bool calculate_hash,
+ const std::string& hash_state,
const linked_ptr<net::FileStream>& file_stream);
virtual ~BaseFile();
- // If calculate_hash is true, sha256 hash will be calculated.
// Returns net::OK on success, or a network error code on failure.
- net::Error Initialize(bool calculate_hash);
+ net::Error Initialize();
// Write a new chunk of data to the file.
// Returns net::OK on success (all bytes written to the file),
@@ -69,14 +70,17 @@ class CONTENT_EXPORT BaseFile {
bool in_progress() const { return file_stream_ != NULL; }
int64 bytes_so_far() const { return bytes_so_far_; }
- // Set |hash| with sha256 digest for the file.
+ // Fills |hash| with the sha256 digest for the file.
Randy Smith (Not in Mondays) 2011/12/20 17:05:40 Basic question: Is the fact that the hash is an sh
ahendrickson 2011/12/20 22:06:54 Changed the comments to match the functions.
// Returns true if digest is successfully calculated.
- virtual bool GetSha256Hash(std::string* hash);
+ virtual bool GetHash(std::string* hash);
+
+ // Returns the current (intermediate) state of the hash as a byte string.
+ virtual std::string GetHashState();
// Returns true if the given hash is considered empty. An empty hash is
// a string of size kSha256HashLen that contains only zeros (initial value
// for the hash).
- static bool IsEmptySha256Hash(const std::string& hash);
+ static bool IsEmptyHash(const std::string& hash);
virtual std::string DebugString() const;
@@ -91,11 +95,14 @@ class CONTENT_EXPORT BaseFile {
private:
friend class BaseFileTest;
- FRIEND_TEST_ALL_PREFIXES(BaseFileTest, IsEmptySha256Hash);
+ FRIEND_TEST_ALL_PREFIXES(BaseFileTest, IsEmptyHash);
// Split out from CurrentSpeed to enable testing.
int64 CurrentSpeedAtTime(base::TimeTicks current_time) const;
+ // Resets the current state of the hash to the contents of |hash_state_bytes|.
+ virtual bool SetHashState(const std::string& hash_state_bytes);
+
static const size_t kSha256HashLen = 32;
static const unsigned char kEmptySha256Hash[kSha256HashLen];

Powered by Google App Engine
This is Rietveld 408576698