Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Side by Side Diff: chrome/browser/prefs/pref_hash_store.h

Issue 114223002: Multi-strategy based tracking. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: UNKNOWN_VALUE when going from atomic to split hash for an existing tracked pref Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_H_ 5 #ifndef CHROME_BROWSER_PREFS_PREF_HASH_STORE_H_
6 #define CHROME_BROWSER_PREFS_PREF_HASH_STORE_H_ 6 #define CHROME_BROWSER_PREFS_PREF_HASH_STORE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector>
9 10
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 12
12 class PrefHashTracker;
13
14 namespace base { 13 namespace base {
14 class DictionaryValue;
15 class Value; 15 class Value;
16 } // namespace base 16 } // namespace base
17 17
18 // Stores hashes of and verifies preference values. To use, first call 18 // Stores hashes of and verifies preference values. To use, first call
19 // |InitializeTrackedValue| with each preference that should be tracked. Then 19 // |InitializeTrackedValue| with each preference that should be tracked. Then
20 // call |OnPrefValueChanged| to update the hash store when preference values 20 // call |OnPrefValueChanged| to update the hash store when preference values
21 // change. 21 // change.
22 class PrefHashStore { 22 class PrefHashStore {
23 public: 23 public:
24 virtual ~PrefHashStore() {} 24 virtual ~PrefHashStore() {}
25 25
26 enum ValueState { 26 enum ValueState {
27 // The preference value corresponds to its stored hash. 27 // The preference value corresponds to its stored hash.
28 UNCHANGED, 28 UNCHANGED,
29 // The preference has been cleared since the last hash. 29 // The preference has been cleared since the last hash.
30 CLEARED, 30 CLEARED,
31 // The preference value corresponds to its stored hash, which was calculated 31 // The preference value corresponds to its stored hash, which was calculated
32 // using a legacy hash algorithm. 32 // using a legacy hash algorithm.
33 MIGRATED, 33 MIGRATED,
34 // The preference value has been changed since the last hash. 34 // The preference value has been changed since the last hash.
35 CHANGED, 35 CHANGED,
36 // No stored hash exists for the preference value. 36 // No stored hash exists for the preference value.
37 UNKNOWN_VALUE, 37 UNKNOWN_VALUE,
38 }; 38 };
39 39
40 // Checks |initial_value| against the existing stored value hash. 40 // Checks |initial_value| against the existing stored value hash.
41 virtual ValueState CheckValue( 41 virtual ValueState CheckValue(
42 const std::string& path, const base::Value* initial_value) const = 0; 42 const std::string& path, const base::Value* initial_value) const = 0;
43 43
44 // Stores a hash of the current value of the preference at |path|. 44 // Stores a hash of the current |value| of the preference at |path|.
45 virtual void StoreHash(const std::string& path, 45 virtual void StoreHash(const std::string& path,
46 const base::Value* value) = 0; 46 const base::Value* value) = 0;
47
48 // Checks |initial_value| against the existing stored hashes for the split
49 // preference at |path|. |initial_split_value| being an empty dictionary or
50 // NULL is treated as equivalent. |invalid_keys| must initially be empty.
51 // If the return value is CHANGED: |invalid_keys| will be filled with the keys
52 // that are considered invalid (unknown or changed). |invalid_keys| will not
53 // be modified in all other cases.
erikwright (departed) 2013/12/19 15:21:28 'in all other cases' -> 'otherwise' or 'any other
gab 2013/12/20 18:37:06 Done.
54 virtual ValueState CheckSplitValue(
55 const std::string& path,
56 const base::DictionaryValue* initial_split_value,
57 std::vector<std::string>* invalid_keys) const = 0;
58
59 // Stores hashes for the |value| of the split preference at |path|.
erikwright (departed) 2013/12/19 15:21:28 Are empty/null equivalent here too?
gab 2013/12/20 18:37:06 Yes, clarified.
60 virtual void StoreSplitHash(
61 const std::string& path,
62 const base::DictionaryValue* split_value) = 0;
47 }; 63 };
48 64
49 #endif // CHROME_BROWSER_PREFS_PREF_HASH_STORE_H_ 65 #endif // CHROME_BROWSER_PREFS_PREF_HASH_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698