Update V8 to version 4.6.62.
[chromium-blink-merge.git] / components / leveldb_proto / leveldb_database.h
blob67d07075ca93d4dd8731ae4047e32c83f55d4095
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_LEVELDB_DATABASE_H_
6 #define COMPONENTS_LEVELDB_PROTO_LEVELDB_DATABASE_H_
8 #include <string>
9 #include <vector>
11 #include "base/files/file_path.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/strings/string_split.h"
14 #include "base/threading/thread_collision_warner.h"
16 namespace leveldb {
17 class DB;
18 class Env;
19 struct Options;
20 } // namespace leveldb
22 namespace leveldb_proto {
24 // Interacts with the LevelDB third party module.
25 // Once constructed, function calls and destruction should all occur on the
26 // same thread (not necessarily the same as the constructor).
27 class LevelDB {
28 public:
29 LevelDB();
30 virtual ~LevelDB();
32 virtual bool InitWithOptions(const base::FilePath& database_dir,
33 const leveldb::Options& options);
34 virtual bool Init(const base::FilePath& database_dir);
35 virtual bool Save(const base::StringPairs& pairs_to_save,
36 const std::vector<std::string>& keys_to_remove);
37 virtual bool Load(std::vector<std::string>* entries);
39 private:
40 DFAKE_MUTEX(thread_checker_);
42 // The declaration order of these members matters: |db_| depends on |env_| and
43 // therefore has to be destructed first.
44 scoped_ptr<leveldb::Env> env_;
45 scoped_ptr<leveldb::DB> db_;
48 } // namespace leveldb_proto
50 #endif // COMPONENTS_LEVELDB_PROTO_LEVELDB_DATABASE_H_