| Index: components/leveldb_proto/testing/fake_db.h
|
| diff --git a/components/leveldb_proto/testing/fake_db.h b/components/leveldb_proto/testing/fake_db.h
|
| index 4ff6b43ca1bbce349f7da07d1a8266207eb1cbbd..e67ceba7a8ccc238a4af9027b91725ac297c2ac5 100644
|
| --- a/components/leveldb_proto/testing/fake_db.h
|
| +++ b/components/leveldb_proto/testing/fake_db.h
|
| @@ -39,6 +39,9 @@ class FakeDB : public ProtoDatabase<T> {
|
| const typename ProtoDatabase<T>::UpdateCallback& callback) override;
|
| void LoadEntries(
|
| const typename ProtoDatabase<T>::LoadCallback& callback) override;
|
| + void GetEntry(
|
| + const std::string& key,
|
| + const typename ProtoDatabase<T>::GetCallback& callback) override;
|
| void Destroy(
|
| const typename ProtoDatabase<T>::DestroyCallback& callback) override;
|
|
|
| @@ -48,6 +51,8 @@ class FakeDB : public ProtoDatabase<T> {
|
|
|
| void LoadCallback(bool success);
|
|
|
| + void GetCallback(bool success);
|
| +
|
| void UpdateCallback(bool success);
|
|
|
| static base::FilePath DirectoryForTestDB();
|
| @@ -58,11 +63,17 @@ class FakeDB : public ProtoDatabase<T> {
|
| std::unique_ptr<typename std::vector<T>> entries,
|
| bool success);
|
|
|
| + static void RunGetCallback(
|
| + const typename ProtoDatabase<T>::GetCallback& callback,
|
| + std::unique_ptr<T> entry,
|
| + bool success);
|
| +
|
| base::FilePath dir_;
|
| EntryMap* db_;
|
|
|
| Callback init_callback_;
|
| Callback load_callback_;
|
| + Callback get_callback_;
|
| Callback update_callback_;
|
| };
|
|
|
| @@ -107,6 +118,18 @@ void FakeDB<T>::LoadEntries(
|
| }
|
|
|
| template <typename T>
|
| +void FakeDB<T>::GetEntry(
|
| + const std::string& key,
|
| + const typename ProtoDatabase<T>::GetCallback& callback) {
|
| + std::unique_ptr<T> entry;
|
| + auto it = db_->find(key);
|
| + if (it != db_->end())
|
| + entry.reset(new T(it->second));
|
| +
|
| + get_callback_ = base::Bind(RunGetCallback, callback, base::Passed(&entry));
|
| +}
|
| +
|
| +template <typename T>
|
| void FakeDB<T>::Destroy(
|
| const typename ProtoDatabase<T>::DestroyCallback& callback) {
|
| }
|
| @@ -129,6 +152,12 @@ void FakeDB<T>::LoadCallback(bool success) {
|
| }
|
|
|
| template <typename T>
|
| +void FakeDB<T>::GetCallback(bool success) {
|
| + get_callback_.Run(success);
|
| + get_callback_.Reset();
|
| +}
|
| +
|
| +template <typename T>
|
| void FakeDB<T>::UpdateCallback(bool success) {
|
| update_callback_.Run(success);
|
| update_callback_.Reset();
|
| @@ -145,6 +174,15 @@ void FakeDB<T>::RunLoadCallback(
|
|
|
| // static
|
| template <typename T>
|
| +void FakeDB<T>::RunGetCallback(
|
| + const typename ProtoDatabase<T>::GetCallback& callback,
|
| + std::unique_ptr<T> entry,
|
| + bool success) {
|
| + callback.Run(success, std::move(entry));
|
| +}
|
| +
|
| +// static
|
| +template <typename T>
|
| base::FilePath FakeDB<T>::DirectoryForTestDB() {
|
| return base::FilePath(FILE_PATH_LITERAL("/fake/path"));
|
| }
|
|
|