[SyncFS] Build indexes from FileTracker entries on disk.
[chromium-blink-merge.git] / third_party / leveldatabase / env_chromium_stdio.h
blob3fb41421451c5be2aa23028e2441b6aca8930b07
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 {
13 public:
14 ChromiumWritableFile(const std::string& fname,
15 FILE* f,
16 const UMALogger* uma_logger,
17 WriteTracker* tracker,
18 bool make_backup);
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();
25 private:
26 enum Type {
27 kManifest,
28 kTable,
29 kOther
31 leveldb::Status SyncParent();
33 std::string filename_;
34 FILE* file_;
35 const UMALogger* uma_logger_;
36 WriteTracker* tracker_;
37 Type file_type_;
38 std::string parent_dir_;
39 bool make_backup_;
42 class ChromiumEnvStdio : public ChromiumEnv {
43 public:
44 ChromiumEnvStdio();
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);
57 protected:
58 virtual base::File::Error GetDirectoryEntries(
59 const base::FilePath& dir_param,
60 std::vector<base::FilePath>* result) const;
62 private:
63 // BGThread() is the body of the background thread
64 void BGThread();
65 static void BGThreadWrapper(void* arg) {
66 reinterpret_cast<ChromiumEnvStdio*>(arg)->BGThread();
68 void RecordOpenFilesLimit(const std::string& type);
71 } // namespace leveldb_env
73 #endif