diff options
author | asargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-10 20:44:40 +0000 |
---|---|---|
committer | asargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-10 20:44:40 +0000 |
commit | f83bd43bfe88d0164f994565d2f19d595c25d2ac (patch) | |
tree | 3524604940049293bd518e84c3f2e5a35ebb5c0c /extensions/browser/content_verify_job.h | |
parent | 8ab0c4b2944a891a836e2a474613f52032e8184c (diff) | |
download | chromium_src-f83bd43bfe88d0164f994565d2f19d595c25d2ac.zip chromium_src-f83bd43bfe88d0164f994565d2f19d595c25d2ac.tar.gz chromium_src-f83bd43bfe88d0164f994565d2f19d595c25d2ac.tar.bz2 |
More implementation details of extension content verification
-Added classes for fetching/reading file hashes (.cc details are still
mostly stubs in this CL though)
-Added a delegate class for ContentVerifier to rework how clients interact
with it
-Added code in ContentVerifyJob that uses the hash reader class
BUG=369895
R=rockot@chromium.org
Review URL: https://codereview.chromium.org/280013003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269633 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions/browser/content_verify_job.h')
-rw-r--r-- | extensions/browser/content_verify_job.h | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/extensions/browser/content_verify_job.h b/extensions/browser/content_verify_job.h index ff75b8c..11660f3b 100644 --- a/extensions/browser/content_verify_job.h +++ b/extensions/browser/content_verify_job.h @@ -16,6 +16,10 @@ namespace base { class FilePath; } +namespace crypto { +class SecureHash; +} + namespace extensions { class ContentHashReader; @@ -39,11 +43,7 @@ class ContentVerifyJob : public base::RefCountedThreadSafe<ContentVerifyJob> { typedef base::Callback<void(FailureReason)> FailureCallback; // The |failure_callback| will be called at most once if there was a failure. - // - // IMPORTANT NOTE: this class is still a stub right now - in the future this - // constructor will also be passed information to let it lookup expected - // block hashes for the file being read. - ContentVerifyJob(const std::string& extension_id, + ContentVerifyJob(ContentHashReader* hash_reader, const FailureCallback& failure_callback); // This begins the process of getting expected hashes, so it should be called @@ -80,10 +80,40 @@ class ContentVerifyJob : public base::RefCountedThreadSafe<ContentVerifyJob> { virtual ~ContentVerifyJob(); friend class base::RefCountedThreadSafe<ContentVerifyJob>; + // Called each time we're done adding bytes for the current block, and are + // ready to finish the hash operation for those bytes and make sure it matches + // what was expected for that block. + void FinishBlock(); + + // Dispatches the failure callback with the given reason. void DispatchFailureCallback(FailureReason reason); - // The id of the extension for the file being verified. - std::string extension_id_; + // Called when our ContentHashReader has finished initializing. + void OnHashesReady(bool success); + + // Indicates whether the caller has told us they are done calling BytesRead. + bool done_reading_; + + // Set to true once hash_reader_ has read its expected hashes. + bool hashes_ready_; + + // While we're waiting for the callback from the ContentHashReader, we need + // to queue up bytes any bytes that are read. + std::string queue_; + + // The total bytes we've read. + int64 total_bytes_read_; + + // The index of the block we're currently on. + int current_block_; + + // The hash we're building up for the bytes of |current_block_|. + scoped_ptr<crypto::SecureHash> current_hash_; + + // The number of bytes we've already input into |current_hash_|. + int current_hash_byte_count_; + + scoped_refptr<ContentHashReader> hash_reader_; // Called once if verification fails. FailureCallback failure_callback_; |