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_PROTO_DATABASE_IMPL_H_ | 5 #ifndef COMPONENTS_LEVELDB_PROTO_PROTO_DATABASE_IMPL_H_ |
6 #define COMPONENTS_LEVELDB_PROTO_PROTO_DATABASE_IMPL_H_ | 6 #define COMPONENTS_LEVELDB_PROTO_PROTO_DATABASE_IMPL_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 T entry; | 174 T entry; |
175 if (!entry.ParseFromString(serialized_entry)) { | 175 if (!entry.ParseFromString(serialized_entry)) { |
176 DLOG(WARNING) << "Unable to parse leveldb_proto entry"; | 176 DLOG(WARNING) << "Unable to parse leveldb_proto entry"; |
177 // TODO(cjhopman): Decide what to do about un-parseable entries. | 177 // TODO(cjhopman): Decide what to do about un-parseable entries. |
178 } | 178 } |
179 | 179 |
180 entries->push_back(entry); | 180 entries->push_back(entry); |
181 } | 181 } |
182 } | 182 } |
183 | 183 |
184 void LoadKeysFromTaskRunner(LevelDB* database, | 184 inline void LoadKeysFromTaskRunner(LevelDB* database, |
185 std::vector<std::string>* keys, | 185 std::vector<std::string>* keys, |
186 bool* success) { | 186 bool* success) { |
187 DCHECK(success); | 187 DCHECK(success); |
188 DCHECK(keys); | 188 DCHECK(keys); |
189 keys->clear(); | 189 keys->clear(); |
190 *success = database->LoadKeys(keys); | 190 *success = database->LoadKeys(keys); |
191 } | 191 } |
192 | 192 |
193 template <typename T> | 193 template <typename T> |
194 void GetEntryFromTaskRunner(LevelDB* database, | 194 void GetEntryFromTaskRunner(LevelDB* database, |
195 const std::string& key, | 195 const std::string& key, |
196 T* entry, | 196 T* entry, |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 FROM_HERE, | 335 FROM_HERE, |
336 base::Bind(GetEntryFromTaskRunner<T>, base::Unretained(db_.get()), key, | 336 base::Bind(GetEntryFromTaskRunner<T>, base::Unretained(db_.get()), key, |
337 entry_ptr, found, success), | 337 entry_ptr, found, success), |
338 base::Bind(RunGetCallback<T>, callback, base::Owned(success), | 338 base::Bind(RunGetCallback<T>, callback, base::Owned(success), |
339 base::Owned(found), base::Passed(&entry))); | 339 base::Owned(found), base::Passed(&entry))); |
340 } | 340 } |
341 | 341 |
342 } // namespace leveldb_proto | 342 } // namespace leveldb_proto |
343 | 343 |
344 #endif // COMPONENTS_LEVELDB_PROTO_PROTO_DATABASE_IMPL_H_ | 344 #endif // COMPONENTS_LEVELDB_PROTO_PROTO_DATABASE_IMPL_H_ |
OLD | NEW |