#ifndef RLZ_CHROMEOS_LIB_RLZ_VALUE_STORE_CHROMEOS_H_
#define RLZ_CHROMEOS_LIB_RLZ_VALUE_STORE_CHROMEOS_H_
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include "base/files/file_path.h"
#include "base/sequence_checker.h"
#include "base/values.h"
#include "rlz/lib/rlz_value_store.h"
namespace rlz_lib {
class RlzValueStoreChromeOS : public RlzValueStore {
public:
static const int kMaxRetryCount;
explicit RlzValueStoreChromeOS(const base::FilePath& store_path);
RlzValueStoreChromeOS(const RlzValueStoreChromeOS&) = delete;
RlzValueStoreChromeOS& operator=(const RlzValueStoreChromeOS&) = delete;
~RlzValueStoreChromeOS() override;
bool HasAccess(AccessType type) override;
bool WritePingTime(Product product, int64_t time) override;
bool ReadPingTime(Product product, int64_t* time) override;
bool ClearPingTime(Product product) override;
bool WriteAccessPointRlz(AccessPoint access_point,
const char* new_rlz) override;
bool ReadAccessPointRlz(AccessPoint access_point,
char* rlz,
size_t rlz_size) override;
bool ClearAccessPointRlz(AccessPoint access_point) override;
bool UpdateExistingAccessPointRlz(const std::string& brand) override;
bool AddProductEvent(Product product, const char* event_rlz) override;
bool ReadProductEvents(Product product,
std::vector<std::string>* events) override;
bool ClearProductEvent(Product product, const char* event_rlz) override;
bool ClearAllProductEvents(Product product) override;
bool AddStatefulEvent(Product product, const char* event_rlz) override;
bool IsStatefulEvent(Product product, const char* event_rlz) override;
bool ClearAllStatefulEvents(Product product) override;
void CollectGarbage() override;
private:
static bool HasRlzEmbargoEndDatePassed();
void ReadStore();
void WriteStore();
bool AddValueToList(const std::string& list_name, base::Value value);
bool RemoveValueFromList(const std::string& list_name,
const base::Value& value);
bool ListContainsValue(const std::string& list_name,
const base::Value& value) const;
bool HasAccessPointRlz(AccessPoint access_point) const;
base::Value::Dict rlz_store_;
base::FilePath store_path_;
bool read_only_ = true;
SEQUENCE_CHECKER(sequence_checker_);
};
}
#endif