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

Side by Side Diff: services/preferences/public/cpp/tracked/mock_validation_delegate.cc

Issue 2782803002: Move tracked prefs into services/preferences/tracked. (Closed)
Patch Set: rebase Created 3 years, 8 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 "services/preferences/public/cpp/tracked/mock_validation_delegate.h"
6 6
7 MockValidationDelegateRecord::MockValidationDelegateRecord() = default; 7 MockValidationDelegateRecord::MockValidationDelegateRecord() = default;
8 8
9 MockValidationDelegateRecord::~MockValidationDelegateRecord() = default; 9 MockValidationDelegateRecord::~MockValidationDelegateRecord() = default;
10 10
11 size_t MockValidationDelegateRecord::CountValidationsOfState( 11 size_t MockValidationDelegateRecord::CountValidationsOfState(
12 PrefHashStoreTransaction::ValueState value_state) const { 12 prefs::mojom::TrackedPreferenceValidationDelegate::ValueState value_state)
13 const {
13 size_t count = 0; 14 size_t count = 0;
14 for (size_t i = 0; i < validations_.size(); ++i) { 15 for (size_t i = 0; i < validations_.size(); ++i) {
15 if (validations_[i].value_state == value_state) 16 if (validations_[i].value_state == value_state)
16 ++count; 17 ++count;
17 } 18 }
18 return count; 19 return count;
19 } 20 }
20 21
21 size_t MockValidationDelegateRecord::CountExternalValidationsOfState( 22 size_t MockValidationDelegateRecord::CountExternalValidationsOfState(
22 PrefHashStoreTransaction::ValueState value_state) const { 23 prefs::mojom::TrackedPreferenceValidationDelegate::ValueState value_state)
24 const {
23 size_t count = 0; 25 size_t count = 0;
24 for (size_t i = 0; i < validations_.size(); ++i) { 26 for (size_t i = 0; i < validations_.size(); ++i) {
25 if (validations_[i].external_validation_value_state == value_state) 27 if (validations_[i].external_validation_value_state == value_state)
26 ++count; 28 ++count;
27 } 29 }
28 return count; 30 return count;
29 } 31 }
30 32
31 const MockValidationDelegateRecord::ValidationEvent* 33 const MockValidationDelegateRecord::ValidationEvent*
32 MockValidationDelegateRecord::GetEventForPath( 34 MockValidationDelegateRecord::GetEventForPath(
33 const std::string& pref_path) const { 35 const std::string& pref_path) const {
34 for (size_t i = 0; i < validations_.size(); ++i) { 36 for (size_t i = 0; i < validations_.size(); ++i) {
35 if (validations_[i].pref_path == pref_path) 37 if (validations_[i].pref_path == pref_path)
36 return &validations_[i]; 38 return &validations_[i];
37 } 39 }
38 return NULL; 40 return NULL;
39 } 41 }
40 42
41 void MockValidationDelegateRecord::RecordValidation( 43 void MockValidationDelegateRecord::RecordValidation(
42 const std::string& pref_path, 44 const std::string& pref_path,
43 PrefHashStoreTransaction::ValueState value_state, 45 prefs::mojom::TrackedPreferenceValidationDelegate::ValueState value_state,
44 PrefHashStoreTransaction::ValueState external_validation_value_state, 46 prefs::mojom::TrackedPreferenceValidationDelegate::ValueState
47 external_validation_value_state,
45 bool is_personal, 48 bool is_personal,
46 PrefHashFilter::PrefTrackingStrategy strategy) { 49 prefs::mojom::TrackedPreferenceMetadata::PrefTrackingStrategy strategy) {
47 validations_.push_back(ValidationEvent(pref_path, value_state, 50 validations_.push_back(ValidationEvent(pref_path, value_state,
48 external_validation_value_state, 51 external_validation_value_state,
49 is_personal, strategy)); 52 is_personal, strategy));
50 } 53 }
51 54
52 MockValidationDelegate::MockValidationDelegate( 55 MockValidationDelegate::MockValidationDelegate(
53 scoped_refptr<MockValidationDelegateRecord> record) 56 scoped_refptr<MockValidationDelegateRecord> record)
54 : record_(std::move(record)) {} 57 : record_(std::move(record)) {}
55 58
56 MockValidationDelegate::~MockValidationDelegate() = default; 59 MockValidationDelegate::~MockValidationDelegate() = default;
57 60
58 void MockValidationDelegate::OnAtomicPreferenceValidation( 61 void MockValidationDelegate::OnAtomicPreferenceValidation(
59 const std::string& pref_path, 62 const std::string& pref_path,
60 std::unique_ptr<base::Value> value, 63 std::unique_ptr<base::Value> value,
61 PrefHashStoreTransaction::ValueState value_state, 64 prefs::mojom::TrackedPreferenceValidationDelegate::ValueState value_state,
62 PrefHashStoreTransaction::ValueState external_validation_value_state, 65 prefs::mojom::TrackedPreferenceValidationDelegate::ValueState
66 external_validation_value_state,
63 bool is_personal) { 67 bool is_personal) {
64 record_->RecordValidation(pref_path, value_state, 68 record_->RecordValidation(
65 external_validation_value_state, is_personal, 69 pref_path, value_state, external_validation_value_state, is_personal,
66 PrefHashFilter::PrefTrackingStrategy::ATOMIC); 70 prefs::mojom::TrackedPreferenceMetadata::PrefTrackingStrategy::ATOMIC);
67 } 71 }
68 72
69 void MockValidationDelegate::OnSplitPreferenceValidation( 73 void MockValidationDelegate::OnSplitPreferenceValidation(
70 const std::string& pref_path, 74 const std::string& pref_path,
71 const std::vector<std::string>& invalid_keys, 75 const std::vector<std::string>& invalid_keys,
72 const std::vector<std::string>& external_validation_invalid_keys, 76 const std::vector<std::string>& external_validation_invalid_keys,
73 PrefHashStoreTransaction::ValueState value_state, 77 prefs::mojom::TrackedPreferenceValidationDelegate::ValueState value_state,
74 PrefHashStoreTransaction::ValueState external_validation_value_state, 78 prefs::mojom::TrackedPreferenceValidationDelegate::ValueState
79 external_validation_value_state,
75 bool is_personal) { 80 bool is_personal) {
76 record_->RecordValidation(pref_path, value_state, 81 record_->RecordValidation(
77 external_validation_value_state, is_personal, 82 pref_path, value_state, external_validation_value_state, is_personal,
78 PrefHashFilter::PrefTrackingStrategy::SPLIT); 83 prefs::mojom::TrackedPreferenceMetadata::PrefTrackingStrategy::SPLIT);
79 } 84 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698