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

Side by Side Diff: chrome/browser/prefs/pref_hash_store_impl.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_IMPL_H_ 5 #ifndef CHROME_BROWSER_PREFS_PREF_HASH_STORE_IMPL_H_
6 #define CHROME_BROWSER_PREFS_PREF_HASH_STORE_IMPL_H_ 6 #define CHROME_BROWSER_PREFS_PREF_HASH_STORE_IMPL_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/prefs/pref_hash_calculator.h" 13 #include "chrome/browser/prefs/pref_hash_calculator.h"
14 #include "chrome/browser/prefs/pref_hash_store.h" 14 #include "chrome/browser/prefs/pref_hash_store.h"
15 15
16 class PrefRegistrySimple; 16 class PrefRegistrySimple;
17 class PrefService; 17 class PrefService;
18 18
19 namespace base {
20 class Value;
21 } // namespace base
22
23 // Implements PrefHashStoreImpl by storing preference hashes in a PrefService. 19 // Implements PrefHashStoreImpl by storing preference hashes in a PrefService.
24 class PrefHashStoreImpl : public PrefHashStore { 20 class PrefHashStoreImpl : public PrefHashStore {
25 public: 21 public:
26 // Constructs a PrefHashStoreImpl that calculates hashes using 22 // Constructs a PrefHashStoreImpl that calculates hashes using
27 // |seed| and |device_id| and stores them in |local_state|. Multiple hash 23 // |seed| and |device_id| and stores them in |local_state|. Multiple hash
28 // stores can use the same |local_state| with distinct |hash_store_id|s. 24 // stores can use the same |local_state| with distinct |hash_store_id|s.
29 // 25 //
30 // The same |seed|, |device_id|, and |hash_store_id| must be used to load and 26 // The same |seed|, |device_id|, and |hash_store_id| must be used to load and
31 // validate previously stored hashes in |local_state|. 27 // validate previously stored hashes in |local_state|.
32 // 28 //
33 // |local_state| must have previously been passed to |RegisterPrefs|. 29 // |local_state| must have previously been passed to |RegisterPrefs|.
34 PrefHashStoreImpl(const std::string& hash_store_id, 30 PrefHashStoreImpl(const std::string& hash_store_id,
35 const std::string& seed, 31 const std::string& seed,
36 const std::string& device_id, 32 const std::string& device_id,
37 PrefService* local_state); 33 PrefService* local_state);
38 34
39 // Registers required local state preferences. 35 // Registers required local state preferences.
40 static void RegisterPrefs(PrefRegistrySimple* registry); 36 static void RegisterPrefs(PrefRegistrySimple* registry);
41 37
42 // PrefHashStore implementation. 38 // PrefHashStore implementation.
43 virtual ValueState CheckValue(const std::string& path, 39 virtual ValueState CheckValue(const std::string& path,
44 const base::Value* value) const OVERRIDE; 40 const base::Value* value) const OVERRIDE;
45 virtual void StoreHash(const std::string& path, 41 virtual void StoreHash(const std::string& path,
46 const base::Value* value) OVERRIDE; 42 const base::Value* value) OVERRIDE;
43 virtual ValueState CheckSplitValue(
44 const std::string& path,
45 const base::DictionaryValue* initial_split_value,
46 std::vector<std::string>* invalid_keys) const OVERRIDE;
47 virtual void StoreSplitHash(
48 const std::string& path,
49 const base::DictionaryValue* split_value) OVERRIDE;
47 50
48 private: 51 private:
52 // Clears any hashes stored for |path|.
53 void ClearPath(const std::string& path);
54
55 // Returns true if there are split hashes stored for |path|.
56 bool HasSplitHashesAtPath(const std::string& path) const;
57
49 std::string hash_store_id_; 58 std::string hash_store_id_;
50 PrefHashCalculator pref_hash_calculator_; 59 PrefHashCalculator pref_hash_calculator_;
51 PrefService* local_state_; 60 PrefService* local_state_;
52 61
53 DISALLOW_COPY_AND_ASSIGN(PrefHashStoreImpl); 62 DISALLOW_COPY_AND_ASSIGN(PrefHashStoreImpl);
54 }; 63 };
55 64
56 #endif // CHROME_BROWSER_PREFS_PREF_HASH_STORE_IMPL_H_ 65 #endif // CHROME_BROWSER_PREFS_PREF_HASH_STORE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698