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

Unified Diff: third_party/leveldatabase/env_chromium.cc

Issue 2953473002: Use leveldb_env::OpenDB() to open leveldb databases. (Closed)
Patch Set: Rebase; add comments to CHECK() Created 3 years, 5 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
« no previous file with comments | « third_party/leveldatabase/env_chromium.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/leveldatabase/env_chromium.cc
diff --git a/third_party/leveldatabase/env_chromium.cc b/third_party/leveldatabase/env_chromium.cc
index 4a6f9a34ab6836e408c4167357c8d668d465af6d..6dbfc3784d46f529605e97ec4f3a81ca14d99b3d 100644
--- a/third_party/leveldatabase/env_chromium.cc
+++ b/third_party/leveldatabase/env_chromium.cc
@@ -1197,11 +1197,16 @@ class DBTracker::MemoryDumpProvider
public:
bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd) override {
+ // Don't dump in background mode ("from the field") until whitelisted.
+ if (args.level_of_detail ==
+ base::trace_event::MemoryDumpLevelOfDetail::BACKGROUND) {
+ return true;
+ }
+
auto db_visitor = [](const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd,
TrackedDB* db) {
- std::string db_dump_name = base::StringPrintf(
- "leveldatabase/0x%" PRIXPTR, reinterpret_cast<uintptr_t>(db));
+ std::string db_dump_name = DBTracker::GetMemoryDumpName(db);
auto* db_dump = pmd->CreateAllocatorDump(db_dump_name.c_str());
uint64_t db_memory_usage = 0;
@@ -1249,11 +1254,19 @@ DBTracker* DBTracker::GetInstance() {
return instance;
}
+std::string DBTracker::GetMemoryDumpName(leveldb::DB* tracked_db) {
+ return base::StringPrintf("leveldatabase/0x%" PRIXPTR,
+ reinterpret_cast<uintptr_t>(tracked_db));
+}
+
leveldb::Status DBTracker::OpenDatabase(const leveldb::Options& options,
const std::string& name,
TrackedDB** dbptr) {
leveldb::DB* db = nullptr;
auto status = leveldb::DB::Open(options, name, &db);
+ // Enforce expectations: either we succeed, and get a valid object in |db|,
+ // or we fail, and |db| is still NULL.
+ CHECK((status.ok() && db) || (!status.ok() && !db));
if (status.ok()) {
// TrackedDBImpl ctor adds the instance to the tracker.
*dbptr = new TrackedDBImpl(GetInstance(), name, db);
« no previous file with comments | « third_party/leveldatabase/env_chromium.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698