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