1 // Copyright (c) 2013 The LevelDB 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. See the AUTHORS file for names of contributors.
5 #ifndef THIRD_PARTY_LEVELDATABASE_ENV_CHROMIUM_STDIO_H_
6 #define THIRD_PARTY_LEVELDATABASE_ENV_CHROMIUM_STDIO_H_
8 #include "env_chromium.h"
10 namespace leveldb_env
{
12 class ChromiumWritableFile
: public leveldb::WritableFile
{
14 ChromiumWritableFile(const std::string
& fname
,
16 const UMALogger
* uma_logger
,
17 WriteTracker
* tracker
,
19 virtual ~ChromiumWritableFile();
20 virtual leveldb::Status
Append(const leveldb::Slice
& data
);
21 virtual leveldb::Status
Close();
22 virtual leveldb::Status
Flush();
23 virtual leveldb::Status
Sync();
31 leveldb::Status
SyncParent();
33 std::string filename_
;
35 const UMALogger
* uma_logger_
;
36 WriteTracker
* tracker_
;
38 std::string parent_dir_
;
42 class ChromiumEnvStdio
: public ChromiumEnv
{
45 virtual ~ChromiumEnvStdio();
47 virtual leveldb::Status
NewSequentialFile(const std::string
& fname
,
48 leveldb::SequentialFile
** result
);
49 virtual leveldb::Status
NewRandomAccessFile(
50 const std::string
& fname
,
51 leveldb::RandomAccessFile
** result
);
52 virtual leveldb::Status
NewWritableFile(const std::string
& fname
,
53 leveldb::WritableFile
** result
);
54 virtual leveldb::Status
NewLogger(const std::string
& fname
,
55 leveldb::Logger
** result
);
58 virtual base::File::Error
GetDirectoryEntries(
59 const base::FilePath
& dir_param
,
60 std::vector
<base::FilePath
>* result
) const;
63 // BGThread() is the body of the background thread
65 static void BGThreadWrapper(void* arg
) {
66 reinterpret_cast<ChromiumEnvStdio
*>(arg
)->BGThread();
68 void RecordOpenFilesLimit(const std::string
& type
);
71 } // namespace leveldb_env