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

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

Issue 436563004: Fix for 0-length file problem in content verification (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes from review comments Created 6 years, 4 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 | « no previous file | extensions/browser/computed_hashes.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_COMPUTED_HASHES_H_ 5 #ifndef EXTENSIONS_BROWSER_COMPUTED_HASHES_H_
6 #define EXTENSIONS_BROWSER_COMPUTED_HASHES_H_ 6 #define EXTENSIONS_BROWSER_COMPUTED_HASHES_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/values.h" 12 #include "base/memory/scoped_ptr.h"
13 13
14 namespace base { 14 namespace base {
15 class FilePath; 15 class FilePath;
16 class ListValue;
16 } 17 }
17 18
18 namespace extensions { 19 namespace extensions {
19 20
20 // A pair of classes for serialization of a set of SHA256 block hashes computed 21 // A pair of classes for serialization of a set of SHA256 block hashes computed
21 // over the files inside an extension. 22 // over the files inside an extension.
22 class ComputedHashes { 23 class ComputedHashes {
23 public: 24 public:
24 class Reader { 25 class Reader {
25 public: 26 public:
(...skipping 21 matching lines...) Expand all
47 48
48 // Adds hashes for |relative_path|. Should not be called more than once 49 // Adds hashes for |relative_path|. Should not be called more than once
49 // for a given |relative_path|. 50 // for a given |relative_path|.
50 void AddHashes(const base::FilePath& relative_path, 51 void AddHashes(const base::FilePath& relative_path,
51 int block_size, 52 int block_size,
52 const std::vector<std::string>& hashes); 53 const std::vector<std::string>& hashes);
53 54
54 bool WriteToFile(const base::FilePath& path); 55 bool WriteToFile(const base::FilePath& path);
55 56
56 private: 57 private:
57 // The top-level object that will be serialized as JSON. 58 // Each element of this list contains the path and block hashes for one
58 base::ListValue file_list_; 59 // file.
60 scoped_ptr<base::ListValue> file_list_;
59 }; 61 };
62
63 // Computes the SHA256 hash of each |block_size| chunk in |contents|, placing
64 // the results into |hashes|.
65 static void ComputeHashesForContent(const std::string& contents,
66 size_t block_size,
67 std::vector<std::string>* hashes);
60 }; 68 };
61 69
62 } // namespace extensions 70 } // namespace extensions
63 71
64 #endif // EXTENSIONS_BROWSER_COMPUTED_HASHES_H_ 72 #endif // EXTENSIONS_BROWSER_COMPUTED_HASHES_H_
OLDNEW
« no previous file with comments | « no previous file | extensions/browser/computed_hashes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698