pref_hash_store_impl.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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_IMPL_H_
  5. #define SERVICES_PREFERENCES_TRACKED_PREF_HASH_STORE_IMPL_H_
  6. #include "base/compiler_specific.h"
  7. #include "services/preferences/tracked/pref_hash_calculator.h"
  8. #include "services/preferences/tracked/pref_hash_store.h"
  9. // Implements PrefHashStoreImpl by storing preference hashes in a
  10. // HashStoreContents.
  11. class PrefHashStoreImpl : public PrefHashStore {
  12. public:
  13. enum StoreVersion {
  14. // No hashes have been stored in this PrefHashStore yet.
  15. VERSION_UNINITIALIZED = 0,
  16. // The hashes in this PrefHashStore were stored before the introduction
  17. // of a version number and should be re-initialized.
  18. VERSION_PRE_MIGRATION = 1,
  19. // The hashes in this PrefHashStore were stored using the latest algorithm.
  20. VERSION_LATEST = 2,
  21. };
  22. // Constructs a PrefHashStoreImpl that calculates hashes using
  23. // |seed| and |legacy_device_id| and stores them in |contents|.
  24. //
  25. // The same |seed| and |legacy_device_id| must be used to load and validate
  26. // previously stored hashes in |contents|.
  27. PrefHashStoreImpl(const std::string& seed,
  28. const std::string& legacy_device_id,
  29. bool use_super_mac);
  30. PrefHashStoreImpl(const PrefHashStoreImpl&) = delete;
  31. PrefHashStoreImpl& operator=(const PrefHashStoreImpl&) = delete;
  32. ~PrefHashStoreImpl() override;
  33. // Clears the contents of this PrefHashStore. |IsInitialized()| will return
  34. // false after this call.
  35. void Reset();
  36. // PrefHashStore implementation.
  37. std::unique_ptr<PrefHashStoreTransaction> BeginTransaction(
  38. HashStoreContents* storage) override;
  39. std::string ComputeMac(const std::string& path,
  40. const base::Value* new_value) override;
  41. std::unique_ptr<base::DictionaryValue> ComputeSplitMacs(
  42. const std::string& path,
  43. const base::DictionaryValue* split_values) override;
  44. private:
  45. class PrefHashStoreTransactionImpl;
  46. const PrefHashCalculator pref_hash_calculator_;
  47. bool use_super_mac_;
  48. };
  49. #endif // SERVICES_PREFERENCES_TRACKED_PREF_HASH_STORE_IMPL_H_