| 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 } | 257 } |
| 258 | 258 |
| 259 template <typename T> | 259 template <typename T> |
| 260 void ProtoDatabaseImpl<T>::InitWithDatabase( | 260 void ProtoDatabaseImpl<T>::InitWithDatabase( |
| 261 std::unique_ptr<LevelDB> database, | 261 std::unique_ptr<LevelDB> database, |
| 262 const base::FilePath& database_dir, | 262 const base::FilePath& database_dir, |
| 263 const typename ProtoDatabase<T>::InitCallback& callback) { | 263 const typename ProtoDatabase<T>::InitCallback& callback) { |
| 264 DCHECK(thread_checker_.CalledOnValidThread()); | 264 DCHECK(thread_checker_.CalledOnValidThread()); |
| 265 DCHECK(!db_); | 265 DCHECK(!db_); |
| 266 DCHECK(database); | 266 DCHECK(database); |
| 267 db_.reset(database.release()); | 267 db_ = std::move(database); |
| 268 bool* success = new bool(false); | 268 bool* success = new bool(false); |
| 269 task_runner_->PostTaskAndReply( | 269 task_runner_->PostTaskAndReply( |
| 270 FROM_HERE, base::Bind(InitFromTaskRunner, base::Unretained(db_.get()), | 270 FROM_HERE, base::Bind(InitFromTaskRunner, base::Unretained(db_.get()), |
| 271 database_dir, success), | 271 database_dir, success), |
| 272 base::Bind(RunInitCallback<T>, callback, base::Owned(success))); | 272 base::Bind(RunInitCallback<T>, callback, base::Owned(success))); |
| 273 } | 273 } |
| 274 | 274 |
| 275 template <typename T> | 275 template <typename T> |
| 276 void ProtoDatabaseImpl<T>::UpdateEntries( | 276 void ProtoDatabaseImpl<T>::UpdateEntries( |
| 277 std::unique_ptr<typename ProtoDatabase<T>::KeyEntryVector> entries_to_save, | 277 std::unique_ptr<typename ProtoDatabase<T>::KeyEntryVector> entries_to_save, |
| (...skipping 57 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 |