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

Unified Diff: content/browser/dom_storage/session_storage_database.cc

Issue 1906243002: [tracing] Add a memory dump provider for DOM storage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix dcheck and return value. Created 4 years, 7 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 | « content/browser/dom_storage/session_storage_database.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_) {
« no previous file with comments | « content/browser/dom_storage/session_storage_database.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698