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

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: Merged with trunk Created 9 years, 1 month 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 2a0994358055c89d9f84c59b1fca13c4f5076f5e..64a94f7cb6657dc6ed6264af02fa424295e723c2 100644
--- a/content/browser/download/base_file.h
+++ b/content/browser/download/base_file.h
@@ -12,12 +12,15 @@
#include "base/gtest_prod_util.h"
#include "base/memory/linked_ptr.h"
#include "base/memory/scoped_ptr.h"
+#include "base/pickle.h"
#include "content/browser/power_save_blocker.h"
#include "content/common/content_export.h"
#include "googleurl/src/gurl.h"
#include "net/base/file_stream.h"
#include "net/base/net_errors.h"
+class Pickle;
Randy Smith (Not in Mondays) 2011/11/21 02:10:17 I don't think Pickle belongs in the interface to *
ahendrickson 2011/11/21 20:34:47 Done.
+
namespace crypto {
class SecureHash;
}
@@ -33,6 +36,7 @@ class CONTENT_EXPORT BaseFile {
const GURL& source_url,
const GURL& referrer_url,
int64 received_bytes,
+ const Pickle& hash_state,
const linked_ptr<net::FileStream>& file_stream);
virtual ~BaseFile();
@@ -65,10 +69,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. May be partial.
// Returns true if digest is successfully calculated.
virtual bool GetSha256Hash(std::string* hash);
+ // Retrieves the current (intermediate) state of the hash and puts it in
+ // |hash_state|.
+ virtual bool GetSha256HashState(Pickle* hash_state);
+
+ // Resets the current state of the hash to the contents of |hash_state|.
+ virtual bool SetSha256HashState(Pickle* hash_state);
+
// 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).
@@ -114,6 +125,9 @@ class CONTENT_EXPORT BaseFile {
// is set.
scoped_ptr<crypto::SecureHash> secure_hash_;
+ // The hash state is stored here on creation.
+ Pickle initial_hash_state_;
+
unsigned char sha256_hash_[kSha256HashLen];
// Indicates that this class no longer owns the associated file, and so

Powered by Google App Engine
This is Rietveld 408576698