Index: services/preferences/tracked/pref_hash_store_impl.cc |
diff --git a/components/user_prefs/tracked/pref_hash_store_impl.cc b/services/preferences/tracked/pref_hash_store_impl.cc |
similarity index 89% |
rename from components/user_prefs/tracked/pref_hash_store_impl.cc |
rename to services/preferences/tracked/pref_hash_store_impl.cc |
index 6487822fdb1df7671f5971a5c90de4a9bbb56027..522b013c5bc1cadaecd1a17ec470ff6e35207267 100644 |
--- a/components/user_prefs/tracked/pref_hash_store_impl.cc |
+++ b/services/preferences/tracked/pref_hash_store_impl.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "components/user_prefs/tracked/pref_hash_store_impl.h" |
+#include "services/preferences/tracked/pref_hash_store_impl.h" |
#include <stddef.h> |
#include <utility> |
@@ -10,11 +10,14 @@ |
#include "base/logging.h" |
#include "base/macros.h" |
#include "base/metrics/histogram_macros.h" |
-#include "components/user_prefs/tracked/device_id.h" |
-#include "components/user_prefs/tracked/hash_store_contents.h" |
+#include "services/preferences/tracked/device_id.h" |
+#include "services/preferences/tracked/hash_store_contents.h" |
namespace { |
+using ValueState = |
+ prefs::mojom::TrackedPreferenceValidationDelegate::ValueState; |
+ |
// Returns a deterministic ID for this machine. |
std::string GenerateDeviceId() { |
static std::string cached_device_id; |
@@ -82,8 +85,7 @@ PrefHashStoreImpl::PrefHashStoreImpl(const std::string& seed, |
: pref_hash_calculator_(seed, GenerateDeviceId(), legacy_device_id), |
use_super_mac_(use_super_mac) {} |
-PrefHashStoreImpl::~PrefHashStoreImpl() { |
-} |
+PrefHashStoreImpl::~PrefHashStoreImpl() {} |
std::unique_ptr<PrefHashStoreTransaction> PrefHashStoreImpl::BeginTransaction( |
HashStoreContents* storage) { |
@@ -154,8 +156,7 @@ PrefHashStoreImpl::PrefHashStoreTransactionImpl::GetStoreUMASuffix() const { |
return contents_->GetUMASuffix(); |
} |
-PrefHashStoreTransaction::ValueState |
-PrefHashStoreImpl::PrefHashStoreTransactionImpl::CheckValue( |
+ValueState PrefHashStoreImpl::PrefHashStoreTransactionImpl::CheckValue( |
const std::string& path, |
const base::Value* initial_value) const { |
std::string last_hash; |
@@ -165,26 +166,26 @@ PrefHashStoreImpl::PrefHashStoreTransactionImpl::CheckValue( |
// In the absence of a hash for this pref, always trust a NULL value, but |
// only trust an existing value if the initial hashes dictionary is trusted. |
if (!initial_value) |
- return TRUSTED_NULL_VALUE; |
+ return ValueState::TRUSTED_NULL_VALUE; |
else if (super_mac_valid_) |
- return TRUSTED_UNKNOWN_VALUE; |
+ return ValueState::TRUSTED_UNKNOWN_VALUE; |
else |
- return UNTRUSTED_UNKNOWN_VALUE; |
+ return ValueState::UNTRUSTED_UNKNOWN_VALUE; |
} |
PrefHashCalculator::ValidationResult validation_result = |
outer_->pref_hash_calculator_.Validate(path, initial_value, last_hash); |
switch (validation_result) { |
case PrefHashCalculator::VALID: |
- return UNCHANGED; |
+ return ValueState::UNCHANGED; |
case PrefHashCalculator::VALID_SECURE_LEGACY: |
- return SECURE_LEGACY; |
+ return ValueState::SECURE_LEGACY; |
case PrefHashCalculator::INVALID: |
- return initial_value ? CHANGED : CLEARED; |
+ return initial_value ? ValueState::CHANGED : ValueState::CLEARED; |
} |
NOTREACHED() << "Unexpected PrefHashCalculator::ValidationResult: " |
<< validation_result; |
- return UNTRUSTED_UNKNOWN_VALUE; |
+ return ValueState::UNTRUSTED_UNKNOWN_VALUE; |
} |
void PrefHashStoreImpl::PrefHashStoreTransactionImpl::StoreHash( |
@@ -195,8 +196,7 @@ void PrefHashStoreImpl::PrefHashStoreTransactionImpl::StoreHash( |
super_mac_dirty_ = true; |
} |
-PrefHashStoreTransaction::ValueState |
-PrefHashStoreImpl::PrefHashStoreTransactionImpl::CheckSplitValue( |
+ValueState PrefHashStoreImpl::PrefHashStoreTransactionImpl::CheckSplitValue( |
const std::string& path, |
const base::DictionaryValue* initial_split_value, |
std::vector<std::string>* invalid_keys) const { |
@@ -209,10 +209,11 @@ PrefHashStoreImpl::PrefHashStoreTransactionImpl::CheckSplitValue( |
// the entire dictionary (or some other special beacon) to differentiate these |
// two cases which are really the same for dictionaries. |
if (!initial_split_value || initial_split_value->empty()) |
- return has_hashes ? CLEARED : UNCHANGED; |
+ return has_hashes ? ValueState::CLEARED : ValueState::UNCHANGED; |
if (!has_hashes) |
- return super_mac_valid_ ? TRUSTED_UNKNOWN_VALUE : UNTRUSTED_UNKNOWN_VALUE; |
+ return super_mac_valid_ ? ValueState::TRUSTED_UNKNOWN_VALUE |
+ : ValueState::UNTRUSTED_UNKNOWN_VALUE; |
bool has_secure_legacy_id_hashes = false; |
std::string keyed_path(path); |
@@ -232,7 +233,7 @@ PrefHashStoreImpl::PrefHashStoreTransactionImpl::CheckSplitValue( |
entry->second)) { |
case PrefHashCalculator::VALID: |
break; |
- case SECURE_LEGACY: |
+ case PrefHashCalculator::VALID_SECURE_LEGACY: |
// Secure legacy device IDs based hashes are still accepted, but we |
// should make sure to notify the caller for them to update the legacy |
// hashes. |
@@ -256,8 +257,9 @@ PrefHashStoreImpl::PrefHashStoreTransactionImpl::CheckSplitValue( |
} |
return invalid_keys->empty() |
- ? (has_secure_legacy_id_hashes ? SECURE_LEGACY : UNCHANGED) |
- : CHANGED; |
+ ? (has_secure_legacy_id_hashes ? ValueState::SECURE_LEGACY |
+ : ValueState::UNCHANGED) |
+ : ValueState::CHANGED; |
} |
void PrefHashStoreImpl::PrefHashStoreTransactionImpl::StoreSplitHash( |