OLD | NEW |
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/segregated_pref_store.h" | 5 #include "components/user_prefs/tracked/segregated_pref_store.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/logging.h" | 9 #include "base/logging.h" |
8 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
9 #include "base/values.h" | 11 #include "base/values.h" |
10 | 12 |
11 SegregatedPrefStore::AggregatingObserver::AggregatingObserver( | 13 SegregatedPrefStore::AggregatingObserver::AggregatingObserver( |
12 SegregatedPrefStore* outer) | 14 SegregatedPrefStore* outer) |
13 : outer_(outer), | 15 : outer_(outer), |
14 failed_sub_initializations_(0), | 16 failed_sub_initializations_(0), |
15 successful_sub_initializations_(0) { | 17 successful_sub_initializations_(0) { |
16 } | 18 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 80 } |
79 | 81 |
80 bool SegregatedPrefStore::GetValue(const std::string& key, | 82 bool SegregatedPrefStore::GetValue(const std::string& key, |
81 const base::Value** result) const { | 83 const base::Value** result) const { |
82 return StoreForKey(key)->GetValue(key, result); | 84 return StoreForKey(key)->GetValue(key, result); |
83 } | 85 } |
84 | 86 |
85 void SegregatedPrefStore::SetValue(const std::string& key, | 87 void SegregatedPrefStore::SetValue(const std::string& key, |
86 scoped_ptr<base::Value> value, | 88 scoped_ptr<base::Value> value, |
87 uint32_t flags) { | 89 uint32_t flags) { |
88 StoreForKey(key)->SetValue(key, value.Pass(), flags); | 90 StoreForKey(key)->SetValue(key, std::move(value), flags); |
89 } | 91 } |
90 | 92 |
91 void SegregatedPrefStore::RemoveValue(const std::string& key, uint32_t flags) { | 93 void SegregatedPrefStore::RemoveValue(const std::string& key, uint32_t flags) { |
92 StoreForKey(key)->RemoveValue(key, flags); | 94 StoreForKey(key)->RemoveValue(key, flags); |
93 } | 95 } |
94 | 96 |
95 bool SegregatedPrefStore::GetMutableValue(const std::string& key, | 97 bool SegregatedPrefStore::GetMutableValue(const std::string& key, |
96 base::Value** result) { | 98 base::Value** result) { |
97 return StoreForKey(key)->GetMutableValue(key, result); | 99 return StoreForKey(key)->GetMutableValue(key, result); |
98 } | 100 } |
99 | 101 |
100 void SegregatedPrefStore::ReportValueChanged(const std::string& key, | 102 void SegregatedPrefStore::ReportValueChanged(const std::string& key, |
101 uint32_t flags) { | 103 uint32_t flags) { |
102 StoreForKey(key)->ReportValueChanged(key, flags); | 104 StoreForKey(key)->ReportValueChanged(key, flags); |
103 } | 105 } |
104 | 106 |
105 void SegregatedPrefStore::SetValueSilently(const std::string& key, | 107 void SegregatedPrefStore::SetValueSilently(const std::string& key, |
106 scoped_ptr<base::Value> value, | 108 scoped_ptr<base::Value> value, |
107 uint32_t flags) { | 109 uint32_t flags) { |
108 StoreForKey(key)->SetValueSilently(key, value.Pass(), flags); | 110 StoreForKey(key)->SetValueSilently(key, std::move(value), flags); |
109 } | 111 } |
110 | 112 |
111 bool SegregatedPrefStore::ReadOnly() const { | 113 bool SegregatedPrefStore::ReadOnly() const { |
112 return selected_pref_store_->ReadOnly() || default_pref_store_->ReadOnly(); | 114 return selected_pref_store_->ReadOnly() || default_pref_store_->ReadOnly(); |
113 } | 115 } |
114 | 116 |
115 PersistentPrefStore::PrefReadError SegregatedPrefStore::GetReadError() const { | 117 PersistentPrefStore::PrefReadError SegregatedPrefStore::GetReadError() const { |
116 PersistentPrefStore::PrefReadError read_error = | 118 PersistentPrefStore::PrefReadError read_error = |
117 default_pref_store_->GetReadError(); | 119 default_pref_store_->GetReadError(); |
118 if (read_error == PersistentPrefStore::PREF_READ_ERROR_NONE) { | 120 if (read_error == PersistentPrefStore::PREF_READ_ERROR_NONE) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 ? selected_pref_store_ | 166 ? selected_pref_store_ |
165 : default_pref_store_).get(); | 167 : default_pref_store_).get(); |
166 } | 168 } |
167 | 169 |
168 const PersistentPrefStore* SegregatedPrefStore::StoreForKey( | 170 const PersistentPrefStore* SegregatedPrefStore::StoreForKey( |
169 const std::string& key) const { | 171 const std::string& key) const { |
170 return (ContainsKey(selected_preference_names_, key) | 172 return (ContainsKey(selected_preference_names_, key) |
171 ? selected_pref_store_ | 173 ? selected_pref_store_ |
172 : default_pref_store_).get(); | 174 : default_pref_store_).get(); |
173 } | 175 } |
OLD | NEW |