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

Unified Diff: content/browser/dom_storage/dom_storage_context_impl.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
Index: content/browser/dom_storage/dom_storage_context_impl.cc
diff --git a/content/browser/dom_storage/dom_storage_context_impl.cc b/content/browser/dom_storage/dom_storage_context_impl.cc
index 7fee39c34abf0647fe6e9c329bafdf54c76fe190..dad99c8462873eab07bc6e1dd36da7e62687eaac 100644
--- a/content/browser/dom_storage/dom_storage_context_impl.cc
+++ b/content/browser/dom_storage/dom_storage_context_impl.cc
@@ -14,6 +14,8 @@
#include "base/guid.h"
#include "base/location.h"
#include "base/time/time.h"
+#include "base/trace_event/memory_dump_manager.h"
+#include "base/trace_event/process_memory_dump.h"
#include "content/browser/dom_storage/dom_storage_area.h"
#include "content/browser/dom_storage/dom_storage_database.h"
#include "content/browser/dom_storage/dom_storage_namespace.h"
@@ -50,9 +52,20 @@ DOMStorageContextImpl::DOMStorageContextImpl(
// namespace ids at one since zero is reserved for the
// kLocalStorageNamespaceId.
session_id_sequence_.GetNext();
+
+ // Tests may run without task runners.
+ if (task_runner_) {
+ // Registering dump provider is safe even outside the task runner.
+ base::trace_event::MemoryDumpManager::GetInstance()
+ ->RegisterDumpProviderWithSequencedTaskRunner(
+ this, "DOMStorage", task_runner_->GetSequencedTaskRunner(
+ DOMStorageTaskRunner::PRIMARY_SEQUENCE),
+ base::trace_event::MemoryDumpProvider::Options());
+ }
}
DOMStorageContextImpl::~DOMStorageContextImpl() {
+ DCHECK(is_shutdown_);
if (session_storage_database_.get()) {
// SessionStorageDatabase shouldn't be deleted right away: deleting it will
// potentially involve waiting in leveldb::DBImpl::~DBImpl, and waiting
@@ -174,11 +187,15 @@ void DOMStorageContextImpl::Flush() {
}
void DOMStorageContextImpl::Shutdown() {
+ DCHECK(!task_runner_ || task_runner_->IsRunningOnPrimarySequence());
is_shutdown_ = true;
StorageNamespaceMap::const_iterator it = namespaces_.begin();
for (; it != namespaces_.end(); ++it)
it->second->Shutdown();
+ base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider(
+ this);
+
if (localstorage_directory_.empty() && !session_storage_database_.get())
return;
@@ -357,6 +374,17 @@ void DOMStorageContextImpl::StartScavengingUnusedSessionStorage() {
}
}
+bool DOMStorageContextImpl::OnMemoryDump(
+ const base::trace_event::MemoryDumpArgs& args,
+ base::trace_event::ProcessMemoryDump* pmd) {
+ for (const auto& it : namespaces_) {
+ it.second->OnMemoryDump(pmd);
+ }
+ if (session_storage_database_)
+ session_storage_database_->OnMemoryDump(pmd);
+ return true;
+}
+
void DOMStorageContextImpl::FindUnusedNamespaces() {
DCHECK(session_storage_database_.get());
if (scavenging_started_)

Powered by Google App Engine
This is Rietveld 408576698