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

Side by Side Diff: chrome/browser/prefs/pref_hash_store_impl.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_IMPL_H_
6 #define CHROME_BROWSER_PREFS_PREF_HASH_STORE_IMPL_H_
7
8 #include <set>
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "chrome/browser/prefs/pref_hash_calculator.h"
15 #include "chrome/browser/prefs/pref_hash_store.h"
16
17 class PrefRegistrySimple;
18 class PrefService;
19
20 namespace base {
21 class Value;
22 } // namespace base
23
24 // Implements PrefHashStoreImpl by storing preference hashes in a PrefService.
25 class PrefHashStoreImpl : public PrefHashStore {
gab 2013/12/04 22:22:30 I think it's overkill to have a public interface a
erikwright (departed) 2013/12/05 23:48:00 The current factoring makes it very easy to test h
26 public:
27 // Constructs a PrefHashStoreImpl that calculates hashes using
28 // |hash_calculator| and stores them in |local_state|. Multiple hash stores
29 // can use the same |local_state| with distinct |hash_store_id|s.
30 //
31 // The same |hash_calculator| parameters and |hash_store_id| must be used to
32 // load and validate previously stored hashes in |local_state|.
33 //
34 // |local_state| must have previously been passed to |RegisterPrefs|.
35 PrefHashStoreImpl(const PrefHashCalculator& hash_calculator,
36 PrefService* local_state,
37 const std::string& hash_store_id);
38
39 // Registers required local state preferences.
40 static void RegisterPrefs(PrefRegistrySimple* registry);
41
42 // PrefHashStore implementation.
43 virtual InitializationResult InitializeTrackedValue(
44 const std::string& path, const base::Value* initial_value) OVERRIDE;
45 virtual void OnPrefValueChanged(const std::string& path,
46 const base::Value* new_value) OVERRIDE;
47
48 private:
49 std::set<std::string> tracked_paths_;
50 PrefService* local_state_;
51 std::string hash_store_id_;
52 PrefHashCalculator pref_hash_calculator_;
53
54 DISALLOW_COPY_AND_ASSIGN(PrefHashStoreImpl);
55 };
56
57 #endif // CHROME_BROWSER_PREFS_PREF_HASH_STORE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698