OLD | NEW |
(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_process_prefs.h" |
| 6 |
| 7 #include "base/values.h" |
| 8 |
| 9 ServiceProcessPrefs::ServiceProcessPrefs( |
| 10 const FilePath& pref_filename, |
| 11 base::MessageLoopProxy* file_message_loop_proxy) |
| 12 : prefs_(pref_filename, file_message_loop_proxy) { |
| 13 } |
| 14 |
| 15 void ServiceProcessPrefs::ReadPrefs() { |
| 16 prefs_.ReadPrefs(); |
| 17 } |
| 18 |
| 19 void ServiceProcessPrefs::WritePrefs() { |
| 20 prefs_.WritePrefs(); |
| 21 } |
| 22 |
| 23 void ServiceProcessPrefs::GetString(const std::string& key, |
| 24 std::string* result) { |
| 25 Value* value; |
| 26 if (prefs_.GetValue(key, &value) == PersistentPrefStore::READ_OK) |
| 27 value->GetAsString(result); |
| 28 } |
| 29 |
| 30 void ServiceProcessPrefs::SetString(const std::string& key, |
| 31 const std::string& value) { |
| 32 prefs_.SetValue(key, Value::CreateStringValue(value)); |
| 33 } |
| 34 |
| 35 void ServiceProcessPrefs::GetBoolean(const std::string& key, bool* result) { |
| 36 Value* value; |
| 37 if (prefs_.GetValue(key, &value) == PersistentPrefStore::READ_OK) |
| 38 value->GetAsBoolean(result); |
| 39 } |
| 40 |
| 41 void ServiceProcessPrefs::SetBoolean(const std::string& key, bool value) { |
| 42 prefs_.SetValue(key, Value::CreateBooleanValue(value)); |
| 43 } |
| 44 |
| 45 void ServiceProcessPrefs::GetDictionary(const std::string& key, |
| 46 DictionaryValue** result) { |
| 47 Value* value; |
| 48 if (prefs_.GetValue(key, &value) != PersistentPrefStore::READ_OK || |
| 49 !value->IsType(Value::TYPE_DICTIONARY)) { |
| 50 return; |
| 51 } |
| 52 |
| 53 *result = static_cast<DictionaryValue*>(value); |
| 54 } |
OLD | NEW |