Chromium Code Reviews| Index: content/browser/dom_storage/dom_storage_area.cc |
| diff --git a/content/browser/dom_storage/dom_storage_area.cc b/content/browser/dom_storage/dom_storage_area.cc |
| index 50ef7ff05f993f4ca0bc2b59aa849b9a23c78f35..9fa350719a176240d1c59050eed507d2a7390741 100644 |
| --- a/content/browser/dom_storage/dom_storage_area.cc |
| +++ b/content/browser/dom_storage/dom_storage_area.cc |
| @@ -5,14 +5,18 @@ |
| #include "content/browser/dom_storage/dom_storage_area.h" |
| #include <algorithm> |
| +#include <cctype> // for std::isalnum |
| #include "base/bind.h" |
| #include "base/location.h" |
| #include "base/logging.h" |
| #include "base/metrics/histogram.h" |
| #include "base/process/process_info.h" |
| +#include "base/strings/stringprintf.h" |
| #include "base/strings/utf_string_conversions.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_namespace.h" |
| #include "content/browser/dom_storage/dom_storage_task_runner.h" |
| #include "content/browser/dom_storage/local_storage_database_adapter.h" |
| @@ -330,6 +334,29 @@ void DOMStorageArea::Shutdown() { |
| DCHECK(success); |
| } |
| +void DOMStorageArea::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) { |
| + if (!map_->bytes_used()) |
| + return; |
| + // Limit the url length to 50 and strip special characters. |
| + std::string url = origin_.spec().substr(0, 50); |
| + for (size_t index = 0; index < url.size(); ++index) { |
| + if (!std::isalnum(url[index])) |
| + url[index] = '_'; |
| + } |
| + std::string name = StringPrintf("dom_storage/%s/%p", url.c_str(), this); |
|
Primiano Tucci (use gerrit)
2016/04/22 09:56:39
I'd probably %s_%p instead of %s/%p just for the s
ssid
2016/04/22 23:28:16
No, I intended to make this %s/%p since it groups
|
| + auto mad = pmd->CreateAllocatorDump(name + "/storage_map"); |
| + mad->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
| + base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
| + map_->bytes_used()); |
| + |
| + 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); |
| + // TODO(ssid): Add memory usage of backing storage crbug.com/605785. |
| +} |
| + |
| void DOMStorageArea::InitialImportIfNeeded() { |
| if (is_initial_import_done_) |
| return; |