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

Side by Side Diff: extensions/browser/content_hash_reader.h

Issue 288273004: A bunch of remaining parts of extension content verification (Reland) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix browser test Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « extensions/browser/content_hash_fetcher.cc ('k') | extensions/browser/content_hash_reader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef EXTENSIONS_BROWSER_CONTENT_HASH_READER_H_ 5 #ifndef EXTENSIONS_BROWSER_CONTENT_HASH_READER_H_
6 #define EXTENSIONS_BROWSER_CONTENT_HASH_READER_H_ 6 #define EXTENSIONS_BROWSER_CONTENT_HASH_READER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector>
9 10
10 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
11 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
13 #include "base/version.h" 14 #include "base/version.h"
14 #include "extensions/browser/content_verifier_delegate.h" 15 #include "extensions/browser/content_verifier_delegate.h"
15 16
16 namespace extensions { 17 namespace extensions {
17 18
19 class VerifiedContents;
20
18 // This class creates an object that will read expected hashes that may have 21 // This class creates an object that will read expected hashes that may have
19 // been fetched/calculated by the ContentHashFetcher, and vends them out for 22 // been fetched/calculated by the ContentHashFetcher, and vends them out for
20 // use in ContentVerifyJob's. 23 // use in ContentVerifyJob's.
21 class ContentHashReader : public base::RefCountedThreadSafe<ContentHashReader> { 24 class ContentHashReader : public base::RefCountedThreadSafe<ContentHashReader> {
22 public: 25 public:
23 // Create one of these to get expected hashes for the file at |relative_path| 26 // Create one of these to get expected hashes for the file at |relative_path|
24 // within an extension. 27 // within an extension.
25 ContentHashReader(const std::string& extension_id, 28 ContentHashReader(const std::string& extension_id,
26 const base::Version& extension_version, 29 const base::Version& extension_version,
27 const base::FilePath& extension_root, 30 const base::FilePath& extension_root,
(...skipping 15 matching lines...) Expand all
43 int block_size() const; 46 int block_size() const;
44 47
45 // Returns a pointer to the expected sha256 hash value for the block at the 48 // Returns a pointer to the expected sha256 hash value for the block at the
46 // given index. Only valid after calling Init(). 49 // given index. Only valid after calling Init().
47 bool GetHashForBlock(int block_index, const std::string** result) const; 50 bool GetHashForBlock(int block_index, const std::string** result) const;
48 51
49 private: 52 private:
50 friend class base::RefCountedThreadSafe<ContentHashReader>; 53 friend class base::RefCountedThreadSafe<ContentHashReader>;
51 virtual ~ContentHashReader(); 54 virtual ~ContentHashReader();
52 55
53 bool ReadHashes(const base::FilePath& hashes_file); 56 enum InitStatus { NOT_INITIALIZED, SUCCESS, FAILURE };
54 57
55 std::string extension_id_; 58 std::string extension_id_;
56 base::Version extension_version_; 59 base::Version extension_version_;
57 base::FilePath extension_root_; 60 base::FilePath extension_root_;
58 base::FilePath relative_path_; 61 base::FilePath relative_path_;
59 ContentVerifierKey key_; 62 ContentVerifierKey key_;
60 63
64 InitStatus status_;
65
66 // The blocksize used for generating the hashes.
67 int block_size_;
68
69 scoped_ptr<VerifiedContents> verified_contents_;
70
71 std::vector<std::string> hashes_;
72
61 DISALLOW_COPY_AND_ASSIGN(ContentHashReader); 73 DISALLOW_COPY_AND_ASSIGN(ContentHashReader);
62 }; 74 };
63 75
64 } // namespace extensions 76 } // namespace extensions
65 77
66 #endif // EXTENSIONS_BROWSER_CONTENT_HASH_READER_H_ 78 #endif // EXTENSIONS_BROWSER_CONTENT_HASH_READER_H_
OLDNEW
« no previous file with comments | « extensions/browser/content_hash_fetcher.cc ('k') | extensions/browser/content_hash_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698