OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_PREFS_TRACKED_PREF_HASH_STORE_H_ | 5 #ifndef COMPONENTS_PREFS_TRACKED_PREF_HASH_STORE_H_ |
6 #define COMPONENTS_PREFS_TRACKED_PREF_HASH_STORE_H_ | 6 #define COMPONENTS_PREFS_TRACKED_PREF_HASH_STORE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
| 9 #include <string> |
| 10 |
| 11 #include "base/values.h" |
| 12 #include "components/user_prefs/tracked/pref_hash_store_transaction.h" |
9 | 13 |
10 class HashStoreContents; | 14 class HashStoreContents; |
11 class PrefHashStoreTransaction; | |
12 | 15 |
13 // Holds the configuration and implementation used to calculate and verify | 16 // Holds the configuration and implementation used to calculate and verify |
14 // preference MACs. | 17 // preference MACs. |
15 // TODO(gab): Rename this class as it is no longer a store. | 18 // TODO(gab): Rename this class as it is no longer a store. |
16 class PrefHashStore { | 19 class PrefHashStore { |
17 public: | 20 public: |
18 virtual ~PrefHashStore() {} | 21 virtual ~PrefHashStore() {} |
19 | 22 |
20 // Returns a PrefHashStoreTransaction which can be used to perform a series | 23 // Returns a PrefHashStoreTransaction which can be used to perform a series |
21 // of operations on the hash store. |storage| MAY be used as the backing store | 24 // of operations on the hash store. |storage| MAY be used as the backing store |
22 // depending on the implementation. Therefore the HashStoreContents used for | 25 // depending on the implementation. Therefore the HashStoreContents used for |
23 // related transactions should correspond to the same underlying data store. | 26 // related transactions should correspond to the same underlying data store. |
24 // |storage| must outlive the returned transaction. | 27 // |storage| must outlive the returned transaction. |
25 virtual std::unique_ptr<PrefHashStoreTransaction> BeginTransaction( | 28 virtual std::unique_ptr<PrefHashStoreTransaction> BeginTransaction( |
26 HashStoreContents* storage) = 0; | 29 HashStoreContents* storage) = 0; |
| 30 |
| 31 // Computes the MAC to be associated with |path| and |value| in this store. |
| 32 // PrefHashStoreTransaction typically uses this internally but it's also |
| 33 // exposed for users that want to compute MACs ahead of time for asynchronous |
| 34 // operations. |
| 35 virtual std::string ComputeMac(const std::string& path, |
| 36 const base::Value* value) = 0; |
| 37 |
| 38 // Computes the MAC to be associated with |path| and |split_values| in this |
| 39 // store. PrefHashStoreTransaction typically uses this internally but it's |
| 40 // also exposed for users that want to compute MACs ahead of time for |
| 41 // asynchronous operations. |
| 42 virtual std::unique_ptr<base::DictionaryValue> ComputeSplitMacs( |
| 43 const std::string& path, |
| 44 const base::DictionaryValue* split_values) = 0; |
27 }; | 45 }; |
28 | 46 |
29 #endif // COMPONENTS_PREFS_TRACKED_PREF_HASH_STORE_H_ | 47 #endif // COMPONENTS_PREFS_TRACKED_PREF_HASH_STORE_H_ |
OLD | NEW |