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 CHROME_BROWSER_PREFS_PREF_HASH_STORE_IMPL_H_ | 5 #ifndef CHROME_BROWSER_PREFS_PREF_HASH_STORE_IMPL_H_ |
6 #define CHROME_BROWSER_PREFS_PREF_HASH_STORE_IMPL_H_ | 6 #define CHROME_BROWSER_PREFS_PREF_HASH_STORE_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 // No hashes have been stored in this PrefHashStore yet. | 29 // No hashes have been stored in this PrefHashStore yet. |
30 VERSION_UNINITIALIZED = 0, | 30 VERSION_UNINITIALIZED = 0, |
31 // The hashes in this PrefHashStore were stored before the introduction | 31 // The hashes in this PrefHashStore were stored before the introduction |
32 // of a version number and should be re-initialized. | 32 // of a version number and should be re-initialized. |
33 VERSION_PRE_MIGRATION = 1, | 33 VERSION_PRE_MIGRATION = 1, |
34 // The hashes in this PrefHashStore were stored using the latest algorithm. | 34 // The hashes in this PrefHashStore were stored using the latest algorithm. |
35 VERSION_LATEST = 2, | 35 VERSION_LATEST = 2, |
36 }; | 36 }; |
37 | 37 |
38 // Constructs a PrefHashStoreImpl that calculates hashes using | 38 // Constructs a PrefHashStoreImpl that calculates hashes using |
39 // |seed| and |device_id| and stores them in |contents|. | 39 // |seed| and |device_id| |
40 // | 40 PrefHashStoreImpl(const std::string& seed, const std::string& device_id); |
41 // The same |seed| and |device_id| must be used to load and validate | |
42 // previously stored hashes in |contents|. | |
43 PrefHashStoreImpl(const std::string& seed, | |
44 const std::string& device_id, | |
45 scoped_ptr<HashStoreContents> contents); | |
46 | 41 |
47 virtual ~PrefHashStoreImpl(); | 42 virtual ~PrefHashStoreImpl(); |
48 | 43 |
49 // Clears the contents of this PrefHashStore. |IsInitialized()| will return | 44 // Configures this |PrefHashStoreImpl| to store MACs in and retrieve MACs from |
50 // false after this call. | 45 // |contents|. |
51 void Reset(); | 46 void SetHashStoreContents(scoped_ptr<HashStoreContents> contents); |
52 | 47 |
53 // PrefHashStore implementation. | 48 // PrefHashStore implementation. |
| 49 virtual bool IsInitialized() const OVERRIDE; |
| 50 virtual void Reset() OVERRIDE; |
54 virtual scoped_ptr<PrefHashStoreTransaction> BeginTransaction() OVERRIDE; | 51 virtual scoped_ptr<PrefHashStoreTransaction> BeginTransaction() OVERRIDE; |
55 virtual void CommitPendingWrite() OVERRIDE; | 52 virtual void CommitPendingWrite() OVERRIDE; |
56 | 53 |
57 // Returns the current version of this hash store. | |
58 StoreVersion GetCurrentVersion() const; | |
59 | |
60 private: | 54 private: |
61 class PrefHashStoreTransactionImpl; | 55 class PrefHashStoreTransactionImpl; |
62 | 56 |
63 const PrefHashCalculator pref_hash_calculator_; | 57 const PrefHashCalculator pref_hash_calculator_; |
64 scoped_ptr<HashStoreContents> contents_; | 58 scoped_ptr<HashStoreContents> contents_; |
65 const bool initial_hashes_dictionary_trusted_; | 59 |
| 60 bool initial_hashes_dictionary_trusted_; |
66 | 61 |
67 // True if hashes have been modified since the last call to | 62 // True if hashes have been modified since the last call to |
68 // CommitPendingWriteIfRequired(). | 63 // CommitPendingWriteIfRequired(). |
69 bool has_pending_write_; | 64 bool has_pending_write_; |
70 | 65 |
71 DISALLOW_COPY_AND_ASSIGN(PrefHashStoreImpl); | 66 DISALLOW_COPY_AND_ASSIGN(PrefHashStoreImpl); |
72 }; | 67 }; |
73 | 68 |
74 #endif // CHROME_BROWSER_PREFS_PREF_HASH_STORE_IMPL_H_ | 69 #endif // CHROME_BROWSER_PREFS_PREF_HASH_STORE_IMPL_H_ |
OLD | NEW |