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

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

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
« no previous file with comments | « components/user_prefs/tracked/DEPS ('k') | components/user_prefs/tracked/mock_validation_delegate.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/user_prefs/tracked/mock_validation_delegate.h
diff --git a/components/user_prefs/tracked/mock_validation_delegate.h b/components/user_prefs/tracked/mock_validation_delegate.h
index de95f0599ed4fbfcdeea831497dc23e500d8ee23..58a35e821ade75e0fcf619b64dba3b3c2bb3c6c3 100644
--- a/components/user_prefs/tracked/mock_validation_delegate.h
+++ b/components/user_prefs/tracked/mock_validation_delegate.h
@@ -14,10 +14,13 @@
#include "base/macros.h"
#include "components/user_prefs/tracked/pref_hash_filter.h"
#include "components/user_prefs/tracked/pref_hash_store_transaction.h"
-#include "components/user_prefs/tracked/tracked_preference_validation_delegate.h"
+#include "services/preferences/public/interfaces/tracked_preference_validation_delegate.mojom.h"
+
+class MockValidationDelegate;
// A mock tracked preference validation delegate for use by tests.
-class MockValidationDelegate : public TrackedPreferenceValidationDelegate {
+class MockValidationDelegateRecord
+ : public base::RefCounted<MockValidationDelegateRecord> {
public:
struct ValidationEvent {
ValidationEvent(
@@ -39,8 +42,7 @@ class MockValidationDelegate : public TrackedPreferenceValidationDelegate {
PrefHashFilter::PrefTrackingStrategy strategy;
};
- MockValidationDelegate();
- ~MockValidationDelegate() override;
+ MockValidationDelegateRecord();
// Returns the number of recorded validations.
size_t recorded_validations_count() const { return validations_.size(); }
@@ -56,16 +58,41 @@ class MockValidationDelegate : public TrackedPreferenceValidationDelegate {
// Returns the event for the preference with a given path.
const ValidationEvent* GetEventForPath(const std::string& pref_path) const;
+ private:
+ friend class MockValidationDelegate;
+ friend class base::RefCounted<MockValidationDelegateRecord>;
+
+ ~MockValidationDelegateRecord();
+
+ // Adds a new validation event.
+ void RecordValidation(
+ const std::string& pref_path,
+ PrefHashStoreTransaction::ValueState value_state,
+ PrefHashStoreTransaction::ValueState external_validation_value_state,
+ bool is_personal,
+ PrefHashFilter::PrefTrackingStrategy strategy);
+
+ std::vector<ValidationEvent> validations_;
+
+ DISALLOW_COPY_AND_ASSIGN(MockValidationDelegateRecord);
+};
+
+class MockValidationDelegate
+ : public prefs::mojom::TrackedPreferenceValidationDelegate {
+ public:
+ explicit MockValidationDelegate(
+ scoped_refptr<MockValidationDelegateRecord> record);
+ ~MockValidationDelegate() override;
+
// TrackedPreferenceValidationDelegate implementation.
void OnAtomicPreferenceValidation(
const std::string& pref_path,
- const base::Value* value,
+ std::unique_ptr<base::Value> value,
PrefHashStoreTransaction::ValueState value_state,
PrefHashStoreTransaction::ValueState external_validation_value_state,
bool is_personal) override;
void OnSplitPreferenceValidation(
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,
PrefHashStoreTransaction::ValueState value_state,
@@ -81,7 +108,7 @@ class MockValidationDelegate : public TrackedPreferenceValidationDelegate {
bool is_personal,
PrefHashFilter::PrefTrackingStrategy strategy);
- std::vector<ValidationEvent> validations_;
+ scoped_refptr<MockValidationDelegateRecord> record_;
DISALLOW_COPY_AND_ASSIGN(MockValidationDelegate);
};
« no previous file with comments | « components/user_prefs/tracked/DEPS ('k') | components/user_prefs/tracked/mock_validation_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698