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

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

Issue 329303007: Fix several problems with the content verification code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ready Created 6 years, 6 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
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 #include <vector>
10 10
(...skipping 22 matching lines...) Expand all
33 33
34 const std::string& extension_id() const { return extension_id_; } 34 const std::string& extension_id() const { return extension_id_; }
35 const base::FilePath& relative_path() const { return relative_path_; } 35 const base::FilePath& relative_path() const { return relative_path_; }
36 36
37 // This should be called to initialize this object (reads the expected hashes 37 // This should be called to initialize this object (reads the expected hashes
38 // from storage, etc.). Must be called on a thread that is allowed to do file 38 // from storage, etc.). Must be called on a thread that is allowed to do file
39 // I/O. Returns a boolean indicating success/failure. On failure, this object 39 // I/O. Returns a boolean indicating success/failure. On failure, this object
40 // should likely be discarded. 40 // should likely be discarded.
41 bool Init(); 41 bool Init();
42 42
43 // These return whether we found valid verified_contents.json /
44 // computed_hashes.json files respectively. Note that both of these can be
45 // true but we still didn't find an entry for |relative_path_| in them.
46 bool have_verified_contents() { return have_verified_contents_; }
47 bool have_computed_hashes() { return have_computed_hashes_; }
48
43 // Return the number of blocks and block size, respectively. Only valid after 49 // Return the number of blocks and block size, respectively. Only valid after
44 // calling Init(). 50 // calling Init().
45 int block_count() const; 51 int block_count() const;
46 int block_size() const; 52 int block_size() const;
47 53
48 // Returns a pointer to the expected sha256 hash value for the block at the 54 // Returns a pointer to the expected sha256 hash value for the block at the
49 // given index. Only valid after calling Init(). 55 // given index. Only valid after calling Init().
50 bool GetHashForBlock(int block_index, const std::string** result) const; 56 bool GetHashForBlock(int block_index, const std::string** result) const;
51 57
52 private: 58 private:
53 friend class base::RefCountedThreadSafe<ContentHashReader>; 59 friend class base::RefCountedThreadSafe<ContentHashReader>;
54 virtual ~ContentHashReader(); 60 virtual ~ContentHashReader();
55 61
56 enum InitStatus { NOT_INITIALIZED, SUCCESS, FAILURE }; 62 enum InitStatus { NOT_INITIALIZED, SUCCESS, FAILURE };
57 63
58 std::string extension_id_; 64 std::string extension_id_;
59 base::Version extension_version_; 65 base::Version extension_version_;
60 base::FilePath extension_root_; 66 base::FilePath extension_root_;
61 base::FilePath relative_path_; 67 base::FilePath relative_path_;
62 ContentVerifierKey key_; 68 ContentVerifierKey key_;
63 69
64 InitStatus status_; 70 InitStatus status_;
65 71
72 bool have_verified_contents_;
73 bool have_computed_hashes_;
74
66 // The blocksize used for generating the hashes. 75 // The blocksize used for generating the hashes.
67 int block_size_; 76 int block_size_;
68 77
69 scoped_ptr<VerifiedContents> verified_contents_; 78 scoped_ptr<VerifiedContents> verified_contents_;
70 79
71 std::vector<std::string> hashes_; 80 std::vector<std::string> hashes_;
72 81
73 DISALLOW_COPY_AND_ASSIGN(ContentHashReader); 82 DISALLOW_COPY_AND_ASSIGN(ContentHashReader);
74 }; 83 };
75 84
76 } // namespace extensions 85 } // namespace extensions
77 86
78 #endif // EXTENSIONS_BROWSER_CONTENT_HASH_READER_H_ 87 #endif // EXTENSIONS_BROWSER_CONTENT_HASH_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698