| OLD | NEW |
| 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 #ifndef CHROME_SERVICE_SERVICE_PROCESS_PREFS_H_ | 5 #ifndef CHROME_SERVICE_SERVICE_PROCESS_PREFS_H_ |
| 6 #define CHROME_SERVICE_SERVICE_PROCESS_PREFS_H_ | 6 #define CHROME_SERVICE_SERVICE_PROCESS_PREFS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "chrome/common/json_pref_store.h" | 10 #include "chrome/common/json_pref_store.h" |
| 11 | 11 |
| 12 namespace base { | 12 namespace base { |
| 13 class DictionaryValue; | 13 class DictionaryValue; |
| 14 class ListValue; |
| 14 } | 15 } |
| 15 | 16 |
| 16 // Manages persistent preferences for the service process. This is basically a | 17 // Manages persistent preferences for the service process. This is basically a |
| 17 // thin wrapper around JsonPrefStore for more comfortable use. | 18 // thin wrapper around JsonPrefStore for more comfortable use. |
| 18 class ServiceProcessPrefs { | 19 class ServiceProcessPrefs { |
| 19 public: | 20 public: |
| 20 // |file_message_loop_proxy| is the MessageLoopProxy for a thread on which | 21 // |file_message_loop_proxy| is the MessageLoopProxy for a thread on which |
| 21 // file I/O can be done. | 22 // file I/O can be done. |
| 22 ServiceProcessPrefs(const FilePath& pref_filename, | 23 ServiceProcessPrefs(const FilePath& pref_filename, |
| 23 base::MessageLoopProxy* file_message_loop_proxy); | 24 base::MessageLoopProxy* file_message_loop_proxy); |
| 24 ~ServiceProcessPrefs(); | 25 ~ServiceProcessPrefs(); |
| 25 | 26 |
| 26 // Read preferences from the backing file. | 27 // Read preferences from the backing file. |
| 27 void ReadPrefs(); | 28 void ReadPrefs(); |
| 28 | 29 |
| 29 // Write the data to the backing file. | 30 // Write the data to the backing file. |
| 30 void WritePrefs(); | 31 void WritePrefs(); |
| 31 | 32 |
| 32 // Get a string preference for |key| and store it in |result|. | 33 // Returns a string preference for |key|. |
| 33 void GetString(const std::string& key, std::string* result) const; | 34 std::string GetString(const std::string& key, |
| 35 const std::string& default_value) const; |
| 34 | 36 |
| 35 // Set a string |value| for |key|. | 37 // Set a string |value| for |key|. |
| 36 void SetString(const std::string& key, const std::string& value); | 38 void SetString(const std::string& key, const std::string& value); |
| 37 | 39 |
| 38 // Get a boolean preference for |key| and store it in |result|. | 40 // Returns a boolean preference for |key|. |
| 39 void GetBoolean(const std::string& key, bool* result) const; | 41 bool GetBoolean(const std::string& key, bool default_value) const; |
| 40 | 42 |
| 41 // Set a boolean |value| for |key|. | 43 // Set a boolean |value| for |key|. |
| 42 void SetBoolean(const std::string& key, bool value); | 44 void SetBoolean(const std::string& key, bool value); |
| 43 | 45 |
| 44 // Get a dictionary preference for |key| and store it in |result|. | 46 // Returns a dictionary preference for |key|. |
| 45 void GetDictionary(const std::string& key, | 47 const base::DictionaryValue* GetDictionary(const std::string& key) const; |
| 46 const base::DictionaryValue** result) const; | 48 |
| 49 // Returns a list for |key|. |
| 50 const base::ListValue* GetList(const std::string& key) const; |
| 47 | 51 |
| 48 // Removes the pref specified by |key|. | 52 // Removes the pref specified by |key|. |
| 49 void RemovePref(const std::string& key); | 53 void RemovePref(const std::string& key); |
| 50 | 54 |
| 51 private: | 55 private: |
| 52 scoped_refptr<JsonPrefStore> prefs_; | 56 scoped_refptr<JsonPrefStore> prefs_; |
| 53 | 57 |
| 54 DISALLOW_COPY_AND_ASSIGN(ServiceProcessPrefs); | 58 DISALLOW_COPY_AND_ASSIGN(ServiceProcessPrefs); |
| 55 }; | 59 }; |
| 56 | 60 |
| 57 #endif // CHROME_SERVICE_SERVICE_PROCESS_PREFS_H_ | 61 #endif // CHROME_SERVICE_SERVICE_PROCESS_PREFS_H_ |
| OLD | NEW |