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

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

Issue 24533002: Added the AutomaticProfileResetter service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Final touches on unittests. Created 7 years, 2 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 | Annotate | Revision Log
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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 base::DictionaryValue* out = new base::DictionaryValue; 177 base::DictionaryValue* out = new base::DictionaryValue;
178 PrefRegistry::const_iterator i = pref_registry_->begin(); 178 PrefRegistry::const_iterator i = pref_registry_->begin();
179 for (; i != pref_registry_->end(); ++i) { 179 for (; i != pref_registry_->end(); ++i) {
180 const base::Value* value = GetPreferenceValue(i->first); 180 const base::Value* value = GetPreferenceValue(i->first);
181 DCHECK(value); 181 DCHECK(value);
182 out->Set(i->first, value->DeepCopy()); 182 out->Set(i->first, value->DeepCopy());
183 } 183 }
184 return out; 184 return out;
185 } 185 }
186 186
187 base::DictionaryValue* PrefService::GetPreferenceValuesWithoutPathExpansion()
188 const {
189 DCHECK(CalledOnValidThread());
190 base::DictionaryValue* out = new base::DictionaryValue;
191 PrefRegistry::const_iterator i = pref_registry_->begin();
192 for (; i != pref_registry_->end(); ++i) {
193 const base::Value* value = GetPreferenceValue(i->first);
194 DCHECK(value);
195 out->SetWithoutPathExpansion(i->first, value->DeepCopy());
196 }
197 return out;
198 }
199
187 const PrefService::Preference* PrefService::FindPreference( 200 const PrefService::Preference* PrefService::FindPreference(
188 const char* pref_name) const { 201 const char* pref_name) const {
189 DCHECK(CalledOnValidThread()); 202 DCHECK(CalledOnValidThread());
190 PreferenceMap::iterator it = prefs_map_.find(pref_name); 203 PreferenceMap::iterator it = prefs_map_.find(pref_name);
191 if (it != prefs_map_.end()) 204 if (it != prefs_map_.end())
192 return &(it->second); 205 return &(it->second);
193 const base::Value* default_value = NULL; 206 const base::Value* default_value = NULL;
194 if (!pref_registry_->defaults()->GetValue(pref_name, &default_value)) 207 if (!pref_registry_->defaults()->GetValue(pref_name, &default_value))
195 return NULL; 208 return NULL;
196 it = prefs_map_.insert( 209 it = prefs_map_.insert(
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 DCHECK(found_value->IsType(default_type)); 590 DCHECK(found_value->IsType(default_type));
578 return found_value; 591 return found_value;
579 } else { 592 } else {
580 // Every registered preference has at least a default value. 593 // Every registered preference has at least a default value.
581 NOTREACHED() << "no valid value found for registered pref " << path; 594 NOTREACHED() << "no valid value found for registered pref " << path;
582 } 595 }
583 } 596 }
584 597
585 return NULL; 598 return NULL;
586 } 599 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698