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

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: merge up to r248367 Created 6 years, 10 months 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
« no previous file with comments | « chrome/browser/prefs/pref_hash_store.h ('k') | chrome/browser/prefs/pref_hash_store_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/prefs/scoped_user_pref_update.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 { 19 namespace base {
20 class DictionaryValue;
20 class Value; 21 class Value;
21 } // namespace base 22 }
22 23
23 // Implements PrefHashStoreImpl by storing preference hashes in a PrefService. 24 // Implements PrefHashStoreImpl by storing preference hashes in a PrefService.
24 class PrefHashStoreImpl : public PrefHashStore { 25 class PrefHashStoreImpl : public PrefHashStore {
25 public: 26 public:
26 // Constructs a PrefHashStoreImpl that calculates hashes using 27 // Constructs a PrefHashStoreImpl that calculates hashes using
27 // |seed| and |device_id| and stores them in |local_state|. Multiple hash 28 // |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. 29 // stores can use the same |local_state| with distinct |hash_store_id|s.
29 // 30 //
30 // The same |seed|, |device_id|, and |hash_store_id| must be used to load and 31 // The same |seed|, |device_id|, and |hash_store_id| must be used to load and
31 // validate previously stored hashes in |local_state|. 32 // validate previously stored hashes in |local_state|.
(...skipping 10 matching lines...) Expand all
42 // Clears the contents of this PrefHashStore. |IsInitialized()| will return 43 // Clears the contents of this PrefHashStore. |IsInitialized()| will return
43 // false after this call. 44 // false after this call.
44 void Reset(); 45 void Reset();
45 46
46 // PrefHashStore implementation. 47 // PrefHashStore implementation.
47 virtual bool IsInitialized() const OVERRIDE; 48 virtual bool IsInitialized() const OVERRIDE;
48 virtual ValueState CheckValue(const std::string& path, 49 virtual ValueState CheckValue(const std::string& path,
49 const base::Value* value) const OVERRIDE; 50 const base::Value* value) const OVERRIDE;
50 virtual void StoreHash(const std::string& path, 51 virtual void StoreHash(const std::string& path,
51 const base::Value* value) OVERRIDE; 52 const base::Value* value) OVERRIDE;
53 virtual ValueState CheckSplitValue(
54 const std::string& path,
55 const base::DictionaryValue* initial_split_value,
56 std::vector<std::string>* invalid_keys) const OVERRIDE;
57 virtual void StoreSplitHash(
58 const std::string& path,
59 const base::DictionaryValue* split_value) OVERRIDE;
52 60
53 private: 61 private:
62 // Clears any hashes stored for |path| through |update|.
63 void ClearPath(const std::string& path,
64 DictionaryPrefUpdate* update);
65
66 // Returns true if there are split hashes stored for |path|.
67 bool HasSplitHashesAtPath(const std::string& path) const;
68
69 // Used by StoreHash and StoreSplitHash to store the hash of |new_value| at
70 // |path| under |update|. Allows multiple hashes to be stored under the same
71 // |update|.
72 void StoreHashInternal(const std::string& path,
73 const base::Value* new_value,
74 DictionaryPrefUpdate* update);
75
76 // Updates kHashOfHashesPref to reflect the last changes to the |hashes_dict|.
77 // Must be called after every change to the |hashes_dict|, within the scope of
78 // |update|.
79 void UpdateHashOfHashes(const base::DictionaryValue* hashes_dict,
80 DictionaryPrefUpdate* update);
81
54 // Returns true if the dictionary of hashes stored for |hash_store_id_| is 82 // Returns true if the dictionary of hashes stored for |hash_store_id_| is
55 // trusted (which implies unknown values can be trusted as newly tracked 83 // trusted (which implies unknown values can be trusted as newly tracked
56 // values). 84 // values).
57 bool IsHashDictionaryTrusted() const; 85 bool IsHashDictionaryTrusted() const;
58 86
59 std::string hash_store_id_; 87 std::string hash_store_id_;
60 PrefHashCalculator pref_hash_calculator_; 88 PrefHashCalculator pref_hash_calculator_;
61 PrefService* local_state_; 89 PrefService* local_state_;
62 bool initial_hashes_dictionary_trusted_; 90 bool initial_hashes_dictionary_trusted_;
63 91
64 DISALLOW_COPY_AND_ASSIGN(PrefHashStoreImpl); 92 DISALLOW_COPY_AND_ASSIGN(PrefHashStoreImpl);
65 }; 93 };
66 94
67 #endif // CHROME_BROWSER_PREFS_PREF_HASH_STORE_IMPL_H_ 95 #endif // CHROME_BROWSER_PREFS_PREF_HASH_STORE_IMPL_H_
OLDNEW
« no previous file with comments | « chrome/browser/prefs/pref_hash_store.h ('k') | chrome/browser/prefs/pref_hash_store_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698