OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "chrome/common/json_pref_store.h" | 11 #include "chrome/common/json_pref_store.h" |
12 | 12 |
13 // Manages persistent preferences for the service process. This is basically a | 13 // Manages persistent preferences for the service process. This is basically a |
14 // thin wrapper around JsonPrefStore for more comfortable use. | 14 // thin wrapper around JsonPrefStore for more comfortable use. |
15 class ServiceProcessPrefs { | 15 class ServiceProcessPrefs { |
16 public: | 16 public: |
17 // |file_message_loop_proxy| is the MessageLoopProxy for a thread on which | 17 // |file_message_loop_proxy| is the MessageLoopProxy for a thread on which |
18 // file I/O can be done. | 18 // file I/O can be done. |
19 ServiceProcessPrefs(const FilePath& pref_filename, | 19 ServiceProcessPrefs(const FilePath& pref_filename, |
20 base::MessageLoopProxy* file_message_loop_proxy); | 20 base::MessageLoopProxy* file_message_loop_proxy); |
| 21 ~ServiceProcessPrefs(); |
21 | 22 |
22 // Read preferences from the backing file. | 23 // Read preferences from the backing file. |
23 void ReadPrefs(); | 24 void ReadPrefs(); |
24 | 25 |
25 // Write the data to the backing file. | 26 // Write the data to the backing file. |
26 void WritePrefs(); | 27 void WritePrefs(); |
27 | 28 |
28 // Get a string preference for |key| and store it in |result|. | 29 // Get a string preference for |key| and store it in |result|. |
29 void GetString(const std::string& key, std::string* result); | 30 void GetString(const std::string& key, std::string* result); |
30 | 31 |
31 // Set a string |value| for |key|. | 32 // Set a string |value| for |key|. |
32 void SetString(const std::string& key, const std::string& value); | 33 void SetString(const std::string& key, const std::string& value); |
33 | 34 |
34 // Get a boolean preference for |key| and store it in |result|. | 35 // Get a boolean preference for |key| and store it in |result|. |
35 void GetBoolean(const std::string& key, bool* result); | 36 void GetBoolean(const std::string& key, bool* result); |
36 | 37 |
37 // Set a boolean |value| for |key|. | 38 // Set a boolean |value| for |key|. |
38 void SetBoolean(const std::string& key, bool value); | 39 void SetBoolean(const std::string& key, bool value); |
39 | 40 |
40 // Get a dictionary preference for |key| and store it in |result|. | 41 // Get a dictionary preference for |key| and store it in |result|. |
41 void GetDictionary(const std::string& key, DictionaryValue** result); | 42 void GetDictionary(const std::string& key, DictionaryValue** result); |
42 | 43 |
43 private: | 44 private: |
44 scoped_refptr<JsonPrefStore> prefs_; | 45 scoped_refptr<JsonPrefStore> prefs_; |
45 | 46 |
46 DISALLOW_COPY_AND_ASSIGN(ServiceProcessPrefs); | 47 DISALLOW_COPY_AND_ASSIGN(ServiceProcessPrefs); |
47 }; | 48 }; |
48 | 49 |
49 #endif // CHROME_SERVICE_SERVICE_PROCESS_PREFS_H_ | 50 #endif // CHROME_SERVICE_SERVICE_PROCESS_PREFS_H_ |
OLD | NEW |