| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // ProtoDatabase implementation. | 30 // ProtoDatabase implementation. |
| 31 void Init(const char* client_name, | 31 void Init(const char* client_name, |
| 32 const base::FilePath& database_dir, | 32 const base::FilePath& database_dir, |
| 33 const typename ProtoDatabase<T>::InitCallback& callback) override; | 33 const typename ProtoDatabase<T>::InitCallback& callback) override; |
| 34 void UpdateEntries( | 34 void UpdateEntries( |
| 35 scoped_ptr<typename ProtoDatabase<T>::KeyEntryVector> entries_to_save, | 35 scoped_ptr<typename ProtoDatabase<T>::KeyEntryVector> entries_to_save, |
| 36 scoped_ptr<std::vector<std::string>> keys_to_remove, | 36 scoped_ptr<std::vector<std::string>> keys_to_remove, |
| 37 const typename ProtoDatabase<T>::UpdateCallback& callback) override; | 37 const typename ProtoDatabase<T>::UpdateCallback& callback) override; |
| 38 void LoadEntries( | 38 void LoadEntries( |
| 39 const typename ProtoDatabase<T>::LoadCallback& callback) override; | 39 const typename ProtoDatabase<T>::LoadCallback& callback) override; |
| 40 void Destroy( |
| 41 const typename ProtoDatabase<T>::DestroyCallback& callback) override; |
| 40 | 42 |
| 41 base::FilePath& GetDirectory(); | 43 base::FilePath& GetDirectory(); |
| 42 | 44 |
| 43 void InitCallback(bool success); | 45 void InitCallback(bool success); |
| 44 | 46 |
| 45 void LoadCallback(bool success); | 47 void LoadCallback(bool success); |
| 46 | 48 |
| 47 void UpdateCallback(bool success); | 49 void UpdateCallback(bool success); |
| 48 | 50 |
| 49 static base::FilePath DirectoryForTestDB(); | 51 static base::FilePath DirectoryForTestDB(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 const typename ProtoDatabase<T>::LoadCallback& callback) { | 98 const typename ProtoDatabase<T>::LoadCallback& callback) { |
| 97 scoped_ptr<std::vector<T>> entries(new std::vector<T>()); | 99 scoped_ptr<std::vector<T>> entries(new std::vector<T>()); |
| 98 for (const auto& pair : *db_) | 100 for (const auto& pair : *db_) |
| 99 entries->push_back(pair.second); | 101 entries->push_back(pair.second); |
| 100 | 102 |
| 101 load_callback_ = | 103 load_callback_ = |
| 102 base::Bind(RunLoadCallback, callback, base::Passed(&entries)); | 104 base::Bind(RunLoadCallback, callback, base::Passed(&entries)); |
| 103 } | 105 } |
| 104 | 106 |
| 105 template <typename T> | 107 template <typename T> |
| 108 void FakeDB<T>::Destroy( |
| 109 const typename ProtoDatabase<T>::DestroyCallback& callback) { |
| 110 } |
| 111 |
| 112 template <typename T> |
| 106 base::FilePath& FakeDB<T>::GetDirectory() { | 113 base::FilePath& FakeDB<T>::GetDirectory() { |
| 107 return dir_; | 114 return dir_; |
| 108 } | 115 } |
| 109 | 116 |
| 110 template <typename T> | 117 template <typename T> |
| 111 void FakeDB<T>::InitCallback(bool success) { | 118 void FakeDB<T>::InitCallback(bool success) { |
| 112 init_callback_.Run(success); | 119 init_callback_.Run(success); |
| 113 init_callback_.Reset(); | 120 init_callback_.Reset(); |
| 114 } | 121 } |
| 115 | 122 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 137 // static | 144 // static |
| 138 template <typename T> | 145 template <typename T> |
| 139 base::FilePath FakeDB<T>::DirectoryForTestDB() { | 146 base::FilePath FakeDB<T>::DirectoryForTestDB() { |
| 140 return base::FilePath(FILE_PATH_LITERAL("/fake/path")); | 147 return base::FilePath(FILE_PATH_LITERAL("/fake/path")); |
| 141 } | 148 } |
| 142 | 149 |
| 143 } // namespace test | 150 } // namespace test |
| 144 } // namespace leveldb_proto | 151 } // namespace leveldb_proto |
| 145 | 152 |
| 146 #endif // COMPONENTS_LEVELDB_PROTO_TESTING_FAKE_DB_H_ | 153 #endif // COMPONENTS_LEVELDB_PROTO_TESTING_FAKE_DB_H_ |
| OLD | NEW |