blob: 14962dde934526a36f5eb5ae72b13d81f898a2a0 [file] [log] [blame]
Darin Petkov4f0a07b2011-05-25 16:47:20 -07001// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
Darin Petkov30030592010-07-27 13:53:20 -07002// 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
10namespace chromeos_update_engine {
11
Bruno Rocha7f9aea22011-09-12 14:31:24 -070012extern const char kPrefsCertificateReportToSendDownload[];
13extern const char kPrefsCertificateReportToSendUpdate[];
Darin Petkov36275772010-10-01 11:40:57 -070014extern const char kPrefsDeltaUpdateFailures[];
Darin Petkov1cbd78f2010-07-29 12:38:34 -070015extern const char kPrefsLastActivePingDay[];
16extern const char kPrefsLastRollCallPingDay[];
Darin Petkov73058b42010-10-06 16:32:19 -070017extern const char kPrefsManifestMetadataSize[];
Darin Petkov95508da2011-01-05 12:42:29 -080018extern const char kPrefsPreviousVersion[];
Darin Petkov61426142010-10-08 11:04:55 -070019extern const char kPrefsResumedUpdateFailures[];
Darin Petkov73058b42010-10-06 16:32:19 -070020extern const char kPrefsUpdateCheckResponseHash[];
Bruno Rocha7f9aea22011-09-12 14:31:24 -070021extern const char kPrefsUpdateServerCertificate[];
Darin Petkov73058b42010-10-06 16:32:19 -070022extern const char kPrefsUpdateStateNextDataOffset[];
23extern const char kPrefsUpdateStateNextOperation[];
Darin Petkov437adc42010-10-07 13:12:24 -070024extern const char kPrefsUpdateStateSHA256Context[];
Darin Petkov4f0a07b2011-05-25 16:47:20 -070025extern const char kPrefsUpdateStateSignatureBlob[];
Darin Petkov73058b42010-10-06 16:32:19 -070026extern const char kPrefsUpdateStateSignedSHA256Context[];
Jay Srinivasan480ddfa2012-06-01 19:15:26 -070027extern const char kPrefsUpdateCheckCount[];
28extern const char kPrefsWallClockWaitPeriod[];
Jay Srinivasan34b5d862012-07-23 11:43:22 -070029extern const char kPrefsUpdateFirstSeenAt[];
Jay Srinivasan2b5a0f02012-12-19 17:25:56 -080030extern const char kPrefsPayloadAttemptNumber[];
Jay Srinivasan08262882012-12-28 19:29:43 -080031extern const char kPrefsCurrentResponseSignature[];
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080032extern const char kPrefsCurrentUrlIndex[];
Jay Srinivasan2b5a0f02012-12-19 17:25:56 -080033extern const char kPrefsCurrentUrlFailureCount[];
Jay Srinivasan08262882012-12-28 19:29:43 -080034extern const char kPrefsBackoffExpiryTime[];
Darin Petkov1cbd78f2010-07-29 12:38:34 -070035
Darin Petkov30030592010-07-27 13:53:20 -070036// The prefs interface allows access to a persistent preferences
37// store. The two reasons for providing this as an interface are
38// testing as well as easier switching to a new implementation in the
39// future, if necessary.
40
41class PrefsInterface {
42 public:
43 // Gets a string |value| associated with |key|. Returns true on
44 // success, false on failure (including when the |key| is not
45 // present in the store).
46 virtual bool GetString(const std::string& key, std::string* value) = 0;
47
48 // Associates |key| with a string |value|. Returns true on success,
49 // false otherwise.
50 virtual bool SetString(const std::string& key, const std::string& value) = 0;
51
52 // Gets an int64 |value| associated with |key|. Returns true on
53 // success, false on failure (including when the |key| is not
54 // present in the store).
55 virtual bool GetInt64(const std::string& key, int64_t* value) = 0;
56
57 // Associates |key| with an int64 |value|. Returns true on success,
58 // false otherwise.
59 virtual bool SetInt64(const std::string& key, const int64_t value) = 0;
Darin Petkov1cbd78f2010-07-29 12:38:34 -070060
Jay Srinivasan480ddfa2012-06-01 19:15:26 -070061 // Returns true if the setting exists (i.e. a file with the given key
62 // exists in the prefs directory)
63 virtual bool Exists(const std::string& key) = 0;
64
65 // Returns true if successfully deleted the file corresponding to
66 // this key. Calling with non-existent keys does nothing.
67 virtual bool Delete(const std::string& key) = 0;
68
Darin Petkov1cbd78f2010-07-29 12:38:34 -070069 virtual ~PrefsInterface() {}
Darin Petkov30030592010-07-27 13:53:20 -070070};
71
72} // namespace chromeos_update_engine
73
74#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_PREFS_INTERFACE_H__