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 CHROME_BROWSER_PREFS_TRACKED_PREF_HASH_STORE_TRANSACTION_H_ | 5 #ifndef COMPONENTS_USER_PREFS_TRACKED_PREF_HASH_STORE_TRANSACTION_H_ |
6 #define CHROME_BROWSER_PREFS_TRACKED_PREF_HASH_STORE_TRANSACTION_H_ | 6 #define COMPONENTS_USER_PREFS_TRACKED_PREF_HASH_STORE_TRANSACTION_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 namespace base { | 11 namespace base { |
12 class DictionaryValue; | 12 class DictionaryValue; |
13 class Value; | 13 class Value; |
14 } // namespace base | 14 } // namespace base |
15 | 15 |
16 // Used to perform a series of checks/transformations on a PrefHashStore. | 16 // Used to perform a series of checks/transformations on a PrefHashStore. |
(...skipping 18 matching lines...) Expand all Loading... |
35 // tracked value needs to be seeded). | 35 // tracked value needs to be seeded). |
36 TRUSTED_UNKNOWN_VALUE, | 36 TRUSTED_UNKNOWN_VALUE, |
37 // NULL values are inherently trusted. | 37 // NULL values are inherently trusted. |
38 TRUSTED_NULL_VALUE, | 38 TRUSTED_NULL_VALUE, |
39 }; | 39 }; |
40 | 40 |
41 // Finalizes any remaining work after the transaction has been performed. | 41 // Finalizes any remaining work after the transaction has been performed. |
42 virtual ~PrefHashStoreTransaction() {} | 42 virtual ~PrefHashStoreTransaction() {} |
43 | 43 |
44 // Checks |initial_value| against the existing stored value hash. | 44 // Checks |initial_value| against the existing stored value hash. |
45 virtual ValueState CheckValue( | 45 virtual ValueState CheckValue(const std::string& path, |
46 const std::string& path, const base::Value* initial_value) const = 0; | 46 const base::Value* initial_value) const = 0; |
47 | 47 |
48 // Stores a hash of the current |value| of the preference at |path|. | 48 // Stores a hash of the current |value| of the preference at |path|. |
49 virtual void StoreHash(const std::string& path, | 49 virtual void StoreHash(const std::string& path, const base::Value* value) = 0; |
50 const base::Value* value) = 0; | |
51 | 50 |
52 // Checks |initial_value| against the existing stored hashes for the split | 51 // Checks |initial_value| against the existing stored hashes for the split |
53 // preference at |path|. |initial_split_value| being an empty dictionary or | 52 // preference at |path|. |initial_split_value| being an empty dictionary or |
54 // NULL is equivalent. |invalid_keys| must initially be empty. |invalid_keys| | 53 // NULL is equivalent. |invalid_keys| must initially be empty. |invalid_keys| |
55 // will not be modified unless the return value is CHANGED, in which case it | 54 // will not be modified unless the return value is CHANGED, in which case it |
56 // will be filled with the keys that are considered invalid (unknown or | 55 // will be filled with the keys that are considered invalid (unknown or |
57 // changed). | 56 // changed). |
58 virtual ValueState CheckSplitValue( | 57 virtual ValueState CheckSplitValue( |
59 const std::string& path, | 58 const std::string& path, |
60 const base::DictionaryValue* initial_split_value, | 59 const base::DictionaryValue* initial_split_value, |
61 std::vector<std::string>* invalid_keys) const = 0; | 60 std::vector<std::string>* invalid_keys) const = 0; |
62 | 61 |
63 // Stores hashes for the |value| of the split preference at |path|. | 62 // Stores hashes for the |value| of the split preference at |path|. |
64 // |split_value| being an empty dictionary or NULL is equivalent. | 63 // |split_value| being an empty dictionary or NULL is equivalent. |
65 virtual void StoreSplitHash( | 64 virtual void StoreSplitHash(const std::string& path, |
66 const std::string& path, | 65 const base::DictionaryValue* split_value) = 0; |
67 const base::DictionaryValue* split_value) = 0; | |
68 | 66 |
69 // Indicates whether the store contains a hash for the preference at |path|. | 67 // Indicates whether the store contains a hash for the preference at |path|. |
70 virtual bool HasHash(const std::string& path) const = 0; | 68 virtual bool HasHash(const std::string& path) const = 0; |
71 | 69 |
72 // Sets the hash for the preference at |path|. | 70 // Sets the hash for the preference at |path|. |
73 // If |path| is a split preference |hash| must be a DictionaryValue whose | 71 // If |path| is a split preference |hash| must be a DictionaryValue whose |
74 // keys are keys in the split preference and whose values are MACs of the | 72 // keys are keys in the split preference and whose values are MACs of the |
75 // corresponding values in the split preference. | 73 // corresponding values in the split preference. |
76 // If |path| is an atomic preference |hash| must be a StringValue | 74 // If |path| is an atomic preference |hash| must be a StringValue |
77 // containing a MAC of the preference value. | 75 // containing a MAC of the preference value. |
78 // |hash| should originate from a PrefHashStore sharing the same MAC | 76 // |hash| should originate from a PrefHashStore sharing the same MAC |
79 // parameters as this transaction's store. | 77 // parameters as this transaction's store. |
80 // The (in)validity of the super MAC will be maintained by this call. | 78 // The (in)validity of the super MAC will be maintained by this call. |
81 virtual void ImportHash(const std::string& path, const base::Value* hash) = 0; | 79 virtual void ImportHash(const std::string& path, const base::Value* hash) = 0; |
82 | 80 |
83 // Removes the hash stored at |path|. The (in)validity of the super MAC will | 81 // Removes the hash stored at |path|. The (in)validity of the super MAC will |
84 // be maintained by this call. | 82 // be maintained by this call. |
85 virtual void ClearHash(const std::string& path) = 0; | 83 virtual void ClearHash(const std::string& path) = 0; |
86 | 84 |
87 // Indicates whether the super MAC was successfully verified at the beginning | 85 // Indicates whether the super MAC was successfully verified at the beginning |
88 // of this transaction. | 86 // of this transaction. |
89 virtual bool IsSuperMACValid() const = 0; | 87 virtual bool IsSuperMACValid() const = 0; |
90 | 88 |
91 // Forces a valid super MAC to be stored when this transaction terminates. | 89 // Forces a valid super MAC to be stored when this transaction terminates. |
92 // Returns true if this results in a change to the store contents. | 90 // Returns true if this results in a change to the store contents. |
93 virtual bool StampSuperMac() = 0; | 91 virtual bool StampSuperMac() = 0; |
94 }; | 92 }; |
95 | 93 |
96 #endif // CHROME_BROWSER_PREFS_TRACKED_PREF_HASH_STORE_TRANSACTION_H_ | 94 #endif // COMPONENTS_USER_PREFS_TRACKED_PREF_HASH_STORE_TRANSACTION_H_ |
OLD | NEW |