| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_LEVELDB_PROTO_TESTING_FAKE_DB_H_ | 5 #ifndef COMPONENTS_LEVELDB_PROTO_TESTING_FAKE_DB_H_ |
| 6 #define COMPONENTS_LEVELDB_PROTO_TESTING_FAKE_DB_H_ | 6 #define COMPONENTS_LEVELDB_PROTO_TESTING_FAKE_DB_H_ |
| 7 | 7 |
| 8 #include <map> |
| 8 #include <memory> | 9 #include <memory> |
| 9 #include <string> | 10 #include <string> |
| 10 #include <utility> | 11 #include <utility> |
| 11 #include <vector> | 12 #include <vector> |
| 12 | 13 |
| 13 #include "base/bind.h" | 14 #include "base/bind.h" |
| 14 #include "base/callback.h" | 15 #include "base/callback.h" |
| 15 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
| 16 #include "components/leveldb_proto/proto_database.h" | 17 #include "components/leveldb_proto/proto_database.h" |
| 17 | 18 |
| 18 namespace leveldb_proto { | 19 namespace leveldb_proto { |
| 19 namespace test { | 20 namespace test { |
| 20 | 21 |
| 21 template <typename T> | 22 template <typename T> |
| 22 class FakeDB : public ProtoDatabase<T> { | 23 class FakeDB : public ProtoDatabase<T> { |
| 23 using Callback = base::Callback<void(bool)>; | 24 using Callback = base::Callback<void(bool)>; |
| 24 | 25 |
| 25 public: | 26 public: |
| 26 using EntryMap = typename base::hash_map<std::string, T>; | 27 using EntryMap = std::map<std::string, T>; |
| 27 | 28 |
| 28 explicit FakeDB(EntryMap* db); | 29 explicit FakeDB(EntryMap* db); |
| 29 ~FakeDB() override; | 30 ~FakeDB() override; |
| 30 | 31 |
| 31 // ProtoDatabase implementation. | 32 // ProtoDatabase implementation. |
| 32 void InitWithOptions( | 33 void InitWithOptions( |
| 33 const char* client_name, | 34 const char* client_name, |
| 34 const Options& options, | 35 const Options& options, |
| 35 const typename ProtoDatabase<T>::InitCallback& callback) override; | 36 const typename ProtoDatabase<T>::InitCallback& callback) override; |
| 36 void UpdateEntries( | 37 void UpdateEntries( |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 // static | 224 // static |
| 224 template <typename T> | 225 template <typename T> |
| 225 base::FilePath FakeDB<T>::DirectoryForTestDB() { | 226 base::FilePath FakeDB<T>::DirectoryForTestDB() { |
| 226 return base::FilePath(FILE_PATH_LITERAL("/fake/path")); | 227 return base::FilePath(FILE_PATH_LITERAL("/fake/path")); |
| 227 } | 228 } |
| 228 | 229 |
| 229 } // namespace test | 230 } // namespace test |
| 230 } // namespace leveldb_proto | 231 } // namespace leveldb_proto |
| 231 | 232 |
| 232 #endif // COMPONENTS_LEVELDB_PROTO_TESTING_FAKE_DB_H_ | 233 #endif // COMPONENTS_LEVELDB_PROTO_TESTING_FAKE_DB_H_ |
| OLD | NEW |