pref_hash_store.h 2.0 KB

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