| 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..6628dffb2896ac4e6c96e247b6ce48585ef92a2d 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,32 @@ void DOMStorageArea::Shutdown() {
|
| DCHECK(success);
|
| }
|
|
|
| +void DOMStorageArea::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) {
|
| + DCHECK(task_runner_->IsRunningOnPrimarySequence());
|
| + // Do not trace if usage is very low.
|
| + if (map_->bytes_used() < 1024)
|
| + 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);
|
| + 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 local backing storage crbug.com/605785.
|
| +}
|
| +
|
| void DOMStorageArea::InitialImportIfNeeded() {
|
| if (is_initial_import_done_)
|
| return;
|
|
|