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

Unified Diff: chrome/browser/prefs/pref_hash_store.h

Issue 90563003: Fix a race condition in preference metric reporting. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments, tidying. 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 side-by-side diff with in-line comments
Download patch
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..449056ae6407005668c975681fe4067a84e366e0
--- /dev/null
+++ b/chrome/browser/prefs/pref_hash_store.h
@@ -0,0 +1,51 @@
+// 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_PREF_HASH_STORE_H_
+#define CHROME_BROWSER_PREFS_PREF_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
+// call |OnPrefValueChanged| to update the hash store when preference values
+// change.
+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
+ };
+
+ // 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(
+ const std::string& path, const base::Value* initial_value) = 0;
+
+ // Receives notification of preference value changes.
+ virtual void OnPrefValueChanged(const std::string& path,
+ const base::Value* new_value) = 0;
+};
+
+#endif // CHROME_BROWSER_PREFS_PREF_HASH_STORE_H_

Powered by Google App Engine
This is Rietveld 408576698