| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "base/sequenced_task_runner.h" | 15 #include "base/sequenced_task_runner.h" |
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "base/threading/sequenced_worker_pool.h" | 17 #include "base/threading/sequenced_worker_pool.h" |
| 18 #include "base/threading/thread_checker.h" | 18 #include "base/threading/thread_checker.h" |
| 19 #include "base/strings/string_split.h" |
| 19 #include "components/leveldb_proto/leveldb_database.h" | 20 #include "components/leveldb_proto/leveldb_database.h" |
| 20 #include "components/leveldb_proto/proto_database.h" | 21 #include "components/leveldb_proto/proto_database.h" |
| 21 | 22 |
| 22 namespace leveldb_proto { | 23 namespace leveldb_proto { |
| 23 | 24 |
| 24 typedef std::vector<std::pair<std::string, std::string> > KeyValueVector; | 25 typedef base::StringPairs KeyValueVector; |
| 25 typedef std::vector<std::string> KeyVector; | 26 typedef std::vector<std::string> KeyVector; |
| 26 | 27 |
| 27 // When the ProtoDatabaseImpl instance is deleted, in-progress asynchronous | 28 // When the ProtoDatabaseImpl instance is deleted, in-progress asynchronous |
| 28 // operations will be completed and the corresponding callbacks will be called. | 29 // operations will be completed and the corresponding callbacks will be called. |
| 29 // Construction/calls/destruction should all happen on the same thread. | 30 // Construction/calls/destruction should all happen on the same thread. |
| 30 template <typename T> | 31 template <typename T> |
| 31 class ProtoDatabaseImpl : public ProtoDatabase<T> { | 32 class ProtoDatabaseImpl : public ProtoDatabase<T> { |
| 32 public: | 33 public: |
| 33 // All blocking calls/disk access will happen on the provided |task_runner|. | 34 // All blocking calls/disk access will happen on the provided |task_runner|. |
| 34 explicit ProtoDatabaseImpl( | 35 explicit ProtoDatabaseImpl( |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 task_runner_->PostTaskAndReply( | 196 task_runner_->PostTaskAndReply( |
| 196 FROM_HERE, base::Bind(LoadEntriesFromTaskRunner<T>, | 197 FROM_HERE, base::Bind(LoadEntriesFromTaskRunner<T>, |
| 197 base::Unretained(db_.get()), entries_ptr, success), | 198 base::Unretained(db_.get()), entries_ptr, success), |
| 198 base::Bind(RunLoadCallback<T>, callback, base::Owned(success), | 199 base::Bind(RunLoadCallback<T>, callback, base::Owned(success), |
| 199 base::Passed(&entries))); | 200 base::Passed(&entries))); |
| 200 } | 201 } |
| 201 | 202 |
| 202 } // namespace leveldb_proto | 203 } // namespace leveldb_proto |
| 203 | 204 |
| 204 #endif // COMPONENTS_LEVELDB_PROTO_PROTO_DATABASE_IMPL_H_ | 205 #endif // COMPONENTS_LEVELDB_PROTO_PROTO_DATABASE_IMPL_H_ |
| OLD | NEW |