#ifndef THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_STORAGE_IMPL_H_
#define THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_STORAGE_IMPL_H_
#include <memory>
#include <string>
#include <vector>
#include "base/scoped_observation.h"
#include "components/prefs/pref_store.h"
#include "third_party/libaddressinput/src/cpp/include/libaddressinput/storage.h"
class WriteablePrefStore;
namespace autofill {
class ChromeStorageImpl : public ::i18n::addressinput::Storage,
public PrefStore::Observer {
public:
explicit ChromeStorageImpl(WriteablePrefStore* store);
ChromeStorageImpl(const ChromeStorageImpl&) = delete;
ChromeStorageImpl& operator=(const ChromeStorageImpl&) = delete;
virtual ~ChromeStorageImpl();
virtual void Put(const std::string& key, std::string* data) override;
virtual void Get(const std::string& key, const Callback& data_ready)
const override;
virtual void OnPrefValueChanged(const std::string& key) override;
virtual void OnInitializationCompleted(bool succeeded) override;
private:
struct Request {
Request(const std::string& key, const Callback& callback);
std::string key;
const Callback& callback;
};
void DoGet(const std::string& key, const Callback& data_ready);
WriteablePrefStore* backing_store_;
std::vector<std::unique_ptr<Request>> outstanding_requests_;
base::ScopedObservation<PrefStore, PrefStore::Observer> scoped_observation_{
this};
};
}
#endif