Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_LEVELDB_PROTO_CORE_PROTO_DATABASE_H_ | |
| 6 #define COMPONENTS_LEVELDB_PROTO_CORE_PROTO_DATABASE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <utility> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/callback.h" | |
| 13 #include "base/files/file_path.h" | |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 | |
| 16 namespace leveldb_proto { | |
| 17 | |
| 18 // Interface for classes providing persistent storage of Protocol Buffer | |
| 19 // entries (T must be a Proto type extending MessageLite). | |
| 20 template <typename T> | |
| 21 class ProtoDatabase { | |
| 22 public: | |
| 23 typedef base::Callback<void(bool success)> InitCallback; | |
| 24 typedef base::Callback<void(bool success)> UpdateCallback; | |
| 25 typedef base::Callback<void(bool success, scoped_ptr<std::vector<T> >)> | |
| 26 LoadCallback; | |
| 27 // A list of key-value (string, T) tuples. | |
| 28 typedef std::vector<std::pair<std::string, T> > KeyEntryVector; | |
| 29 | |
| 30 virtual ~ProtoDatabase() {} | |
| 31 | |
| 32 // Asynchronously initializes the object. |callback| will be invoked on the UI | |
|
cjhopman
2014/06/13 19:41:05
s/UI/calling
and below, too
Mathieu
2014/06/13 22:07:07
Done.
| |
| 33 // thread when complete. | |
| 34 virtual void Init(const base::FilePath& database_dir, | |
| 35 InitCallback callback) = 0; | |
| 36 | |
| 37 // Asynchronously saves |entries_to_save| and deletes entries from | |
| 38 // |keys_to_remove| from the database. |callback| will be invoked on the UI | |
| 39 // thread when complete. | |
| 40 virtual void UpdateEntries( | |
| 41 scoped_ptr<KeyEntryVector> entries_to_save, | |
| 42 scoped_ptr<std::vector<std::string> > keys_to_remove, | |
| 43 UpdateCallback callback) = 0; | |
| 44 | |
| 45 // Asynchronously loads all entries from the database and invokes |callback| | |
| 46 // when complete. | |
| 47 virtual void LoadEntries(LoadCallback callback) = 0; | |
| 48 }; | |
| 49 | |
| 50 } // namespace leveldb_proto | |
| 51 | |
| 52 #endif // COMPONENTS_LEVELDB_PROTO_CORE_PROTO_DATABASE_H_ | |
| OLD | NEW |