Non-SFI mode: Clean up macros of base/ and ipc/ libraries for nacl_helper_nonsfi.
[chromium-blink-merge.git] / components / leveldb_proto / proto_database.h
blob34ee799eb1f1d3734c89bf034a9cb28a082627ce
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.
5 #ifndef COMPONENTS_LEVELDB_PROTO_PROTO_DATABASE_H_
6 #define COMPONENTS_LEVELDB_PROTO_PROTO_DATABASE_H_
8 #include <string>
9 #include <utility>
10 #include <vector>
12 #include "base/callback.h"
13 #include "base/files/file_path.h"
14 #include "base/memory/scoped_ptr.h"
16 namespace leveldb_proto {
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;
30 virtual ~ProtoDatabase() {}
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;
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;
45 // Asynchronously loads all entries from the database and invokes |callback|
46 // when complete.
47 virtual void LoadEntries(LoadCallback callback) = 0;
50 } // namespace leveldb_proto
52 #endif // COMPONENTS_LEVELDB_PROTO_PROTO_DATABASE_H_