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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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_PREF_HASH_STORE_H_
6 #define CHROME_BROWSER_PREFS_PREF_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 // call |OnPrefValueChanged| to update the hash store when preference values
21 // change.
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
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(
44 const std::string& path, const base::Value* initial_value) = 0;
45
46 // Receives notification of preference value changes.
47 virtual void OnPrefValueChanged(const std::string& path,
48 const base::Value* new_value) = 0;
49 };
50
51 #endif // CHROME_BROWSER_PREFS_PREF_HASH_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698