Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: third_party/leveldatabase/env_chromium.h

Issue 2855953002: leveldb: Add DBTracker for exposing databases to Chrome's memory-infra. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698