Index: chrome/browser/prefs/pref_hash_filter.h |
diff --git a/chrome/browser/prefs/pref_hash_filter.h b/chrome/browser/prefs/pref_hash_filter.h |
index baa7811a05aca3fd5ed75039ac5f2f8f626e780a..0232038eb0fc88a7a34c284ff4f0b1430f8789b0 100644 |
--- a/chrome/browser/prefs/pref_hash_filter.h |
+++ b/chrome/browser/prefs/pref_hash_filter.h |
@@ -12,8 +12,7 @@ |
#include "base/compiler_specific.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/prefs/pref_filter.h" |
- |
-class PrefHashStore; |
+#include "chrome/browser/prefs/pref_hash_store.h" |
namespace base { |
class DictionaryValue; |
@@ -25,7 +24,31 @@ class Value; |
// are changed. |
class PrefHashFilter : public PrefFilter { |
public: |
+ enum PrefTrackingStrategy { |
+ // Do not track this preference. Used when tracking is desired on some |
+ // platforms only. |
+ TRACKING_STRATEGY_NONE, |
+ // Atomic preferences are tracked as a whole. |
+ TRACKING_STRATEGY_ATOMIC, |
+ // Split preferences are dictionaries for which each top-level entry is |
+ // tracked independently. |
+ TRACKING_STRATEGY_SPLIT, |
+ }; |
+ |
+ struct TrackedPreference { |
+ const char* name; |
+ PrefTrackingStrategy strategy; |
+ }; |
+ |
+ // Constructs a PrefHashFilter with the default set of tracked preferences. |
explicit PrefHashFilter(scoped_ptr<PrefHashStore> pref_hash_store); |
+ |
+ // Constructs a PrefHashFilter with the specified |tracked_preferences|. Meant |
+ // to be used by tests only. |
+ PrefHashFilter(scoped_ptr<PrefHashStore> pref_hash_store, |
+ const TrackedPreference tracked_preferences[], |
+ size_t tracked_preferences_size); |
+ |
virtual ~PrefHashFilter(); |
// PrefFilter implementation. |
@@ -35,8 +58,38 @@ class PrefHashFilter : public PrefFilter { |
const base::Value* value) OVERRIDE; |
private: |
+ struct TrackedPreferenceMetaData { |
+ TrackedPreferenceMetaData(size_t index_in, PrefTrackingStrategy strategy_in) |
erikwright (departed)
2013/12/17 02:22:50
The fact that it was originally an index is not im
erikwright (departed)
2013/12/17 02:22:50
consider whether the constructor adds anything ove
gab
2013/12/17 18:08:05
Done.
gab
2013/12/17 18:08:05
Done.
|
+ : index(index_in), strategy(strategy_in) {} |
+ |
+ // The index of this tracked preference (important for metrics reporting). |
erikwright (departed)
2013/12/17 02:22:50
once the name changes, these comments are no longe
gab
2013/12/17 18:08:05
Done.
|
+ size_t index; |
+ // The strategy used to track this preference. |
+ PrefTrackingStrategy strategy; |
+ }; |
+ |
+ typedef std::map<std::string, const TrackedPreferenceMetaData> |
+ TrackedPreferencesMap; |
+ |
+ /// Initializes |tracked_paths_| from |tracked_preferences_|. |
+ void InitTrackedPreferences(const TrackedPreference tracked_preferences[], |
+ size_t tracked_preferences_size); |
+ |
+ // Updates the hash(es) in |pref_hash_store_| for |value| at |path| based on |
+ // the tracking |strategy|. |
+ void StoreHashBasedOnStrategy(const std::string& path, |
erikwright (departed)
2013/12/17 02:22:50
BasedOn -> Using
gab
2013/12/17 18:08:05
Done.
|
+ const base::Value* value, |
+ PrefTrackingStrategy strategy); |
+ |
+ // Updates the hash(es) in |pref_hash_store_| for |value| at |path| based on |
+ // the tracking |strategy|. |
erikwright (departed)
2013/12/17 02:22:50
fix comment (Updates -> Checks)
gab
2013/12/17 18:08:05
Done.
|
+ PrefHashStore::ValueState CheckValueBasedOnStrategy( |
+ const std::string& path, |
+ const base::Value* value, |
+ PrefTrackingStrategy strategy); |
+ |
scoped_ptr<PrefHashStore> pref_hash_store_; |
- std::set<std::string> tracked_paths_; |
+ TrackedPreferencesMap tracked_paths_; |
DISALLOW_COPY_AND_ASSIGN(PrefHashFilter); |
}; |