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_PREFERENCE_HASH_STORE_H_ | |
6 #define CHROME_BROWSER_PREFS_PREFERENCE_HASH_STORE_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/memory/scoped_ptr.h" | |
11 | |
12 class PrefHashTracker; | |
13 | |
14 namespace base { | |
15 class Value; | |
16 } // namespace base | |
17 | |
18 // Stores hashes of and verifies preference values. To use, first call | |
19 // |InitializeTrackedValue| with each preference that should be tracked. Then | |
20 // use |CreateTracker| to build an object that can be used to track changes to | |
21 // the configured preferences. | |
22 class PrefHashStore { | |
23 public: | |
24 virtual ~PrefHashStore() {} | |
25 | |
26 enum InitializationResult { | |
27 // The preference value corresponds to its stored hash. | |
28 UNCHANGED, | |
29 // The preference has been cleared since the last hash. | |
30 CLEARED, | |
31 // The preference value corresponds to its stored hash, which was calculated | |
32 // using a legacy hash algorithm. | |
33 MIGRATED, | |
34 // The preference value has been changed since the last hash. | |
35 CHANGED, | |
36 // No stored hash exists for the preference value. | |
37 INITIALIZED | |
gab
2013/11/27 23:43:27
nit: Add trailing comma (no trailing comma usually
| |
38 }; | |
39 | |
40 // Configures tracking of the preference named by |path|. Checks | |
41 // |initial_value| against the existing stored hashes and returns the result. | |
42 // If the result is not UNCHANGED a new hash will be calculated and stored. | |
43 virtual InitializationResult InitializeTrackedValue( | |
gab
2013/11/27 23:43:27
This may eventually do more than just "initialize"
| |
44 const std::string& path, const base::Value* initial_value) = 0; | |
45 | |
46 // Returns a PrefHashTracker that can be used to maintain the hash store as | |
47 // tracked preferences are changed. The returned tracker will ignore changes | |
48 // to preferences not previously initialized by calling | |
49 // InitializeTrackedValue. | |
50 static scoped_ptr<PrefHashTracker> CreateTracker( | |
51 scoped_ptr<PrefHashStore> builder); | |
robertshield
2013/11/28 02:54:26
Since this accepts an instance of the class it is
| |
52 | |
53 private: | |
54 // Returns an implementation specific PrefHashTracker. The PrefHashStore will | |
55 // be destroyed immediately after this method is called. | |
gab
2013/11/27 23:43:27
Lifetime overly complex?
robertshield
2013/11/28 02:54:26
I agree, it's not clear to me how the current inst
| |
56 virtual scoped_ptr<PrefHashTracker> CompleteInitialization() = 0; | |
57 }; | |
58 | |
59 #endif // CHROME_BROWSER_PREFS_PREFERENCE_HASH_STORE_H_ | |
OLD | NEW |