| 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 ae90b0fcc669405433e00f75ad7fd0ad28216888..219c184e24496ae9d10af45881dcb3d50b55b837 100644
|
| --- a/content/browser/dom_storage/session_storage_database.cc
|
| +++ b/content/browser/dom_storage/session_storage_database.cc
|
| @@ -14,6 +14,8 @@
|
| #include "base/strings/string_number_conversions.h"
|
| #include "base/strings/stringprintf.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| +#include "base/trace_event/memory_dump_manager.h"
|
| +#include "base/trace_event/process_memory_dump.h"
|
| #include "third_party/leveldatabase/env_chromium.h"
|
| #include "third_party/leveldatabase/src/include/leveldb/db.h"
|
| #include "third_party/leveldatabase/src/include/leveldb/iterator.h"
|
| @@ -325,6 +327,36 @@ bool SessionStorageDatabase::ReadNamespacesAndOrigins(
|
| return true;
|
| }
|
|
|
| +void SessionStorageDatabase::OnMemoryDump(
|
| + base::trace_event::ProcessMemoryDump* pmd) {
|
| + std::string db_memory_usage;
|
| + {
|
| + base::AutoLock lock(db_lock_);
|
| + if (!db_)
|
| + return;
|
| +
|
| + bool res =
|
| + db_->GetProperty("leveldb.approximate-memory-usage", &db_memory_usage);
|
| + DCHECK(res);
|
| + }
|
| +
|
| + uint64_t size;
|
| + bool res = base::StringToUint64(db_memory_usage, &size);
|
| + DCHECK(res);
|
| +
|
| + auto mad = pmd->CreateAllocatorDump(
|
| + base::StringPrintf("dom_storage/session_storage_%p", this));
|
| + 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);
|
| +}
|
| +
|
| bool SessionStorageDatabase::LazyOpen(bool create_if_needed) {
|
| base::AutoLock auto_lock(db_lock_);
|
| if (db_error_ || is_inconsistent_) {
|
|
|