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

Unified Diff: extensions/browser/computed_hashes.h

Issue 289533003: A bunch of remaining parts of extension content verification (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nits 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/extensions/extension_constants.cc ('k') | extensions/browser/computed_hashes.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/computed_hashes.h
diff --git a/extensions/browser/computed_hashes.h b/extensions/browser/computed_hashes.h
new file mode 100644
index 0000000000000000000000000000000000000000..c68175c8d2c832107335eb4d8abd60266b23540f
--- /dev/null
+++ b/extensions/browser/computed_hashes.h
@@ -0,0 +1,64 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef EXTENSIONS_BROWSER_COMPUTED_HASHES_H_
+#define EXTENSIONS_BROWSER_COMPUTED_HASHES_H_
+
+#include <map>
+#include <string>
+#include <vector>
+
+#include "base/values.h"
+
+namespace base {
+class FilePath;
+}
+
+namespace extensions {
+
+// A pair of classes for serialization of a set of SHA256 block hashes computed
+// over the files inside an extension.
+class ComputedHashes {
+ public:
+ class Reader {
+ public:
+ Reader();
+ ~Reader();
+ bool InitFromFile(const base::FilePath& path);
+
+ // The block size and hashes for |relative_path| will be copied into the
+ // out parameters.
+ bool GetHashes(const base::FilePath& relative_path,
+ int* block_size,
+ std::vector<std::string>* hashes);
+
+ private:
+ typedef std::pair<int, std::vector<std::string> > HashInfo;
+
+ // This maps a relative path to a pair of (block size, hashes)
+ std::map<base::FilePath, HashInfo> data_;
+ };
+
+ class Writer {
+ public:
+ Writer();
+ ~Writer();
+
+ // Adds hashes for |relative_path|. Should not be called more than once
+ // for a given |relative_path|.
+ void AddHashes(const base::FilePath& relative_path,
+ int block_size,
+ const std::vector<std::string>& hashes);
+
+ bool WriteToFile(const base::FilePath& path);
+
+ private:
+ // The top-level object that will be serialized as JSON.
+ base::ListValue file_list_;
+ };
+};
+
+} // namespace extensions
+
+#endif // EXTENSIONS_BROWSER_COMPUTED_HASHES_H_
« no previous file with comments | « chrome/common/extensions/extension_constants.cc ('k') | extensions/browser/computed_hashes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698