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

Unified Diff: third_party/leveldatabase/env_chromium.cc

Issue 2953473002: Use leveldb_env::OpenDB() to open leveldb databases. (Closed)
Patch Set: Don't dump in background mode 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
Index: third_party/leveldatabase/env_chromium.cc
diff --git a/third_party/leveldatabase/env_chromium.cc b/third_party/leveldatabase/env_chromium.cc
index 7a0f4ad03f18b378b52d94398510e54e6ccb05a4..c3f730dd45928f0cdc1be2d56352439398f4c342 100644
--- a/third_party/leveldatabase/env_chromium.cc
+++ b/third_party/leveldatabase/env_chromium.cc
@@ -1193,11 +1193,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;
@@ -1245,11 +1250,17 @@ DBTracker* DBTracker::GetInstance() {
return instance;
}
+std::string DBTracker::GetMemoryDumpName(leveldb::DB* tracked_db) {
+ return base::StringPrintf("leveldatabase/0x%" PRIXPTR,
pwnall 2017/07/07 22:30:29 nit: I'd prefer that GetMemoryDumpName() DCHECKs t
DmitrySkiba 2017/07/17 22:09:25 I can see value in that DCHECK, but I'm not sure w
+ 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);
+ CHECK((status.ok() && db) || (!status.ok() && !db));
if (status.ok()) {
// TrackedDBImpl ctor adds the instance to the tracker.
*dbptr = new TrackedDBImpl(GetInstance(), name, db);
« third_party/leveldatabase/env_chromium.h ('K') | « third_party/leveldatabase/env_chromium.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698