This source file includes following definitions.
- enforce_
- GetAction
- ReportValidationResult
- ReportAction
- ReportSplitPreferenceChangedCount
#include "chrome/browser/prefs/tracked/tracked_preference_helper.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
TrackedPreferenceHelper::TrackedPreferenceHelper(
const std::string& pref_path,
size_t reporting_id,
size_t reporting_ids_count,
PrefHashFilter::EnforcementLevel enforcement_level)
: pref_path_(pref_path),
reporting_id_(reporting_id), reporting_ids_count_(reporting_ids_count),
enforce_(enforcement_level == PrefHashFilter::ENFORCE_ON_LOAD) {
}
TrackedPreferenceHelper::ResetAction TrackedPreferenceHelper::GetAction(
PrefHashStoreTransaction::ValueState value_state) const {
switch (value_state) {
case PrefHashStoreTransaction::UNCHANGED:
return DONT_RESET;
case PrefHashStoreTransaction::CLEARED:
return DONT_RESET;
case PrefHashStoreTransaction::TRUSTED_UNKNOWN_VALUE:
return DONT_RESET;
case PrefHashStoreTransaction::SECURE_LEGACY:
return DONT_RESET;
case PrefHashStoreTransaction::WEAK_LEGACY:
case PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE:
case PrefHashStoreTransaction::CHANGED:
return enforce_ ? DO_RESET : WANTED_RESET;
}
NOTREACHED() << "Unexpected PrefHashStoreTransaction::ValueState: "
<< value_state;
return DONT_RESET;
}
void TrackedPreferenceHelper::ReportValidationResult(
PrefHashStoreTransaction::ValueState value_state) const {
switch (value_state) {
case PrefHashStoreTransaction::UNCHANGED:
UMA_HISTOGRAM_ENUMERATION("Settings.TrackedPreferenceUnchanged",
reporting_id_, reporting_ids_count_);
return;
case PrefHashStoreTransaction::CLEARED:
UMA_HISTOGRAM_ENUMERATION("Settings.TrackedPreferenceCleared",
reporting_id_, reporting_ids_count_);
return;
case PrefHashStoreTransaction::WEAK_LEGACY:
UMA_HISTOGRAM_ENUMERATION("Settings.TrackedPreferenceMigrated",
reporting_id_, reporting_ids_count_);
return;
case PrefHashStoreTransaction::SECURE_LEGACY:
UMA_HISTOGRAM_ENUMERATION(
"Settings.TrackedPreferenceMigratedLegacyDeviceId", reporting_id_,
reporting_ids_count_);
return;
case PrefHashStoreTransaction::CHANGED:
UMA_HISTOGRAM_ENUMERATION("Settings.TrackedPreferenceChanged",
reporting_id_, reporting_ids_count_);
return;
case PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE:
UMA_HISTOGRAM_ENUMERATION("Settings.TrackedPreferenceInitialized",
reporting_id_, reporting_ids_count_);
return;
case PrefHashStoreTransaction::TRUSTED_UNKNOWN_VALUE:
UMA_HISTOGRAM_ENUMERATION("Settings.TrackedPreferenceTrustedInitialized",
reporting_id_, reporting_ids_count_);
return;
}
NOTREACHED() << "Unexpected PrefHashStoreTransaction::ValueState: "
<< value_state;
}
void TrackedPreferenceHelper::ReportAction(ResetAction reset_action) const {
switch (reset_action) {
case DONT_RESET:
break;
case WANTED_RESET:
UMA_HISTOGRAM_ENUMERATION("Settings.TrackedPreferenceWantedReset",
reporting_id_, reporting_ids_count_);
break;
case DO_RESET:
UMA_HISTOGRAM_ENUMERATION("Settings.TrackedPreferenceReset",
reporting_id_, reporting_ids_count_);
break;
}
}
void TrackedPreferenceHelper::ReportSplitPreferenceChangedCount(
size_t count) const {
base::HistogramBase* histogram =
base::LinearHistogram::FactoryGet(
"Settings.TrackedSplitPreferenceChanged." + pref_path_,
1,
100,
101,
base::HistogramBase::kUmaTargetedHistogramFlag);
histogram->Add(count);
}