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

Unified 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, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/leveldatabase/env_chromium.h
diff --git a/third_party/leveldatabase/env_chromium.h b/third_party/leveldatabase/env_chromium.h
index d2e5b83111c79974c2b93622dedf2ec8aaf0eb8c..0afac376d2402f273c0e9a167ee2b7854d41990a 100644
--- a/third_party/leveldatabase/env_chromium.h
+++ b/third_party/leveldatabase/env_chromium.h
@@ -6,17 +6,26 @@
#define THIRD_PARTY_LEVELDATABASE_ENV_CHROMIUM_H_
#include <deque>
+#include <functional>
+#include <memory>
#include <set>
#include <string>
#include <vector>
+#include "base/containers/linked_list.h"
#include "base/files/file.h"
#include "base/files/file_path.h"
+#include "base/macros.h"
#include "base/metrics/histogram.h"
#include "leveldb/env.h"
#include "port/port_chromium.h"
#include "util/mutexlock.h"
+namespace leveldb {
+class DB;
+struct Options;
+}
+
namespace leveldb_env {
// These entries map to values in tools/metrics/histograms/histograms.xml. New
@@ -227,6 +236,37 @@ class ChromiumEnv : public leveldb::Env,
LockTable locks_;
};
+class DBRegistry {
+ public:
+ static leveldb::Status Open(const leveldb::Options& options,
+ const std::string& name,
+ leveldb::DB** dbptr);
+
+ static DBRegistry* GetInstance();
+
+ using Visitor = std::function<void(const leveldb::Options& options,
+ const std::string& name,
+ leveldb::DB* db)>;
+
+ void Visit(const Visitor& visitor);
+
+ private:
+ class DBProxy;
+ class MDP;
+
+ DBRegistry();
+ ~DBRegistry();
+
+ void Register(DBProxy* proxy);
+ void Unregister(DBProxy* proxy);
+
+ base::Lock lock_;
+ base::LinkedList<DBProxy> proxies_;
+ std::unique_ptr<MDP> mdp_;
+
+ DISALLOW_COPY_AND_ASSIGN(DBRegistry);
+};
+
} // namespace leveldb_env
#endif // THIRD_PARTY_LEVELDATABASE_ENV_CHROMIUM_H_

Powered by Google App Engine
This is Rietveld 408576698