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

Unified Diff: components/user_prefs/tracked/mock_validation_delegate.cc

Issue 2719833002: Convert TrackedPreferenceValidationDelegate into a mojo interface. (Closed)
Patch Set: Created 3 years, 9 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: components/user_prefs/tracked/mock_validation_delegate.cc
diff --git a/components/user_prefs/tracked/mock_validation_delegate.cc b/components/user_prefs/tracked/mock_validation_delegate.cc
index e0e88283c48a3458bcef224f562278665c3dbb02..4362f9911a46324c7805b5cbd079209a7edbe6cc 100644
--- a/components/user_prefs/tracked/mock_validation_delegate.cc
+++ b/components/user_prefs/tracked/mock_validation_delegate.cc
@@ -4,13 +4,11 @@
#include "components/user_prefs/tracked/mock_validation_delegate.h"
-MockValidationDelegate::MockValidationDelegate() {
-}
+MockValidationDelegateRecord::MockValidationDelegateRecord() = default;
-MockValidationDelegate::~MockValidationDelegate() {
-}
+MockValidationDelegateRecord::~MockValidationDelegateRecord() = default;
-size_t MockValidationDelegate::CountValidationsOfState(
+size_t MockValidationDelegateRecord::CountValidationsOfState(
PrefHashStoreTransaction::ValueState value_state) const {
size_t count = 0;
for (size_t i = 0; i < validations_.size(); ++i) {
@@ -20,7 +18,7 @@ size_t MockValidationDelegate::CountValidationsOfState(
return count;
}
-size_t MockValidationDelegate::CountExternalValidationsOfState(
+size_t MockValidationDelegateRecord::CountExternalValidationsOfState(
PrefHashStoreTransaction::ValueState value_state) const {
size_t count = 0;
for (size_t i = 0; i < validations_.size(); ++i) {
@@ -30,8 +28,9 @@ size_t MockValidationDelegate::CountExternalValidationsOfState(
return count;
}
-const MockValidationDelegate::ValidationEvent*
-MockValidationDelegate::GetEventForPath(const std::string& pref_path) const {
+const MockValidationDelegateRecord::ValidationEvent*
+MockValidationDelegateRecord::GetEventForPath(
+ const std::string& pref_path) const {
for (size_t i = 0; i < validations_.size(); ++i) {
if (validations_[i].pref_path == pref_path)
return &validations_[i];
@@ -39,35 +38,42 @@ MockValidationDelegate::GetEventForPath(const std::string& pref_path) const {
return NULL;
}
-void MockValidationDelegate::OnAtomicPreferenceValidation(
+void MockValidationDelegateRecord::RecordValidation(
const std::string& pref_path,
- const base::Value* value,
PrefHashStoreTransaction::ValueState value_state,
PrefHashStoreTransaction::ValueState external_validation_value_state,
- bool is_personal) {
- RecordValidation(pref_path, value_state, external_validation_value_state,
- is_personal, PrefHashFilter::TRACKING_STRATEGY_ATOMIC);
+ bool is_personal,
+ PrefHashFilter::PrefTrackingStrategy strategy) {
+ validations_.push_back(ValidationEvent(pref_path, value_state,
+ external_validation_value_state,
+ is_personal, strategy));
}
-void MockValidationDelegate::OnSplitPreferenceValidation(
+MockValidationDelegate::MockValidationDelegate(
+ scoped_refptr<MockValidationDelegateRecord> record)
+ : record_(std::move(record)) {}
+
+MockValidationDelegate::~MockValidationDelegate() = default;
+
+void MockValidationDelegate::OnAtomicPreferenceValidation(
const std::string& pref_path,
- const base::DictionaryValue* dict_value,
- const std::vector<std::string>& invalid_keys,
- const std::vector<std::string>& external_validation_invalid_keys,
+ std::unique_ptr<base::Value> value,
PrefHashStoreTransaction::ValueState value_state,
PrefHashStoreTransaction::ValueState external_validation_value_state,
bool is_personal) {
- RecordValidation(pref_path, value_state, external_validation_value_state,
- is_personal, PrefHashFilter::TRACKING_STRATEGY_SPLIT);
+ record_->RecordValidation(pref_path, value_state,
+ external_validation_value_state, is_personal,
+ PrefHashFilter::TRACKING_STRATEGY_ATOMIC);
}
-void MockValidationDelegate::RecordValidation(
+void MockValidationDelegate::OnSplitPreferenceValidation(
const std::string& pref_path,
+ const std::vector<std::string>& invalid_keys,
+ const std::vector<std::string>& external_validation_invalid_keys,
PrefHashStoreTransaction::ValueState value_state,
PrefHashStoreTransaction::ValueState external_validation_value_state,
- bool is_personal,
- PrefHashFilter::PrefTrackingStrategy strategy) {
- validations_.push_back(ValidationEvent(pref_path, value_state,
- external_validation_value_state,
- is_personal, strategy));
+ bool is_personal) {
+ record_->RecordValidation(pref_path, value_state,
+ external_validation_value_state, is_personal,
+ PrefHashFilter::TRACKING_STRATEGY_SPLIT);
}
« no previous file with comments | « components/user_prefs/tracked/mock_validation_delegate.h ('k') | components/user_prefs/tracked/pref_hash_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698