Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: components/leveldb_proto/proto_database.h

Issue 330833002: Extract protobuf database into a new 'leveldb_proto' component (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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_PROTO_DATABASE_H_
6 #define COMPONENTS_LEVELDB_PROTO_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
33 // calling 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
39 // calling 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_PROTO_DATABASE_H_
OLDNEW
« no previous file with comments | « components/leveldb_proto/leveldb_database.cc ('k') | components/leveldb_proto/proto_database_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698