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

Side by Side Diff: chrome/service/service_prefs.cc

Issue 5646003: Sanitize PrefStore interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, fix up unit tests. Created 10 years 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
(Empty)
1 // Copyright (c) 2010 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.
4
5 #include "chrome/service/service_prefs.h"
6
7 #include "base/values.h"
8
9 ServicePrefs::ServicePrefs(const FilePath& pref_filename,
10 base::MessageLoopProxy* file_message_loop_proxy)
11 : prefs_(pref_filename, file_message_loop_proxy) {
12 }
13
14 void ServicePrefs::ReadPrefs() {
15 prefs_.ReadPrefs();
16 }
17
18 void ServicePrefs::WritePrefs() {
19 prefs_.WritePrefs();
20 }
21
22 void ServicePrefs::GetString(const std::string& key, std::string* result) {
23 Value* value;
24 if (prefs_.GetValue(key, &value) == PersistentPrefStore::READ_OK)
25 value->GetAsString(result);
26 }
27
28 void ServicePrefs::SetString(const std::string& key, const std::string& value) {
29 prefs_.SetValue(key, Value::CreateStringValue(value));
30 }
31
32 void ServicePrefs::GetBoolean(const std::string& key, bool* result) {
33 Value* value;
34 if (prefs_.GetValue(key, &value) == PersistentPrefStore::READ_OK)
35 value->GetAsBoolean(result);
gfeher 2010/12/08 12:34:35 How about indicating missing prefs to the consumer
Mattias Nissler (ping if slow) 2010/12/09 10:20:20 If the consumers would need that. But so far they
36 }
37
38 void ServicePrefs::SetBoolean(const std::string& key, bool value) {
39 prefs_.SetValue(key, Value::CreateBooleanValue(value));
40 }
41
42 void ServicePrefs::GetDictionary(const std::string& key,
43 DictionaryValue** result) {
44 Value* value;
45 if (prefs_.GetValue(key, &value) != PersistentPrefStore::READ_OK ||
46 !value->IsType(Value::TYPE_DICTIONARY)) {
47 return;
48 }
49
50 *result = static_cast<DictionaryValue*>(value);
51 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698