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

Unified Diff: chrome/browser/prefs/tracked_preference_helper.h

Issue 114223002: Multi-strategy based tracking. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use base::ScopedPtrHashMap Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/prefs/tracked_preference_helper.h
diff --git a/chrome/browser/prefs/tracked_preference_helper.h b/chrome/browser/prefs/tracked_preference_helper.h
new file mode 100644
index 0000000000000000000000000000000000000000..55de99d7e6a331ee1f012bf7655932cd897cef7c
--- /dev/null
+++ b/chrome/browser/prefs/tracked_preference_helper.h
@@ -0,0 +1,74 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_PREFS_TRACKED_PREFERENCE_HELPER_H_
+#define CHROME_BROWSER_PREFS_TRACKED_PREFERENCE_HELPER_H_
+
+#include "base/macros.h"
+#include "chrome/browser/prefs/pref_hash_store.h"
+
+// A TrackedPreferenceHelper is a helper class for TrackedPreference which
+// handles decision making and reporting for TrackedPreference's
+// implementations.
+class TrackedPreferenceHelper {
+ public:
+ // Enforcement levels are defined in order of intensity; the next level always
+ // implies the previous one and more.
+ enum EnforcementLevel {
erikwright (departed) 2014/01/17 20:23:01 I would probably put this in its own file. It does
gab 2014/01/17 21:32:01 Put it back in PrefHashFilter.
+ NO_ENFORCEMENT,
+ ENFORCE,
+ ENFORCE_NO_SEEDING,
+ ENFORCE_NO_SEEDING_NO_MIGRATION,
+ // ENFORCE_ALL must always remain last; it is meant to be used when the
+ // desired level is underdetermined and the caller wants to enforce the
+ // strongest level to be safe.
+ ENFORCE_ALL
+ };
+
+ enum ResetAction {
+ DONT_RESET,
+ // WANTED_RESET is reported when DO_RESET would have been reported but the
+ // current |enforcement_level| doesn't allow a reset for the detected state.
+ WANTED_RESET,
+ DO_RESET,
+ };
+
+ TrackedPreferenceHelper(const std::string& pref_path,
+ size_t reporting_id,
+ size_t reporting_ids_count,
+ EnforcementLevel enforcement_level);
+
+ // Returns a ResetAction stating whether a reset is desired (DO_RESET) based
+ // on observing |value_state| or not (DONT_RESET). |allow_changes_|,
+ // |allow_seeding_|, and |allow_migration_| make the decision softer in favor
+ // of WANTED_RESET over DO_RESET in various scenarios.
+ ResetAction GetAction(PrefHashStore::ValueState value_state) const;
+
+ // Reports |value_state| via UMA under |reporting_id_|.
+ void ReportValidationResult(PrefHashStore::ValueState value_state) const;
+
+ // Reports |reset_action| via UMA under |reporting_id_|.
+ void ReportAction(ResetAction reset_action) const;
+
+ // Reports, via UMA, the |count| of split preference entries that were
+ // considered invalid in a CHANGED event.
+ void ReportSplitPreferenceChangedCount(size_t count) const;
+
+ private:
+ const std::string pref_path_;
+
+ const size_t reporting_id_;
+ const size_t reporting_ids_count_;
+
+ // Allow setting changes.
+ const bool allow_changes_;
+ // Allow seeding unknown values for atomic preferences.
+ const bool allow_seeding_;
+ // Allow migration of values validated by the old MAC algorithm.
+ const bool allow_migration_;
+
+ DISALLOW_COPY_AND_ASSIGN(TrackedPreferenceHelper);
+};
+
+#endif // CHROME_BROWSER_PREFS_TRACKED_PREFERENCE_HELPER_H_

Powered by Google App Engine
This is Rietveld 408576698