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_mojo_proxy.h" | 9 #include "components/leveldb/leveldb_mojo_proxy.h" |
| 10 #include "third_party/leveldatabase/env_chromium.h" |
10 #include "third_party/leveldatabase/src/include/leveldb/env.h" | 11 #include "third_party/leveldatabase/src/include/leveldb/env.h" |
11 | 12 |
12 namespace leveldb { | 13 namespace leveldb { |
13 | 14 |
14 // An implementation of the leveldb operating system interaction code which | 15 // An implementation of the leveldb operating system interaction code which |
15 // 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 |
16 // 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 |
17 // 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 |
18 // existence. | 19 // existence. |
19 class MojoEnv : public leveldb::Env { | 20 class MojoEnv : public Env, public leveldb_env::UMALogger { |
20 public: | 21 public: |
21 MojoEnv(scoped_refptr<LevelDBMojoProxy> file_thread, | 22 MojoEnv(scoped_refptr<LevelDBMojoProxy> file_thread, |
22 LevelDBMojoProxy::OpaqueDir* dir); | 23 LevelDBMojoProxy::OpaqueDir* dir); |
23 ~MojoEnv() override; | 24 ~MojoEnv() override; |
24 | 25 |
25 // Overridden from leveldb::Env: | 26 // Overridden from leveldb::Env: |
26 Status NewSequentialFile(const std::string& fname, | 27 Status NewSequentialFile(const std::string& fname, |
27 SequentialFile** result) override; | 28 SequentialFile** result) override; |
28 Status NewRandomAccessFile(const std::string& fname, | 29 Status NewRandomAccessFile(const std::string& fname, |
29 RandomAccessFile** result) override; | 30 RandomAccessFile** result) override; |
(...skipping 13 matching lines...) Expand all Loading... |
43 Status UnlockFile(FileLock* lock) override; | 44 Status UnlockFile(FileLock* lock) override; |
44 Status GetTestDirectory(std::string* path) override; | 45 Status GetTestDirectory(std::string* path) override; |
45 Status NewLogger(const std::string& fname, Logger** result) override; | 46 Status NewLogger(const std::string& fname, Logger** result) override; |
46 | 47 |
47 uint64_t NowMicros() override; | 48 uint64_t NowMicros() override; |
48 void SleepForMicroseconds(int micros) override; | 49 void SleepForMicroseconds(int micros) override; |
49 void Schedule(void (*function)(void* arg), void* arg) override; | 50 void Schedule(void (*function)(void* arg), void* arg) override; |
50 void StartThread(void (*function)(void* arg), void* arg) override; | 51 void StartThread(void (*function)(void* arg), void* arg) override; |
51 | 52 |
52 private: | 53 private: |
| 54 void RecordErrorAt(leveldb_env::MethodID method) const override; |
| 55 void RecordOSError(leveldb_env::MethodID method, |
| 56 base::File::Error error) const override; |
| 57 |
| 58 void RecordFileError(leveldb_env::MethodID method, |
| 59 filesystem::mojom::FileError error) const; |
| 60 |
53 scoped_refptr<LevelDBMojoProxy> thread_; | 61 scoped_refptr<LevelDBMojoProxy> thread_; |
54 LevelDBMojoProxy::OpaqueDir* dir_; | 62 LevelDBMojoProxy::OpaqueDir* dir_; |
55 | 63 |
56 DISALLOW_COPY_AND_ASSIGN(MojoEnv); | 64 DISALLOW_COPY_AND_ASSIGN(MojoEnv); |
57 }; | 65 }; |
58 | 66 |
59 } // namespace leveldb | 67 } // namespace leveldb |
60 | 68 |
61 #endif // COMPONENTS_LEVELDB_ENV_MOJO_H_ | 69 #endif // COMPONENTS_LEVELDB_ENV_MOJO_H_ |
OLD | NEW |