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_
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"
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).
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
);
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_