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

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

Issue 1310513004: [tracing] Add memory statistics from level db clients to tracing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@skia_res
Patch Set: Rebase. Created 5 years, 3 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: 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 d0ab442238b5817b48761a8267e5858002ba420d..5dc1605bb36ed1ce81581f96d6f71dc371abaa96 100644
--- a/content/browser/dom_storage/session_storage_database.cc
+++ b/content/browser/dom_storage/session_storage_database.cc
@@ -12,6 +12,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"
@@ -95,9 +97,13 @@ SessionStorageDatabase::SessionStorageDatabase(const base::FilePath& file_path)
is_inconsistent_(false),
invalid_db_deleted_(false),
operation_count_(0) {
+ base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
+ this);
}
SessionStorageDatabase::~SessionStorageDatabase() {
+ base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider(
+ this);
Primiano Tucci (use gerrit) 2015/10/15 08:59:52 if you unregister the RegisterDumpProvider call ab
ssid 2015/10/15 15:22:04 Thanks, I guess both were done in the same thread
}
void SessionStorageDatabase::ReadAreaValues(const std::string& namespace_id,
@@ -323,6 +329,31 @@ bool SessionStorageDatabase::ReadNamespacesAndOrigins(
return true;
}
+bool SessionStorageDatabase::OnMemoryDump(
+ const base::trace_event::MemoryDumpArgs& args,
+ base::trace_event::ProcessMemoryDump* pmd) {
+ if (!db_)
+ return true;
+
+ base::trace_event::MemoryAllocatorDump* dump =
+ pmd->CreateAllocatorDump("leveldb/session_storage_db");
+
+ base::AutoLock auto_lock(db_lock_);
+ std::string value;
+ uint64 size;
+ db_->GetProperty("leveldb.approximate-memory-usage", &value);
Primiano Tucci (use gerrit) 2015/10/15 08:59:52 shouldn't you check the return value of GetPropert
ssid 2015/10/15 15:22:04 Actually it cannot fail. added dcheck.
+ base::StringToUint64(value, &size);
+
+ dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
+ base::trace_event::MemoryAllocatorDump::kUnitsBytes, size);
+
+ // Memory is allocated from system allocator (malloc).
+ pmd->AddSuballocation(dump->guid(),
+ base::trace_event::MemoryDumpManager::GetInstance()
+ ->system_allocator_pool_name());
+ return true;
+}
+
bool SessionStorageDatabase::LazyOpen(bool create_if_needed) {
base::AutoLock auto_lock(db_lock_);
if (db_error_ || is_inconsistent_) {

Powered by Google App Engine
This is Rietveld 408576698