Index: chrome/browser/prefs/pref_hash_store.h |
diff --git a/chrome/browser/prefs/pref_hash_store.h b/chrome/browser/prefs/pref_hash_store.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d87aa4219c92f10a3f8d7b8a485891c1b39b6aae |
--- /dev/null |
+++ b/chrome/browser/prefs/pref_hash_store.h |
@@ -0,0 +1,59 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_PREFS_PREFERENCE_HASH_STORE_H_ |
+#define CHROME_BROWSER_PREFS_PREFERENCE_HASH_STORE_H_ |
+ |
+#include <string> |
+ |
+#include "base/memory/scoped_ptr.h" |
+ |
+class PrefHashTracker; |
+ |
+namespace base { |
+class Value; |
+} // namespace base |
+ |
+// Stores hashes of and verifies preference values. To use, first call |
+// |InitializeTrackedValue| with each preference that should be tracked. Then |
+// use |CreateTracker| to build an object that can be used to track changes to |
+// the configured preferences. |
+class PrefHashStore { |
+ public: |
+ virtual ~PrefHashStore() {} |
+ |
+ enum InitializationResult { |
+ // The preference value corresponds to its stored hash. |
+ UNCHANGED, |
+ // The preference has been cleared since the last hash. |
+ CLEARED, |
+ // The preference value corresponds to its stored hash, which was calculated |
+ // using a legacy hash algorithm. |
+ MIGRATED, |
+ // The preference value has been changed since the last hash. |
+ CHANGED, |
+ // No stored hash exists for the preference value. |
+ INITIALIZED |
gab
2013/11/27 23:43:27
nit: Add trailing comma (no trailing comma usually
|
+ }; |
+ |
+ // Configures tracking of the preference named by |path|. Checks |
+ // |initial_value| against the existing stored hashes and returns the result. |
+ // If the result is not UNCHANGED a new hash will be calculated and stored. |
+ virtual InitializationResult InitializeTrackedValue( |
gab
2013/11/27 23:43:27
This may eventually do more than just "initialize"
|
+ const std::string& path, const base::Value* initial_value) = 0; |
+ |
+ // Returns a PrefHashTracker that can be used to maintain the hash store as |
+ // tracked preferences are changed. The returned tracker will ignore changes |
+ // to preferences not previously initialized by calling |
+ // InitializeTrackedValue. |
+ static scoped_ptr<PrefHashTracker> CreateTracker( |
+ scoped_ptr<PrefHashStore> builder); |
robertshield
2013/11/28 02:54:26
Since this accepts an instance of the class it is
|
+ |
+ private: |
+ // Returns an implementation specific PrefHashTracker. The PrefHashStore will |
+ // 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
|
+ virtual scoped_ptr<PrefHashTracker> CompleteInitialization() = 0; |
+}; |
+ |
+#endif // CHROME_BROWSER_PREFS_PREFERENCE_HASH_STORE_H_ |