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

Side by Side Diff: components/user_prefs/tracked/mock_validation_delegate.cc

Issue 2390213002: Revert of Send a TrackedPreference incident when registry pref validation fails. (Closed)
Patch Set: Created 4 years, 2 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 #include "components/user_prefs/tracked/mock_validation_delegate.h" 5 #include "components/user_prefs/tracked/mock_validation_delegate.h"
6 6
7 MockValidationDelegate::MockValidationDelegate() { 7 MockValidationDelegate::MockValidationDelegate() {
8 } 8 }
9 9
10 MockValidationDelegate::~MockValidationDelegate() { 10 MockValidationDelegate::~MockValidationDelegate() {
11 } 11 }
12 12
13 size_t MockValidationDelegate::CountValidationsOfState( 13 size_t MockValidationDelegate::CountValidationsOfState(
14 PrefHashStoreTransaction::ValueState value_state) const { 14 PrefHashStoreTransaction::ValueState value_state) const {
15 size_t count = 0; 15 size_t count = 0;
16 for (size_t i = 0; i < validations_.size(); ++i) { 16 for (size_t i = 0; i < validations_.size(); ++i) {
17 if (validations_[i].value_state == value_state) 17 if (validations_[i].value_state == value_state)
18 ++count; 18 ++count;
19 } 19 }
20 return count; 20 return count;
21 } 21 }
22 22
23 size_t MockValidationDelegate::CountExternalValidationsOfState(
24 PrefHashStoreTransaction::ValueState value_state) const {
25 size_t count = 0;
26 for (size_t i = 0; i < validations_.size(); ++i) {
27 if (validations_[i].external_validation_value_state == value_state)
28 ++count;
29 }
30 return count;
31 }
32
33 const MockValidationDelegate::ValidationEvent* 23 const MockValidationDelegate::ValidationEvent*
34 MockValidationDelegate::GetEventForPath(const std::string& pref_path) const { 24 MockValidationDelegate::GetEventForPath(const std::string& pref_path) const {
35 for (size_t i = 0; i < validations_.size(); ++i) { 25 for (size_t i = 0; i < validations_.size(); ++i) {
36 if (validations_[i].pref_path == pref_path) 26 if (validations_[i].pref_path == pref_path)
37 return &validations_[i]; 27 return &validations_[i];
38 } 28 }
39 return NULL; 29 return NULL;
40 } 30 }
41 31
42 void MockValidationDelegate::OnAtomicPreferenceValidation( 32 void MockValidationDelegate::OnAtomicPreferenceValidation(
43 const std::string& pref_path, 33 const std::string& pref_path,
44 const base::Value* value, 34 const base::Value* value,
45 PrefHashStoreTransaction::ValueState value_state, 35 PrefHashStoreTransaction::ValueState value_state,
46 PrefHashStoreTransaction::ValueState external_validation_value_state,
47 bool is_personal) { 36 bool is_personal) {
48 RecordValidation(pref_path, value_state, external_validation_value_state, 37 RecordValidation(pref_path, value_state, is_personal,
49 is_personal, PrefHashFilter::TRACKING_STRATEGY_ATOMIC); 38 PrefHashFilter::TRACKING_STRATEGY_ATOMIC);
50 } 39 }
51 40
52 void MockValidationDelegate::OnSplitPreferenceValidation( 41 void MockValidationDelegate::OnSplitPreferenceValidation(
53 const std::string& pref_path, 42 const std::string& pref_path,
54 const base::DictionaryValue* dict_value, 43 const base::DictionaryValue* dict_value,
55 const std::vector<std::string>& invalid_keys, 44 const std::vector<std::string>& invalid_keys,
56 PrefHashStoreTransaction::ValueState value_state, 45 PrefHashStoreTransaction::ValueState value_state,
57 PrefHashStoreTransaction::ValueState external_validation_value_state,
58 bool is_personal) { 46 bool is_personal) {
59 RecordValidation(pref_path, value_state, external_validation_value_state, 47 RecordValidation(pref_path, value_state, is_personal,
60 is_personal, PrefHashFilter::TRACKING_STRATEGY_SPLIT); 48 PrefHashFilter::TRACKING_STRATEGY_SPLIT);
61 } 49 }
62 50
63 void MockValidationDelegate::RecordValidation( 51 void MockValidationDelegate::RecordValidation(
64 const std::string& pref_path, 52 const std::string& pref_path,
65 PrefHashStoreTransaction::ValueState value_state, 53 PrefHashStoreTransaction::ValueState value_state,
66 PrefHashStoreTransaction::ValueState external_validation_value_state,
67 bool is_personal, 54 bool is_personal,
68 PrefHashFilter::PrefTrackingStrategy strategy) { 55 PrefHashFilter::PrefTrackingStrategy strategy) {
69 validations_.push_back(ValidationEvent(pref_path, value_state, 56 validations_.push_back(
70 external_validation_value_state, 57 ValidationEvent(pref_path, value_state, is_personal, strategy));
71 is_personal, strategy));
72 } 58 }
OLDNEW
« no previous file with comments | « components/user_prefs/tracked/mock_validation_delegate.h ('k') | components/user_prefs/tracked/pref_hash_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698