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

Side by Side Diff: base/prefs/pref_service.cc

Issue 1129083003: More base::Values-related bare pointer -> scoped_ptr conversions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix bad merge Created 5 years, 7 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
« no previous file with comments | « base/prefs/json_pref_store.cc ('k') | base/test/values_test_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/prefs/pref_service.h" 5 #include "base/prefs/pref_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 183
184 bool PrefService::HasPrefPath(const std::string& path) const { 184 bool PrefService::HasPrefPath(const std::string& path) const {
185 const Preference* pref = FindPreference(path); 185 const Preference* pref = FindPreference(path);
186 return pref && !pref->IsDefaultValue(); 186 return pref && !pref->IsDefaultValue();
187 } 187 }
188 188
189 scoped_ptr<base::DictionaryValue> PrefService::GetPreferenceValues() const { 189 scoped_ptr<base::DictionaryValue> PrefService::GetPreferenceValues() const {
190 DCHECK(CalledOnValidThread()); 190 DCHECK(CalledOnValidThread());
191 scoped_ptr<base::DictionaryValue> out(new base::DictionaryValue); 191 scoped_ptr<base::DictionaryValue> out(new base::DictionaryValue);
192 for (const auto& it : *pref_registry_) { 192 for (const auto& it : *pref_registry_) {
193 const base::Value* value = GetPreferenceValue(it.first); 193 out->Set(it.first, GetPreferenceValue(it.first)->CreateDeepCopy());
194 out->Set(it.first, value->DeepCopy());
195 } 194 }
196 return out.Pass(); 195 return out.Pass();
197 } 196 }
198 197
199 scoped_ptr<base::DictionaryValue> PrefService::GetPreferenceValuesOmitDefaults() 198 scoped_ptr<base::DictionaryValue> PrefService::GetPreferenceValuesOmitDefaults()
200 const { 199 const {
201 DCHECK(CalledOnValidThread()); 200 DCHECK(CalledOnValidThread());
202 scoped_ptr<base::DictionaryValue> out(new base::DictionaryValue); 201 scoped_ptr<base::DictionaryValue> out(new base::DictionaryValue);
203 for (const auto& it : *pref_registry_) { 202 for (const auto& it : *pref_registry_) {
204 const Preference* pref = FindPreference(it.first); 203 const Preference* pref = FindPreference(it.first);
205 if (pref->IsDefaultValue()) 204 if (pref->IsDefaultValue())
206 continue; 205 continue;
207 out->Set(it.first, pref->GetValue()->DeepCopy()); 206 out->Set(it.first, pref->GetValue()->CreateDeepCopy());
208 } 207 }
209 return out.Pass(); 208 return out.Pass();
210 } 209 }
211 210
212 scoped_ptr<base::DictionaryValue> 211 scoped_ptr<base::DictionaryValue>
213 PrefService::GetPreferenceValuesWithoutPathExpansion() const { 212 PrefService::GetPreferenceValuesWithoutPathExpansion() const {
214 DCHECK(CalledOnValidThread()); 213 DCHECK(CalledOnValidThread());
215 scoped_ptr<base::DictionaryValue> out(new base::DictionaryValue); 214 scoped_ptr<base::DictionaryValue> out(new base::DictionaryValue);
216 for (const auto& it : *pref_registry_) { 215 for (const auto& it : *pref_registry_) {
217 const base::Value* value = GetPreferenceValue(it.first); 216 const base::Value* value = GetPreferenceValue(it.first);
218 DCHECK(value); 217 DCHECK(value);
219 out->SetWithoutPathExpansion(it.first, value->DeepCopy()); 218 out->SetWithoutPathExpansion(it.first, value->CreateDeepCopy());
220 } 219 }
221 return out.Pass(); 220 return out.Pass();
222 } 221 }
223 222
224 const PrefService::Preference* PrefService::FindPreference( 223 const PrefService::Preference* PrefService::FindPreference(
225 const std::string& pref_name) const { 224 const std::string& pref_name) const {
226 DCHECK(CalledOnValidThread()); 225 DCHECK(CalledOnValidThread());
227 PreferenceMap::iterator it = prefs_map_.find(pref_name); 226 PreferenceMap::iterator it = prefs_map_.find(pref_name);
228 if (it != prefs_map_.end()) 227 if (it != prefs_map_.end())
229 return &(it->second); 228 return &(it->second);
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 DCHECK(found_value->IsType(default_type)); 600 DCHECK(found_value->IsType(default_type));
602 return found_value; 601 return found_value;
603 } else { 602 } else {
604 // Every registered preference has at least a default value. 603 // Every registered preference has at least a default value.
605 NOTREACHED() << "no valid value found for registered pref " << path; 604 NOTREACHED() << "no valid value found for registered pref " << path;
606 } 605 }
607 } 606 }
608 607
609 return NULL; 608 return NULL;
610 } 609 }
OLDNEW
« no previous file with comments | « base/prefs/json_pref_store.cc ('k') | base/test/values_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698