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

Side by Side Diff: services/preferences/tracked/pref_hash_store_transaction.h

Issue 2782803002: Move tracked prefs into services/preferences/tracked. (Closed)
Patch Set: rebase Created 3 years, 8 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
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 COMPONENTS_USER_PREFS_TRACKED_PREF_HASH_STORE_TRANSACTION_H_ 5 #ifndef SERVICES_PREFERENCES_TRACKED_PREF_HASH_STORE_TRANSACTION_H_
6 #define COMPONENTS_USER_PREFS_TRACKED_PREF_HASH_STORE_TRANSACTION_H_ 6 #define SERVICES_PREFERENCES_TRACKED_PREF_HASH_STORE_TRANSACTION_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/strings/string_piece.h" 11 #include "base/strings/string_piece.h"
12 #include "services/preferences/public/interfaces/tracked_preference_validation_d elegate.mojom.h"
12 13
13 namespace base { 14 namespace base {
14 class DictionaryValue; 15 class DictionaryValue;
15 class Value; 16 class Value;
16 } // namespace base 17 } // namespace base
17 18
18 // Used to perform a series of checks/transformations on a PrefHashStore. 19 // Used to perform a series of checks/transformations on a PrefHashStore.
19 class PrefHashStoreTransaction { 20 class PrefHashStoreTransaction {
20 public: 21 public:
21 enum ValueState {
22 // The preference value corresponds to its stored hash.
23 UNCHANGED,
24 // The preference has been cleared since the last hash.
25 CLEARED,
26 // The preference value corresponds to its stored hash, but the hash was
27 // calculated using a deprecated hash algorithm which is just as safe as
28 // the current one.
29 SECURE_LEGACY,
30 // The preference value has been changed since the last hash.
31 CHANGED,
32 // No stored hash exists for the preference value.
33 UNTRUSTED_UNKNOWN_VALUE,
34 // No stored hash exists for the preference value, but the current set of
35 // hashes stored is trusted and thus this value can safely be seeded. This
36 // happens when all hashes are already properly seeded and a newly
37 // tracked value needs to be seeded).
38 TRUSTED_UNKNOWN_VALUE,
39 // NULL values are inherently trusted.
40 TRUSTED_NULL_VALUE,
41 // This transaction's store type is not supported.
42 UNSUPPORTED,
43 };
44
45 // Finalizes any remaining work after the transaction has been performed. 22 // Finalizes any remaining work after the transaction has been performed.
46 virtual ~PrefHashStoreTransaction() {} 23 virtual ~PrefHashStoreTransaction() {}
47 24
48 // Returns the suffix to be appended to UMA histograms for the store contained 25 // Returns the suffix to be appended to UMA histograms for the store contained
49 // in this transaction. 26 // in this transaction.
50 virtual base::StringPiece GetStoreUMASuffix() const = 0; 27 virtual base::StringPiece GetStoreUMASuffix() const = 0;
51 28
52 // Checks |initial_value| against the existing stored value hash. 29 // Checks |initial_value| against the existing stored value hash.
53 virtual ValueState CheckValue(const std::string& path, 30 virtual prefs::mojom::TrackedPreferenceValidationDelegate::ValueState
54 const base::Value* initial_value) const = 0; 31 CheckValue(const std::string& path,
32 const base::Value* initial_value) const = 0;
55 33
56 // Stores a hash of the current |value| of the preference at |path|. 34 // Stores a hash of the current |value| of the preference at |path|.
57 virtual void StoreHash(const std::string& path, const base::Value* value) = 0; 35 virtual void StoreHash(const std::string& path, const base::Value* value) = 0;
58 36
59 // Checks |initial_value| against the existing stored hashes for the split 37 // Checks |initial_value| against the existing stored hashes for the split
60 // preference at |path|. |initial_split_value| being an empty dictionary or 38 // preference at |path|. |initial_split_value| being an empty dictionary or
61 // NULL is equivalent. |invalid_keys| must initially be empty. |invalid_keys| 39 // NULL is equivalent. |invalid_keys| must initially be empty. |invalid_keys|
62 // will not be modified unless the return value is CHANGED, in which case it 40 // will not be modified unless the return value is CHANGED, in which case it
63 // will be filled with the keys that are considered invalid (unknown or 41 // will be filled with the keys that are considered invalid (unknown or
64 // changed). 42 // changed).
65 virtual ValueState CheckSplitValue( 43 virtual prefs::mojom::TrackedPreferenceValidationDelegate::ValueState
66 const std::string& path, 44 CheckSplitValue(const std::string& path,
67 const base::DictionaryValue* initial_split_value, 45 const base::DictionaryValue* initial_split_value,
68 std::vector<std::string>* invalid_keys) const = 0; 46 std::vector<std::string>* invalid_keys) const = 0;
69 47
70 // Stores hashes for the |value| of the split preference at |path|. 48 // Stores hashes for the |value| of the split preference at |path|.
71 // |split_value| being an empty dictionary or NULL is equivalent. 49 // |split_value| being an empty dictionary or NULL is equivalent.
72 virtual void StoreSplitHash(const std::string& path, 50 virtual void StoreSplitHash(const std::string& path,
73 const base::DictionaryValue* split_value) = 0; 51 const base::DictionaryValue* split_value) = 0;
74 52
75 // Indicates whether the store contains a hash for the preference at |path|. 53 // Indicates whether the store contains a hash for the preference at |path|.
76 virtual bool HasHash(const std::string& path) const = 0; 54 virtual bool HasHash(const std::string& path) const = 0;
77 55
78 // Sets the hash for the preference at |path|. 56 // Sets the hash for the preference at |path|.
(...skipping 13 matching lines...) Expand all
92 70
93 // Indicates whether the super MAC was successfully verified at the beginning 71 // Indicates whether the super MAC was successfully verified at the beginning
94 // of this transaction. 72 // of this transaction.
95 virtual bool IsSuperMACValid() const = 0; 73 virtual bool IsSuperMACValid() const = 0;
96 74
97 // Forces a valid super MAC to be stored when this transaction terminates. 75 // Forces a valid super MAC to be stored when this transaction terminates.
98 // Returns true if this results in a change to the store contents. 76 // Returns true if this results in a change to the store contents.
99 virtual bool StampSuperMac() = 0; 77 virtual bool StampSuperMac() = 0;
100 }; 78 };
101 79
102 #endif // COMPONENTS_USER_PREFS_TRACKED_PREF_HASH_STORE_TRANSACTION_H_ 80 #endif // SERVICES_PREFERENCES_TRACKED_PREF_HASH_STORE_TRANSACTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698