Darin Petkov | 4f0a07b | 2011-05-25 16:47:20 -0700 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
Darin Petkov | 3003059 | 2010-07-27 13:53:20 -0700 | [diff] [blame] | 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_INTERFACE_H__ |
| 6 | #define CHROMEOS_PLATFORM_UPDATE_ENGINE_PREFS_INTERFACE_H__ |
| 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | namespace chromeos_update_engine { |
| 11 | |
Bruno Rocha | 7f9aea2 | 2011-09-12 14:31:24 -0700 | [diff] [blame] | 12 | extern const char kPrefsCertificateReportToSendDownload[]; |
| 13 | extern const char kPrefsCertificateReportToSendUpdate[]; |
Darin Petkov | 3627577 | 2010-10-01 11:40:57 -0700 | [diff] [blame] | 14 | extern const char kPrefsDeltaUpdateFailures[]; |
Darin Petkov | 1cbd78f | 2010-07-29 12:38:34 -0700 | [diff] [blame] | 15 | extern const char kPrefsLastActivePingDay[]; |
| 16 | extern const char kPrefsLastRollCallPingDay[]; |
Darin Petkov | 73058b4 | 2010-10-06 16:32:19 -0700 | [diff] [blame] | 17 | extern const char kPrefsManifestMetadataSize[]; |
Darin Petkov | 95508da | 2011-01-05 12:42:29 -0800 | [diff] [blame] | 18 | extern const char kPrefsPreviousVersion[]; |
Darin Petkov | 6142614 | 2010-10-08 11:04:55 -0700 | [diff] [blame] | 19 | extern const char kPrefsResumedUpdateFailures[]; |
Darin Petkov | 73058b4 | 2010-10-06 16:32:19 -0700 | [diff] [blame] | 20 | extern const char kPrefsUpdateCheckResponseHash[]; |
Bruno Rocha | 7f9aea2 | 2011-09-12 14:31:24 -0700 | [diff] [blame] | 21 | extern const char kPrefsUpdateServerCertificate[]; |
Darin Petkov | 73058b4 | 2010-10-06 16:32:19 -0700 | [diff] [blame] | 22 | extern const char kPrefsUpdateStateNextDataOffset[]; |
| 23 | extern const char kPrefsUpdateStateNextOperation[]; |
Darin Petkov | 437adc4 | 2010-10-07 13:12:24 -0700 | [diff] [blame] | 24 | extern const char kPrefsUpdateStateSHA256Context[]; |
Darin Petkov | 4f0a07b | 2011-05-25 16:47:20 -0700 | [diff] [blame] | 25 | extern const char kPrefsUpdateStateSignatureBlob[]; |
Darin Petkov | 73058b4 | 2010-10-06 16:32:19 -0700 | [diff] [blame] | 26 | extern const char kPrefsUpdateStateSignedSHA256Context[]; |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 27 | extern const char kPrefsUpdateCheckCount[]; |
| 28 | extern const char kPrefsWallClockWaitPeriod[]; |
Jay Srinivasan | 34b5d86 | 2012-07-23 11:43:22 -0700 | [diff] [blame] | 29 | extern const char kPrefsUpdateFirstSeenAt[]; |
Darin Petkov | 1cbd78f | 2010-07-29 12:38:34 -0700 | [diff] [blame] | 30 | |
Darin Petkov | 3003059 | 2010-07-27 13:53:20 -0700 | [diff] [blame] | 31 | // The prefs interface allows access to a persistent preferences |
| 32 | // store. The two reasons for providing this as an interface are |
| 33 | // testing as well as easier switching to a new implementation in the |
| 34 | // future, if necessary. |
| 35 | |
| 36 | class PrefsInterface { |
| 37 | public: |
| 38 | // Gets a string |value| associated with |key|. Returns true on |
| 39 | // success, false on failure (including when the |key| is not |
| 40 | // present in the store). |
| 41 | virtual bool GetString(const std::string& key, std::string* value) = 0; |
| 42 | |
| 43 | // Associates |key| with a string |value|. Returns true on success, |
| 44 | // false otherwise. |
| 45 | virtual bool SetString(const std::string& key, const std::string& value) = 0; |
| 46 | |
| 47 | // Gets an int64 |value| associated with |key|. Returns true on |
| 48 | // success, false on failure (including when the |key| is not |
| 49 | // present in the store). |
| 50 | virtual bool GetInt64(const std::string& key, int64_t* value) = 0; |
| 51 | |
| 52 | // Associates |key| with an int64 |value|. Returns true on success, |
| 53 | // false otherwise. |
| 54 | virtual bool SetInt64(const std::string& key, const int64_t value) = 0; |
Darin Petkov | 1cbd78f | 2010-07-29 12:38:34 -0700 | [diff] [blame] | 55 | |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 56 | // Returns true if the setting exists (i.e. a file with the given key |
| 57 | // exists in the prefs directory) |
| 58 | virtual bool Exists(const std::string& key) = 0; |
| 59 | |
| 60 | // Returns true if successfully deleted the file corresponding to |
| 61 | // this key. Calling with non-existent keys does nothing. |
| 62 | virtual bool Delete(const std::string& key) = 0; |
| 63 | |
Darin Petkov | 1cbd78f | 2010-07-29 12:38:34 -0700 | [diff] [blame] | 64 | virtual ~PrefsInterface() {} |
Darin Petkov | 3003059 | 2010-07-27 13:53:20 -0700 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | } // namespace chromeos_update_engine |
| 68 | |
| 69 | #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_PREFS_INTERFACE_H__ |