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_WIN_H_
6 #define THIRD_PARTY_LEVELDATABASE_ENV_CHROMIUM_WIN_H_
8 #include "env_chromium.h"
10 namespace leveldb_env {
12 leveldb::Status MakeIOErrorWin(leveldb::Slice filename,
13 const std::string& message,
17 class ChromiumWritableFileWin : public leveldb::WritableFile {
19 ChromiumWritableFileWin(const std::string& fname,
21 const UMALogger* uma_logger,
22 WriteTracker* tracker,
24 virtual ~ChromiumWritableFileWin();
25 virtual leveldb::Status Append(const leveldb::Slice& data);
26 virtual leveldb::Status Close();
27 virtual leveldb::Status Flush();
28 virtual leveldb::Status Sync();
36 leveldb::Status SyncParent();
38 std::string filename_;
40 const UMALogger* uma_logger_;
41 WriteTracker* tracker_;
43 std::string parent_dir_;
47 class ChromiumEnvWin : public ChromiumEnv {
50 virtual ~ChromiumEnvWin();
52 virtual leveldb::Status NewSequentialFile(const std::string& fname,
53 leveldb::SequentialFile** result);
54 virtual leveldb::Status NewRandomAccessFile(
55 const std::string& fname,
56 leveldb::RandomAccessFile** result);
57 virtual leveldb::Status NewWritableFile(const std::string& fname,
58 leveldb::WritableFile** result);
59 virtual leveldb::Status NewLogger(const std::string& fname,
60 leveldb::Logger** result);
63 virtual base::File::Error GetDirectoryEntries(
64 const base::FilePath& dir_param,
65 std::vector<base::FilePath>* result) const;
68 // BGThread() is the body of the background thread
70 static void BGThreadWrapper(void* arg) {
71 reinterpret_cast<ChromiumEnvWin*>(arg)->BGThread();
73 void RecordOpenFilesLimit(const std::string& type);
74 virtual void RecordOSError(MethodID method, DWORD err) const;
77 } // namespace leveldb_env