| OLD | NEW |
| 1 // Copyright (c) 2013 The LevelDB Authors. All rights reserved. | 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 | 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. | 3 // found in the LICENSE file. See the AUTHORS file for names of contributors. |
| 4 | 4 |
| 5 #ifndef THIRD_PARTY_LEVELDATABASE_ENV_CHROMIUM_H_ | 5 #ifndef THIRD_PARTY_LEVELDATABASE_ENV_CHROMIUM_H_ |
| 6 #define THIRD_PARTY_LEVELDATABASE_ENV_CHROMIUM_H_ | 6 #define THIRD_PARTY_LEVELDATABASE_ENV_CHROMIUM_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> |
| 12 #include <vector> |
| 11 | 13 |
| 12 #include "base/files/file.h" | 14 #include "base/files/file.h" |
| 15 #include "base/files/file_path.h" |
| 13 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 14 #include "leveldb/env.h" | 17 #include "leveldb/env.h" |
| 15 #include "port/port_chromium.h" | 18 #include "port/port_chromium.h" |
| 16 #include "util/mutexlock.h" | 19 #include "util/mutexlock.h" |
| 17 | 20 |
| 18 namespace leveldb_env { | 21 namespace leveldb_env { |
| 19 | 22 |
| 20 enum MethodID { | 23 enum MethodID { |
| 21 kSequentialFileRead, | 24 kSequentialFileRead, |
| 22 kSequentialFileSkip, | 25 kSequentialFileSkip, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 virtual void DidCreateNewFile(const std::string& fname) = 0; | 99 virtual void DidCreateNewFile(const std::string& fname) = 0; |
| 97 virtual bool DoesDirNeedSync(const std::string& fname) = 0; | 100 virtual bool DoesDirNeedSync(const std::string& fname) = 0; |
| 98 virtual void DidSyncDir(const std::string& fname) = 0; | 101 virtual void DidSyncDir(const std::string& fname) = 0; |
| 99 }; | 102 }; |
| 100 | 103 |
| 101 class ChromiumEnv : public leveldb::Env, | 104 class ChromiumEnv : public leveldb::Env, |
| 102 public UMALogger, | 105 public UMALogger, |
| 103 public RetrierProvider, | 106 public RetrierProvider, |
| 104 public WriteTracker { | 107 public WriteTracker { |
| 105 public: | 108 public: |
| 109 typedef void(ScheduleFunc)(void*); |
| 110 |
| 106 static bool MakeBackup(const std::string& fname); | 111 static bool MakeBackup(const std::string& fname); |
| 107 static base::FilePath CreateFilePath(const std::string& file_path); | 112 static base::FilePath CreateFilePath(const std::string& file_path); |
| 108 static const char* FileErrorString(::base::File::Error error); | 113 static const char* FileErrorString(::base::File::Error error); |
| 109 static bool HasTableExtension(const base::FilePath& path); | 114 static bool HasTableExtension(const base::FilePath& path); |
| 110 virtual ~ChromiumEnv(); | 115 virtual ~ChromiumEnv(); |
| 111 | 116 |
| 112 virtual bool FileExists(const std::string& fname); | 117 virtual bool FileExists(const std::string& fname); |
| 113 virtual leveldb::Status GetChildren(const std::string& dir, | 118 virtual leveldb::Status GetChildren(const std::string& dir, |
| 114 std::vector<std::string>* result); | 119 std::vector<std::string>* result); |
| 115 virtual leveldb::Status DeleteFile(const std::string& fname); | 120 virtual leveldb::Status DeleteFile(const std::string& fname); |
| 116 virtual leveldb::Status CreateDir(const std::string& name); | 121 virtual leveldb::Status CreateDir(const std::string& name); |
| 117 virtual leveldb::Status DeleteDir(const std::string& name); | 122 virtual leveldb::Status DeleteDir(const std::string& name); |
| 118 virtual leveldb::Status GetFileSize(const std::string& fname, uint64_t* size); | 123 virtual leveldb::Status GetFileSize(const std::string& fname, uint64_t* size); |
| 119 virtual leveldb::Status RenameFile(const std::string& src, | 124 virtual leveldb::Status RenameFile(const std::string& src, |
| 120 const std::string& dst); | 125 const std::string& dst); |
| 121 virtual leveldb::Status LockFile(const std::string& fname, | 126 virtual leveldb::Status LockFile(const std::string& fname, |
| 122 leveldb::FileLock** lock); | 127 leveldb::FileLock** lock); |
| 123 virtual leveldb::Status UnlockFile(leveldb::FileLock* lock); | 128 virtual leveldb::Status UnlockFile(leveldb::FileLock* lock); |
| 124 virtual void Schedule(void (*function)(void*), void* arg); | 129 virtual void Schedule(ScheduleFunc*, void* arg); |
| 125 virtual void StartThread(void (*function)(void* arg), void* arg); | 130 virtual void StartThread(void (*function)(void* arg), void* arg); |
| 126 virtual leveldb::Status GetTestDirectory(std::string* path); | 131 virtual leveldb::Status GetTestDirectory(std::string* path); |
| 127 virtual uint64_t NowMicros(); | 132 virtual uint64_t NowMicros(); |
| 128 virtual void SleepForMicroseconds(int micros); | 133 virtual void SleepForMicroseconds(int micros); |
| 129 | 134 |
| 130 protected: | 135 protected: |
| 131 ChromiumEnv(); | 136 ChromiumEnv(); |
| 132 | 137 |
| 133 virtual void DidCreateNewFile(const std::string& fname); | 138 virtual void DidCreateNewFile(const std::string& fname); |
| 134 virtual bool DoesDirNeedSync(const std::string& fname); | 139 virtual bool DoesDirNeedSync(const std::string& fname); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 void* arg; | 204 void* arg; |
| 200 void (*function)(void*); | 205 void (*function)(void*); |
| 201 }; | 206 }; |
| 202 typedef std::deque<BGItem> BGQueue; | 207 typedef std::deque<BGItem> BGQueue; |
| 203 BGQueue queue_; | 208 BGQueue queue_; |
| 204 LockTable locks_; | 209 LockTable locks_; |
| 205 }; | 210 }; |
| 206 | 211 |
| 207 } // namespace leveldb_env | 212 } // namespace leveldb_env |
| 208 | 213 |
| 209 #endif | 214 #endif // THIRD_PARTY_LEVELDATABASE_ENV_CHROMIUM_H_ |
| OLD | NEW |