#ifndef CHROME_BROWSER_COMPONENT_UPDATER_METADATA_TABLE_CHROMEOS_H_
#define CHROME_BROWSER_COMPONENT_UPDATER_METADATA_TABLE_CHROMEOS_H_
#include <memory>
#include <string>
#include "base/gtest_prod_util.h"
#include "base/memory/raw_ptr.h"
#include "base/values.h"
class PrefRegistrySimple;
class PrefService;
namespace component_updater {
class MetadataTable {
public:
explicit MetadataTable(PrefService* pref_service);
MetadataTable(const MetadataTable&) = delete;
MetadataTable& operator=(const MetadataTable&) = delete;
~MetadataTable();
static std::unique_ptr<component_updater::MetadataTable> CreateForTest();
static void RegisterPrefs(PrefRegistrySimple* registry);
bool AddComponentForCurrentUser(const std::string& component_name);
bool DeleteComponentForCurrentUser(const std::string& component_name);
bool HasComponentForAnyUser(const std::string& component_name) const;
private:
FRIEND_TEST_ALL_PREFIXES(CrOSComponentInstallerMetadataTest, Add);
FRIEND_TEST_ALL_PREFIXES(CrOSComponentInstallerMetadataTest, Delete);
MetadataTable();
void Load();
void Store();
void AddItem(const std::string& hashed_user_id,
const std::string& component_name);
bool DeleteItem(const std::string& hashed_user_id,
const std::string& component_name);
bool HasComponentForUser(const std::string& hashed_user_id,
const std::string& component_name) const;
size_t GetInstalledItemIndex(const std::string& hashed_user_id,
const std::string& component_name) const;
base::Value::List installed_items_;
const raw_ptr<PrefService> pref_service_;
};
}
#endif