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

Side by Side Diff: services/preferences/tracked/tracked_preference_helper.h

Issue 2782803002: Move tracked prefs into services/preferences/tracked. (Closed)
Patch Set: rebase Created 3 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 COMPONENTS_USER_PREFS_TRACKED_TRACKED_PREFERENCE_HELPER_H_ 5 #ifndef SERVICES_PREFERENCES_TRACKED_TRACKED_PREFERENCE_HELPER_H_
6 #define COMPONENTS_USER_PREFS_TRACKED_TRACKED_PREFERENCE_HELPER_H_ 6 #define SERVICES_PREFERENCES_TRACKED_TRACKED_PREFERENCE_HELPER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "components/user_prefs/tracked/pref_hash_filter.h" 13 #include "services/preferences/tracked/pref_hash_filter.h"
14 #include "components/user_prefs/tracked/pref_hash_store_transaction.h" 14 #include "services/preferences/tracked/pref_hash_store_transaction.h"
15 15
16 // A TrackedPreferenceHelper is a helper class for TrackedPreference which 16 // A TrackedPreferenceHelper is a helper class for TrackedPreference which
17 // handles decision making and reporting for TrackedPreference's 17 // handles decision making and reporting for TrackedPreference's
18 // implementations. 18 // implementations.
19 class TrackedPreferenceHelper { 19 class TrackedPreferenceHelper {
20 public: 20 public:
21 enum ResetAction { 21 enum ResetAction {
22 DONT_RESET, 22 DONT_RESET,
23 // WANTED_RESET is reported when DO_RESET would have been reported but the 23 // WANTED_RESET is reported when DO_RESET would have been reported but the
24 // current |enforcement_level| doesn't allow a reset for the detected state. 24 // current |enforcement_level| doesn't allow a reset for the detected state.
25 WANTED_RESET, 25 WANTED_RESET,
26 DO_RESET, 26 DO_RESET,
27 }; 27 };
28 28
29 TrackedPreferenceHelper(const std::string& pref_path, 29 TrackedPreferenceHelper(
30 size_t reporting_id, 30 const std::string& pref_path,
31 size_t reporting_ids_count, 31 size_t reporting_id,
32 PrefHashFilter::EnforcementLevel enforcement_level, 32 size_t reporting_ids_count,
33 PrefHashFilter::ValueType value_type); 33 prefs::mojom::TrackedPreferenceMetadata::EnforcementLevel
34 enforcement_level,
35 prefs::mojom::TrackedPreferenceMetadata::ValueType value_type);
34 36
35 // Returns a ResetAction stating whether a reset is desired (DO_RESET) or not 37 // Returns a ResetAction stating whether a reset is desired (DO_RESET) or not
36 // (DONT_RESET) based on observing |value_state|. Can also return WANTED_RESET 38 // (DONT_RESET) based on observing |value_state|. Can also return WANTED_RESET
37 // if a reset would have been desired but the current |enforcement_level| 39 // if a reset would have been desired but the current |enforcement_level|
38 // doesn't allow it. 40 // doesn't allow it.
39 ResetAction GetAction(PrefHashStoreTransaction::ValueState value_state) const; 41 ResetAction GetAction(
42 prefs::mojom::TrackedPreferenceValidationDelegate::ValueState value_state)
43 const;
40 44
41 // Returns true if the preference value may contain personal information. 45 // Returns true if the preference value may contain personal information.
42 bool IsPersonal() const; 46 bool IsPersonal() const;
43 47
44 // Reports |value_state| via UMA under |reporting_id_|. 48 // Reports |value_state| via UMA under |reporting_id_|.
45 // |validation_type_suffix| is appended to the reported histogram's name. 49 // |validation_type_suffix| is appended to the reported histogram's name.
46 void ReportValidationResult(PrefHashStoreTransaction::ValueState value_state, 50 void ReportValidationResult(
47 base::StringPiece validation_type_suffix) const; 51 prefs::mojom::TrackedPreferenceValidationDelegate::ValueState value_state,
52 base::StringPiece validation_type_suffix) const;
48 53
49 // Reports |reset_action| via UMA under |reporting_id_|. 54 // Reports |reset_action| via UMA under |reporting_id_|.
50 void ReportAction(ResetAction reset_action) const; 55 void ReportAction(ResetAction reset_action) const;
51 56
52 // Reports, via UMA, the |count| of split preference entries that were 57 // Reports, via UMA, the |count| of split preference entries that were
53 // considered invalid in a CHANGED event. 58 // considered invalid in a CHANGED event.
54 void ReportSplitPreferenceChangedCount(size_t count) const; 59 void ReportSplitPreferenceChangedCount(size_t count) const;
55 60
56 private: 61 private:
57 const std::string pref_path_; 62 const std::string pref_path_;
58 63
59 const size_t reporting_id_; 64 const size_t reporting_id_;
60 const size_t reporting_ids_count_; 65 const size_t reporting_ids_count_;
61 66
62 // Deny setting changes and hash seeding/migration. 67 // Deny setting changes and hash seeding/migration.
63 const bool enforce_; 68 const bool enforce_;
64 69
65 const bool personal_; 70 const bool personal_;
66 71
67 DISALLOW_COPY_AND_ASSIGN(TrackedPreferenceHelper); 72 DISALLOW_COPY_AND_ASSIGN(TrackedPreferenceHelper);
68 }; 73 };
69 74
70 #endif // COMPONENTS_USER_PREFS_TRACKED_TRACKED_PREFERENCE_HELPER_H_ 75 #endif // SERVICES_PREFERENCES_TRACKED_TRACKED_PREFERENCE_HELPER_H_
OLDNEW
« no previous file with comments | « services/preferences/tracked/tracked_preference.h ('k') | services/preferences/tracked/tracked_preference_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698