| OLD | NEW |
| (Empty) |
| 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 | |
| 5 #ifndef CHROME_BROWSER_PREFS_TRACKED_PREF_HASH_STORE_IMPL_H_ | |
| 6 #define CHROME_BROWSER_PREFS_TRACKED_PREF_HASH_STORE_IMPL_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/compiler_specific.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "chrome/browser/prefs/tracked/pref_hash_calculator.h" | |
| 14 #include "chrome/browser/prefs/tracked/pref_hash_store.h" | |
| 15 | |
| 16 class HashStoreContents; | |
| 17 class PrefHashStoreTransaction; | |
| 18 | |
| 19 // Implements PrefHashStoreImpl by storing preference hashes in a | |
| 20 // HashStoreContents. | |
| 21 class PrefHashStoreImpl : public PrefHashStore { | |
| 22 public: | |
| 23 enum StoreVersion { | |
| 24 // No hashes have been stored in this PrefHashStore yet. | |
| 25 VERSION_UNINITIALIZED = 0, | |
| 26 // The hashes in this PrefHashStore were stored before the introduction | |
| 27 // of a version number and should be re-initialized. | |
| 28 VERSION_PRE_MIGRATION = 1, | |
| 29 // The hashes in this PrefHashStore were stored using the latest algorithm. | |
| 30 VERSION_LATEST = 2, | |
| 31 }; | |
| 32 | |
| 33 // Constructs a PrefHashStoreImpl that calculates hashes using | |
| 34 // |seed| and |device_id| and stores them in |contents|. | |
| 35 // | |
| 36 // The same |seed| and |device_id| must be used to load and validate | |
| 37 // previously stored hashes in |contents|. | |
| 38 PrefHashStoreImpl(const std::string& seed, | |
| 39 const std::string& device_id, | |
| 40 bool use_super_mac); | |
| 41 | |
| 42 ~PrefHashStoreImpl() override; | |
| 43 | |
| 44 // Provides an external HashStoreContents implementation to be used. | |
| 45 // BeginTransaction() will ignore |storage| if this is provided. | |
| 46 void set_legacy_hash_store_contents( | |
| 47 scoped_ptr<HashStoreContents> legacy_hash_store_contents); | |
| 48 | |
| 49 // Clears the contents of this PrefHashStore. |IsInitialized()| will return | |
| 50 // false after this call. | |
| 51 void Reset(); | |
| 52 | |
| 53 // PrefHashStore implementation. | |
| 54 scoped_ptr<PrefHashStoreTransaction> BeginTransaction( | |
| 55 scoped_ptr<HashStoreContents> storage) override; | |
| 56 | |
| 57 private: | |
| 58 class PrefHashStoreTransactionImpl; | |
| 59 | |
| 60 const PrefHashCalculator pref_hash_calculator_; | |
| 61 scoped_ptr<HashStoreContents> legacy_hash_store_contents_; | |
| 62 bool use_super_mac_; | |
| 63 | |
| 64 DISALLOW_COPY_AND_ASSIGN(PrefHashStoreImpl); | |
| 65 }; | |
| 66 | |
| 67 #endif // CHROME_BROWSER_PREFS_TRACKED_PREF_HASH_STORE_IMPL_H_ | |
| OLD | NEW |