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