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

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

Issue 2204943002: Integrate registry_hash_store_contents with the rest of tracked prefs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove a lost include statement Created 4 years, 4 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/tracked_atomic_preference.h" 5 #include "components/user_prefs/tracked/tracked_atomic_preference.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "components/user_prefs/tracked/pref_hash_store_transaction.h" 8 #include "components/user_prefs/tracked/pref_hash_store_transaction.h"
9 #include "components/user_prefs/tracked/tracked_preference_validation_delegate.h " 9 #include "components/user_prefs/tracked/tracked_preference_validation_delegate.h "
10 10
11 TrackedAtomicPreference::TrackedAtomicPreference( 11 TrackedAtomicPreference::TrackedAtomicPreference(
12 const std::string& pref_path, 12 const std::string& pref_path,
13 size_t reporting_id, 13 size_t reporting_id,
14 size_t reporting_ids_count, 14 size_t reporting_ids_count,
15 PrefHashFilter::EnforcementLevel enforcement_level, 15 PrefHashFilter::EnforcementLevel enforcement_level,
16 PrefHashFilter::ValueType value_type, 16 PrefHashFilter::ValueType value_type,
17 TrackedPreferenceValidationDelegate* delegate) 17 TrackedPreferenceValidationDelegate* delegate)
18 : pref_path_(pref_path), 18 : pref_path_(pref_path),
19 helper_(pref_path, 19 helper_(pref_path,
20 reporting_id, 20 reporting_id,
21 reporting_ids_count, 21 reporting_ids_count,
22 enforcement_level, 22 enforcement_level,
23 value_type), 23 value_type),
24 delegate_(delegate) { 24 delegate_(delegate) {
25 } 25 }
26 26
27 TrackedPreferenceType TrackedAtomicPreference::GetType() const {
28 return TrackedPreferenceType::ATOMIC;
29 }
30
27 void TrackedAtomicPreference::OnNewValue( 31 void TrackedAtomicPreference::OnNewValue(
28 const base::Value* value, 32 const base::Value* value,
29 PrefHashStoreTransaction* transaction) const { 33 PrefHashStoreTransaction* transaction) const {
30 transaction->StoreHash(pref_path_, value); 34 transaction->StoreHash(pref_path_, value);
31 } 35 }
32 36
33 bool TrackedAtomicPreference::EnforceAndReport( 37 bool TrackedAtomicPreference::EnforceAndReport(
34 base::DictionaryValue* pref_store_contents, 38 base::DictionaryValue* pref_store_contents,
35 PrefHashStoreTransaction* transaction) const { 39 PrefHashStoreTransaction* transaction,
40 PrefHashStoreTransaction* external_validation_transaction) const {
36 const base::Value* value = NULL; 41 const base::Value* value = NULL;
37 pref_store_contents->Get(pref_path_, &value); 42 pref_store_contents->Get(pref_path_, &value);
38 PrefHashStoreTransaction::ValueState value_state = 43 PrefHashStoreTransaction::ValueState value_state =
39 transaction->CheckValue(pref_path_, value); 44 transaction->CheckValue(pref_path_, value);
45 helper_.ReportValidationResult(value_state, transaction->GetStoreUMASuffix());
40 46
41 helper_.ReportValidationResult(value_state); 47 PrefHashStoreTransaction::ValueState external_validation_value_state =
48 PrefHashStoreTransaction::UNCHANGED;
49 if (external_validation_transaction) {
50 external_validation_value_state =
51 external_validation_transaction->CheckValue(pref_path_, value);
52 helper_.ReportValidationResult(
53 external_validation_value_state,
54 external_validation_transaction->GetStoreUMASuffix());
42 55
43 TrackedPreferenceHelper::ResetAction reset_action = 56 // TODO(proberge): Call delegate_->OnAtomicPreferenceValidation.
44 helper_.GetAction(value_state); 57 }
58
45 if (delegate_) { 59 if (delegate_) {
46 delegate_->OnAtomicPreferenceValidation(pref_path_, value, value_state, 60 delegate_->OnAtomicPreferenceValidation(pref_path_, value, value_state,
47 helper_.IsPersonal()); 61 helper_.IsPersonal());
48 } 62 }
63 TrackedPreferenceHelper::ResetAction reset_action =
64 helper_.GetAction(value_state);
49 helper_.ReportAction(reset_action); 65 helper_.ReportAction(reset_action);
50 66
51 bool was_reset = false; 67 bool was_reset = false;
52 if (reset_action == TrackedPreferenceHelper::DO_RESET) { 68 if (reset_action == TrackedPreferenceHelper::DO_RESET) {
53 pref_store_contents->RemovePath(pref_path_, NULL); 69 pref_store_contents->RemovePath(pref_path_, NULL);
54 was_reset = true; 70 was_reset = true;
55 } 71 }
56 72
57 if (value_state != PrefHashStoreTransaction::UNCHANGED) { 73 if (value_state != PrefHashStoreTransaction::UNCHANGED) {
58 // Store the hash for the new value (whether it was reset or not). 74 // Store the hash for the new value (whether it was reset or not).
59 const base::Value* new_value = NULL; 75 const base::Value* new_value = NULL;
60 pref_store_contents->Get(pref_path_, &new_value); 76 pref_store_contents->Get(pref_path_, &new_value);
61 transaction->StoreHash(pref_path_, new_value); 77 transaction->StoreHash(pref_path_, new_value);
62 } 78 }
63 79
80 if (external_validation_transaction &&
gab 2016/08/08 04:37:47 // Update MACs in the external store if there is o
proberge 2016/08/31 17:30:17 Done.
81 (was_reset ||
82 external_validation_value_state !=
83 PrefHashStoreTransaction::UNCHANGED)) {
84 const base::Value* new_value = NULL;
gab 2016/08/08 04:37:47 nullptr
proberge 2016/08/31 17:30:17 Done.
85 pref_store_contents->Get(pref_path_, &new_value);
86 external_validation_transaction->StoreHash(pref_path_, new_value);
87 }
88
64 return was_reset; 89 return was_reset;
65 } 90 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698