| 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 <functional> |
| 10 #include <memory> |
| 9 #include <set> | 11 #include <set> |
| 10 #include <string> | 12 #include <string> |
| 11 #include <vector> | 13 #include <vector> |
| 12 | 14 |
| 15 #include "base/containers/linked_list.h" |
| 13 #include "base/files/file.h" | 16 #include "base/files/file.h" |
| 14 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
| 18 #include "base/macros.h" |
| 15 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
| 16 #include "leveldb/env.h" | 20 #include "leveldb/env.h" |
| 17 #include "port/port_chromium.h" | 21 #include "port/port_chromium.h" |
| 18 #include "util/mutexlock.h" | 22 #include "util/mutexlock.h" |
| 19 | 23 |
| 24 namespace leveldb { |
| 25 class DB; |
| 26 struct Options; |
| 27 } |
| 28 |
| 20 namespace leveldb_env { | 29 namespace leveldb_env { |
| 21 | 30 |
| 22 // These entries map to values in tools/metrics/histograms/histograms.xml. New | 31 // These entries map to values in tools/metrics/histograms/histograms.xml. New |
| 23 // values should be appended at the end. | 32 // values should be appended at the end. |
| 24 enum MethodID { | 33 enum MethodID { |
| 25 kSequentialFileRead, | 34 kSequentialFileRead, |
| 26 kSequentialFileSkip, | 35 kSequentialFileSkip, |
| 27 kRandomAccessFileRead, | 36 kRandomAccessFileRead, |
| 28 kWritableFileAppend, | 37 kWritableFileAppend, |
| 29 kWritableFileClose, | 38 kWritableFileClose, |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 // Entry per Schedule() call | 229 // Entry per Schedule() call |
| 221 struct BGItem { | 230 struct BGItem { |
| 222 void* arg; | 231 void* arg; |
| 223 void (*function)(void*); | 232 void (*function)(void*); |
| 224 }; | 233 }; |
| 225 typedef std::deque<BGItem> BGQueue; | 234 typedef std::deque<BGItem> BGQueue; |
| 226 BGQueue queue_; | 235 BGQueue queue_; |
| 227 LockTable locks_; | 236 LockTable locks_; |
| 228 }; | 237 }; |
| 229 | 238 |
| 239 class DBRegistry { |
| 240 public: |
| 241 static leveldb::Status Open(const leveldb::Options& options, |
| 242 const std::string& name, |
| 243 leveldb::DB** dbptr); |
| 244 |
| 245 static DBRegistry* GetInstance(); |
| 246 |
| 247 using Visitor = std::function<void(const leveldb::Options& options, |
| 248 const std::string& name, |
| 249 leveldb::DB* db)>; |
| 250 |
| 251 void Visit(const Visitor& visitor); |
| 252 |
| 253 private: |
| 254 class DBProxy; |
| 255 class MDP; |
| 256 |
| 257 DBRegistry(); |
| 258 ~DBRegistry(); |
| 259 |
| 260 void Register(DBProxy* proxy); |
| 261 void Unregister(DBProxy* proxy); |
| 262 |
| 263 base::Lock lock_; |
| 264 base::LinkedList<DBProxy> proxies_; |
| 265 std::unique_ptr<MDP> mdp_; |
| 266 |
| 267 DISALLOW_COPY_AND_ASSIGN(DBRegistry); |
| 268 }; |
| 269 |
| 230 } // namespace leveldb_env | 270 } // namespace leveldb_env |
| 231 | 271 |
| 232 #endif // THIRD_PARTY_LEVELDATABASE_ENV_CHROMIUM_H_ | 272 #endif // THIRD_PARTY_LEVELDATABASE_ENV_CHROMIUM_H_ |
| OLD | NEW |