cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / components / user_prefs / tracked / tracked_atomic_preference.cc
blob4eb4b6129d2b86e411928032141ac769387e7c42
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
3 // found in the LICENSE file.
5 #include "components/user_prefs/tracked/tracked_atomic_preference.h"
7 #include "base/values.h"
8 #include "components/user_prefs/tracked/pref_hash_store_transaction.h"
9 #include "components/user_prefs/tracked/tracked_preference_validation_delegate.h"
11 TrackedAtomicPreference::TrackedAtomicPreference(
12 const std::string& pref_path,
13 size_t reporting_id,
14 size_t reporting_ids_count,
15 PrefHashFilter::EnforcementLevel enforcement_level,
16 PrefHashFilter::ValueType value_type,
17 TrackedPreferenceValidationDelegate* delegate)
18 : pref_path_(pref_path),
19 helper_(pref_path,
20 reporting_id,
21 reporting_ids_count,
22 enforcement_level,
23 value_type),
24 delegate_(delegate) {
27 void TrackedAtomicPreference::OnNewValue(
28 const base::Value* value,
29 PrefHashStoreTransaction* transaction) const {
30 transaction->StoreHash(pref_path_, value);
33 bool TrackedAtomicPreference::EnforceAndReport(
34 base::DictionaryValue* pref_store_contents,
35 PrefHashStoreTransaction* transaction) const {
36 const base::Value* value = NULL;
37 pref_store_contents->Get(pref_path_, &value);
38 PrefHashStoreTransaction::ValueState value_state =
39 transaction->CheckValue(pref_path_, value);
41 helper_.ReportValidationResult(value_state);
43 TrackedPreferenceHelper::ResetAction reset_action =
44 helper_.GetAction(value_state);
45 if (delegate_) {
46 delegate_->OnAtomicPreferenceValidation(pref_path_, value, value_state,
47 helper_.IsPersonal());
49 helper_.ReportAction(reset_action);
51 bool was_reset = false;
52 if (reset_action == TrackedPreferenceHelper::DO_RESET) {
53 pref_store_contents->RemovePath(pref_path_, NULL);
54 was_reset = true;
57 if (value_state != PrefHashStoreTransaction::UNCHANGED) {
58 // Store the hash for the new value (whether it was reset or not).
59 const base::Value* new_value = NULL;
60 pref_store_contents->Get(pref_path_, &new_value);
61 transaction->StoreHash(pref_path_, new_value);
64 return was_reset;