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

Unified Diff: components/leveldb_proto/leveldb_database.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
Index: components/leveldb_proto/leveldb_database.cc
diff --git a/components/leveldb_proto/leveldb_database.cc b/components/leveldb_proto/leveldb_database.cc
index e3903f6d908df3fc6522f2f4dc1c75afe7fc9f1f..073dbec3f51ebac37af89920ddbf69c5278e5ac2 100644
--- a/components/leveldb_proto/leveldb_database.cc
+++ b/components/leveldb_proto/leveldb_database.cc
@@ -62,19 +62,15 @@ bool LevelDB::InitWithOptions(const base::FilePath& database_dir,
std::string path = database_dir.AsUTF8Unsafe();
- leveldb::DB* db = NULL;
- leveldb::Status status = leveldb::DB::Open(options, path, &db);
+ leveldb::Status status = leveldb_env::OpenDB(options, path, &db_);
if (open_histogram_)
open_histogram_->Add(leveldb_env::GetLevelDBStatusUMAValue(status));
if (status.IsCorruption()) {
base::DeleteFile(database_dir, true);
- status = leveldb::DB::Open(options, path, &db);
+ status = leveldb_env::OpenDB(options, path, &db_);
}
if (status.ok()) {
- CHECK(db);
- db_.reset(db);
-
base::trace_event::MemoryDumpManager::GetInstance()
->RegisterDumpProviderWithSequencedTaskRunner(
this, "LevelDB", base::SequencedTaskRunnerHandle::Get(),
@@ -223,12 +219,10 @@ bool LevelDB::OnMemoryDump(const base::trace_event::MemoryDumpArgs& dump_args,
dump->AddString("client_name", "", client_name_);
}
- // Memory is allocated from system allocator (malloc).
- const char* system_allocator_pool_name =
- base::trace_event::MemoryDumpManager::GetInstance()
- ->system_allocator_pool_name();
- if (system_allocator_pool_name)
- pmd->AddSuballocation(dump->guid(), system_allocator_pool_name);
+ // All leveldb databases are already dumped by leveldb_env::DBTracker. Add
+ // an edge to avoid double counting.
+ pmd->AddSuballocation(dump->guid(),
+ leveldb_env::DBTracker::GetMemoryDumpName(db_.get()));
return true;
}
« no previous file with comments | « components/leveldb/leveldb_service_impl.cc ('k') | components/leveldb_proto/proto_database_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698