OLD | NEW |
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 CHROMEOS_PLATFORM_UPDATE_ENGINE_PREFS_H__ | 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_PREFS_H__ |
6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_PREFS_H__ | 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_PREFS_H__ |
7 | 7 |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "gtest/gtest_prod.h" // for FRIEND_TEST | 9 #include "gtest/gtest_prod.h" // for FRIEND_TEST |
10 #include "update_engine/prefs_interface.h" | 10 #include "update_engine/prefs_interface.h" |
11 | 11 |
12 namespace chromeos_update_engine { | 12 namespace chromeos_update_engine { |
13 | 13 |
14 // Implements a preference store by storing the value associated with | 14 // Implements a preference store by storing the value associated with |
15 // a key in a separate file named after the key under a preference | 15 // a key in a separate file named after the key under a preference |
16 // store directory. | 16 // store directory. |
17 | 17 |
18 class Prefs : public PrefsInterface { | 18 class Prefs : public PrefsInterface { |
19 public: | 19 public: |
| 20 Prefs() {} |
| 21 |
20 // Initializes the store by associating this object with |prefs_dir| | 22 // Initializes the store by associating this object with |prefs_dir| |
21 // as the preference store directory. Returns true on success, false | 23 // as the preference store directory. Returns true on success, false |
22 // otherwise. | 24 // otherwise. |
23 bool Init(const FilePath& prefs_dir); | 25 bool Init(const FilePath& prefs_dir); |
24 | 26 |
25 // PrefsInterface methods. | 27 // PrefsInterface methods. |
26 bool GetString(const std::string& key, std::string* value); | 28 bool GetString(const std::string& key, std::string* value); |
27 bool SetString(const std::string& key, const std::string& value); | 29 bool SetString(const std::string& key, const std::string& value); |
28 bool GetInt64(const std::string& key, int64_t* value); | 30 bool GetInt64(const std::string& key, int64_t* value); |
29 bool SetInt64(const std::string& key, const int64_t value); | 31 bool SetInt64(const std::string& key, const int64_t value); |
30 | 32 |
31 private: | 33 private: |
32 FRIEND_TEST(PrefsTest, GetFileNameForKey); | 34 FRIEND_TEST(PrefsTest, GetFileNameForKey); |
33 FRIEND_TEST(PrefsTest, GetFileNameForKeyBadCharacter); | 35 FRIEND_TEST(PrefsTest, GetFileNameForKeyBadCharacter); |
34 FRIEND_TEST(PrefsTest, GetFileNameForKeyEmpty); | 36 FRIEND_TEST(PrefsTest, GetFileNameForKeyEmpty); |
35 | 37 |
36 // Sets |filename| to the full path to the file containing the data | 38 // Sets |filename| to the full path to the file containing the data |
37 // associated with |key|. Returns true on success, false otherwise. | 39 // associated with |key|. Returns true on success, false otherwise. |
38 bool GetFileNameForKey(const std::string& key, FilePath* filename); | 40 bool GetFileNameForKey(const std::string& key, FilePath* filename); |
39 | 41 |
40 // Preference store directory. | 42 // Preference store directory. |
41 FilePath prefs_dir_; | 43 FilePath prefs_dir_; |
| 44 |
| 45 DISALLOW_COPY_AND_ASSIGN(Prefs); |
42 }; | 46 }; |
43 | 47 |
44 } // namespace chromeos_update_engine | 48 } // namespace chromeos_update_engine |
45 | 49 |
46 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_PREFS_H__ | 50 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_PREFS_H__ |
OLD | NEW |