Move content_settings_pattern and content_settings_pattern_parser to the content_sett...
[chromium-blink-merge.git] / third_party / leveldatabase / env_chromium_win.h
blobdcd308afa2359817929aa757f8d14cef2b0a4b8c
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 <string>
9 #include <vector>
11 #include "third_party/leveldatabase/env_chromium.h"
13 namespace leveldb_env {
15 leveldb::Status MakeIOErrorWin(leveldb::Slice filename,
16 const std::string& message,
17 MethodID method,
18 DWORD err);
20 class ChromiumWritableFileWin : public leveldb::WritableFile {
21 public:
22 ChromiumWritableFileWin(const std::string& fname,
23 HANDLE f,
24 const UMALogger* uma_logger,
25 WriteTracker* tracker,
26 bool make_backup);
27 virtual ~ChromiumWritableFileWin();
28 virtual leveldb::Status Append(const leveldb::Slice& data);
29 virtual leveldb::Status Close();
30 virtual leveldb::Status Flush();
31 virtual leveldb::Status Sync();
33 private:
34 enum Type {
35 kManifest,
36 kTable,
37 kOther
39 leveldb::Status SyncParent();
41 std::string filename_;
42 HANDLE file_;
43 const UMALogger* uma_logger_;
44 WriteTracker* tracker_;
45 Type file_type_;
46 std::string parent_dir_;
47 bool make_backup_;
50 class ChromiumEnvWin : public ChromiumEnv {
51 public:
52 ChromiumEnvWin();
53 virtual ~ChromiumEnvWin();
55 virtual leveldb::Status NewSequentialFile(const std::string& fname,
56 leveldb::SequentialFile** result);
57 virtual leveldb::Status NewRandomAccessFile(
58 const std::string& fname,
59 leveldb::RandomAccessFile** result);
60 virtual leveldb::Status NewWritableFile(const std::string& fname,
61 leveldb::WritableFile** result);
62 virtual leveldb::Status NewLogger(const std::string& fname,
63 leveldb::Logger** result);
65 protected:
66 virtual base::File::Error GetDirectoryEntries(
67 const base::FilePath& dir_param,
68 std::vector<base::FilePath>* result) const;
70 private:
71 // BGThread() is the body of the background thread
72 void BGThread();
73 static void BGThreadWrapper(void* arg) {
74 reinterpret_cast<ChromiumEnvWin*>(arg)->BGThread();
76 void RecordOpenFilesLimit(const std::string& type);
77 virtual void RecordOSError(MethodID method, DWORD err) const;
80 } // namespace leveldb_env
82 #endif // THIRD_PARTY_LEVELDATABASE_ENV_CHROMIUM_WIN_H_