OLD | NEW |
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 <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
| 11 #include <memory> |
11 #include <string> | 12 #include <string> |
12 #include <vector> | 13 #include <vector> |
13 | 14 |
14 #include "base/memory/scoped_ptr.h" | |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 class FilePath; | 17 class FilePath; |
18 class ListValue; | 18 class ListValue; |
19 } | 19 } |
20 | 20 |
21 namespace extensions { | 21 namespace extensions { |
22 | 22 |
23 // A pair of classes for serialization of a set of SHA256 block hashes computed | 23 // A pair of classes for serialization of a set of SHA256 block hashes computed |
24 // over the files inside an extension. | 24 // over the files inside an extension. |
(...skipping 27 matching lines...) Expand all Loading... |
52 // for a given |relative_path|. | 52 // for a given |relative_path|. |
53 void AddHashes(const base::FilePath& relative_path, | 53 void AddHashes(const base::FilePath& relative_path, |
54 int block_size, | 54 int block_size, |
55 const std::vector<std::string>& hashes); | 55 const std::vector<std::string>& hashes); |
56 | 56 |
57 bool WriteToFile(const base::FilePath& path); | 57 bool WriteToFile(const base::FilePath& path); |
58 | 58 |
59 private: | 59 private: |
60 // Each element of this list contains the path and block hashes for one | 60 // Each element of this list contains the path and block hashes for one |
61 // file. | 61 // file. |
62 scoped_ptr<base::ListValue> file_list_; | 62 std::unique_ptr<base::ListValue> file_list_; |
63 }; | 63 }; |
64 | 64 |
65 // Computes the SHA256 hash of each |block_size| chunk in |contents|, placing | 65 // Computes the SHA256 hash of each |block_size| chunk in |contents|, placing |
66 // the results into |hashes|. | 66 // the results into |hashes|. |
67 static void ComputeHashesForContent(const std::string& contents, | 67 static void ComputeHashesForContent(const std::string& contents, |
68 size_t block_size, | 68 size_t block_size, |
69 std::vector<std::string>* hashes); | 69 std::vector<std::string>* hashes); |
70 }; | 70 }; |
71 | 71 |
72 } // namespace extensions | 72 } // namespace extensions |
73 | 73 |
74 #endif // EXTENSIONS_BROWSER_COMPUTED_HASHES_H_ | 74 #endif // EXTENSIONS_BROWSER_COMPUTED_HASHES_H_ |
OLD | NEW |