| Index: content/browser/dom_storage/session_storage_database.cc
|
| diff --git a/content/browser/dom_storage/session_storage_database.cc b/content/browser/dom_storage/session_storage_database.cc
|
| index 0bf1caaae7a5403c1a739f867c140737e6a2ba19..2e3d8f7b7a80462e8279b6b8115d52d409bde3f8 100644
|
| --- a/content/browser/dom_storage/session_storage_database.cc
|
| +++ b/content/browser/dom_storage/session_storage_database.cc
|
| @@ -357,12 +357,10 @@ void SessionStorageDatabase::OnMemoryDump(
|
| mad->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
|
| base::trace_event::MemoryAllocatorDump::kUnitsBytes, size);
|
|
|
| - // Memory is allocated from system allocator (malloc).
|
| - const char* system_allocator_name =
|
| - base::trace_event::MemoryDumpManager::GetInstance()
|
| - ->system_allocator_pool_name();
|
| - if (system_allocator_name)
|
| - pmd->AddSuballocation(mad->guid(), system_allocator_name);
|
| + // All leveldb databases are already dumped by leveldb_env::DBTracker. Add
|
| + // an edge to avoid double counting.
|
| + pmd->AddSuballocation(mad->guid(),
|
| + leveldb_env::DBTracker::GetMemoryDumpName(db_.get()));
|
| }
|
|
|
| bool SessionStorageDatabase::LazyOpen(bool create_if_needed) {
|
| @@ -383,16 +381,14 @@ bool SessionStorageDatabase::LazyOpen(bool create_if_needed) {
|
| return false;
|
| }
|
|
|
| - leveldb::DB* db;
|
| - leveldb::Status s = TryToOpen(&db);
|
| + leveldb::Status s = TryToOpen(&db_);
|
| if (!s.ok()) {
|
| LOG(WARNING) << "Failed to open leveldb in " << file_path_.value()
|
| << ", error: " << s.ToString();
|
| - DCHECK(db == NULL);
|
|
|
| // Clear the directory and try again.
|
| base::DeleteFile(file_path_, true);
|
| - s = TryToOpen(&db);
|
| + s = TryToOpen(&db_);
|
| if (!s.ok()) {
|
| LOG(WARNING) << "Failed to open leveldb in " << file_path_.value()
|
| << ", error: " << s.ToString();
|
| @@ -420,7 +416,6 @@ bool SessionStorageDatabase::LazyOpen(bool create_if_needed) {
|
| NOTREACHED();
|
| }
|
|
|
| - DCHECK(db == NULL);
|
| db_error_ = true;
|
| return false;
|
| }
|
| @@ -432,11 +427,11 @@ bool SessionStorageDatabase::LazyOpen(bool create_if_needed) {
|
| SESSION_STORAGE_UMA_SUCCESS,
|
| SESSION_STORAGE_UMA_MAX);
|
| }
|
| - db_.reset(db);
|
| return true;
|
| }
|
|
|
| -leveldb::Status SessionStorageDatabase::TryToOpen(leveldb::DB** db) {
|
| +leveldb::Status SessionStorageDatabase::TryToOpen(
|
| + std::unique_ptr<leveldb::DB>* db) {
|
| leveldb::Options options;
|
| // The directory exists but a valid leveldb database might not exist inside it
|
| // (e.g., a subset of the needed files might be missing). Handle this
|
| @@ -447,7 +442,7 @@ leveldb::Status SessionStorageDatabase::TryToOpen(leveldb::DB** db) {
|
| // Default write_buffer_size is 4 MB but that might leave a 3.999
|
| // memory allocation in RAM from a log file recovery.
|
| options.write_buffer_size = 64 * 1024;
|
| - return leveldb::DB::Open(options, file_path_.AsUTF8Unsafe(), db);
|
| + return leveldb_env::OpenDB(options, file_path_.AsUTF8Unsafe(), db);
|
| }
|
|
|
| bool SessionStorageDatabase::IsOpen() const {
|
|
|