OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_LEVELDB_ENV_MOJO_H_ | 5 #ifndef COMPONENTS_LEVELDB_ENV_MOJO_H_ |
6 #define COMPONENTS_LEVELDB_ENV_MOJO_H_ | 6 #define COMPONENTS_LEVELDB_ENV_MOJO_H_ |
7 | 7 |
8 #include "components/filesystem/public/interfaces/directory.mojom.h" | 8 #include "components/filesystem/public/interfaces/directory.mojom.h" |
9 #include "components/leveldb/leveldb_file_thread.h" | 9 #include "components/leveldb/leveldb_mojo_proxy.h" |
10 #include "third_party/leveldatabase/env_chromium.h" | 10 #include "third_party/leveldatabase/env_chromium.h" |
11 #include "third_party/leveldatabase/src/include/leveldb/env.h" | 11 #include "third_party/leveldatabase/src/include/leveldb/env.h" |
12 | 12 |
13 namespace leveldb { | 13 namespace leveldb { |
14 | 14 |
15 // An implementation of the leveldb operating system interaction code which | 15 // An implementation of the leveldb operating system interaction code which |
16 // proxies to a specified mojo:filesystem directory. Most of these methods are | 16 // proxies to a specified mojo:filesystem directory. Most of these methods are |
17 // synchronous and block on responses from the filesystem service. That's fine | 17 // synchronous and block on responses from the filesystem service. That's fine |
18 // since, for the most part, they merely open files or check for a file's | 18 // since, for the most part, they merely open files or check for a file's |
19 // existence. | 19 // existence. |
20 class MojoEnv : public leveldb_env::ChromiumEnv { | 20 class MojoEnv : public leveldb_env::ChromiumEnv { |
21 public: | 21 public: |
22 MojoEnv(scoped_refptr<LevelDBFileThread> file_thread, | 22 MojoEnv(scoped_refptr<LevelDBMojoProxy> file_thread, |
23 LevelDBFileThread::OpaqueDir* dir); | 23 LevelDBMojoProxy::OpaqueDir* dir); |
24 ~MojoEnv() override; | 24 ~MojoEnv() override; |
25 | 25 |
26 // Overridden from leveldb_env::EnvChromium: | 26 // Overridden from leveldb_env::EnvChromium: |
27 Status NewSequentialFile(const std::string& fname, | 27 Status NewSequentialFile(const std::string& fname, |
28 SequentialFile** result) override; | 28 SequentialFile** result) override; |
29 Status NewRandomAccessFile(const std::string& fname, | 29 Status NewRandomAccessFile(const std::string& fname, |
30 RandomAccessFile** result) override; | 30 RandomAccessFile** result) override; |
31 Status NewWritableFile(const std::string& fname, | 31 Status NewWritableFile(const std::string& fname, |
32 WritableFile** result) override; | 32 WritableFile** result) override; |
33 Status NewAppendableFile(const std::string& fname, | 33 Status NewAppendableFile(const std::string& fname, |
34 WritableFile** result) override; | 34 WritableFile** result) override; |
35 bool FileExists(const std::string& fname) override; | 35 bool FileExists(const std::string& fname) override; |
36 Status GetChildren(const std::string& dir, | 36 Status GetChildren(const std::string& dir, |
37 std::vector<std::string>* result) override; | 37 std::vector<std::string>* result) override; |
38 Status DeleteFile(const std::string& fname) override; | 38 Status DeleteFile(const std::string& fname) override; |
39 Status CreateDir(const std::string& dirname) override; | 39 Status CreateDir(const std::string& dirname) override; |
40 Status DeleteDir(const std::string& dirname) override; | 40 Status DeleteDir(const std::string& dirname) override; |
41 Status GetFileSize(const std::string& fname, uint64_t* file_size) override; | 41 Status GetFileSize(const std::string& fname, uint64_t* file_size) override; |
42 Status RenameFile(const std::string& src, const std::string& target) override; | 42 Status RenameFile(const std::string& src, const std::string& target) override; |
43 Status LockFile(const std::string& fname, FileLock** lock) override; | 43 Status LockFile(const std::string& fname, FileLock** lock) override; |
44 Status UnlockFile(FileLock* lock) override; | 44 Status UnlockFile(FileLock* lock) override; |
45 Status GetTestDirectory(std::string* path) override; | 45 Status GetTestDirectory(std::string* path) override; |
46 Status NewLogger(const std::string& fname, Logger** result) override; | 46 Status NewLogger(const std::string& fname, Logger** result) override; |
47 | 47 |
48 // For reference, we specifically don't override Schedule(), StartThread(), | 48 // For reference, we specifically don't override Schedule(), StartThread(), |
49 // NowMicros() or SleepForMicroseconds() and use the EnvChromium versions. | 49 // NowMicros() or SleepForMicroseconds() and use the EnvChromium versions. |
50 | 50 |
51 private: | 51 private: |
52 scoped_refptr<LevelDBFileThread> thread_; | 52 scoped_refptr<LevelDBMojoProxy> thread_; |
53 LevelDBFileThread::OpaqueDir* dir_; | 53 LevelDBMojoProxy::OpaqueDir* dir_; |
54 | 54 |
55 DISALLOW_COPY_AND_ASSIGN(MojoEnv); | 55 DISALLOW_COPY_AND_ASSIGN(MojoEnv); |
56 }; | 56 }; |
57 | 57 |
58 } // namespace leveldb | 58 } // namespace leveldb |
59 | 59 |
60 #endif // COMPONENTS_LEVELDB_ENV_MOJO_H_ | 60 #endif // COMPONENTS_LEVELDB_ENV_MOJO_H_ |
OLD | NEW |