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

Side by Side Diff: chrome/browser/prefs/pref_hash_calculator.h

Issue 90563003: Fix a race condition in preference metric reporting. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_PREFS_PREF_HASH_CALCULATOR
6 #define CHROME_BROWSER_PREFS_PREF_HASH_CALCULATOR
7
8 #include <string>
9
10 namespace base {
11 class Value;
12 } // namespace base
13
14 // Calculates and validates preference value hashes.
15 // This class is intentionally copy-constructable.
16 class PrefHashCalculator {
17 public:
18 enum ValidationResult {
19 INVALID,
20 VALID,
21 VALID_LEGACY
22 };
23
24 // Constructs a PrefHashCalculator using |seed|. The same seed must be used in
25 // order to successfully validate generated hashes.
26 explicit PrefHashCalculator(const std::string& seed);
27
28 // Calculates a hash value for the supplied preference path and value. |value|
29 // may be null if the preference has no value.
30 std::string Calculate(const std::string& path, const base::Value* value);
31
32 // Validates the provided preference hash using current and legacy hashing
33 // algorithms.
34 ValidationResult Validate(const std::string& path,
35 const base::Value* value,
36 const std::string& hash);
37
38 private:
39 std::string seed_;
40 };
41
42 #endif // CHROME_BROWSER_PREFS_PREF_HASH_CALCULATOR
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698