Index: net/base/sdch_manager.cc |
diff --git a/net/base/sdch_manager.cc b/net/base/sdch_manager.cc |
index e57d73cfb24ab437fff321a170dbc42a5c7e067f..d577db8436c1c682fdcc0595febc39a360dd3167 100644 |
--- a/net/base/sdch_manager.cc |
+++ b/net/base/sdch_manager.cc |
@@ -13,7 +13,10 @@ |
#include "base/metrics/histogram_macros.h" |
#include "base/strings/string_number_conversions.h" |
#include "base/strings/string_util.h" |
+#include "base/strings/stringprintf.h" |
#include "base/time/default_clock.h" |
+#include "base/trace_event/memory_allocator_dump.h" |
+#include "base/trace_event/process_memory_dump.h" |
#include "base/values.h" |
#include "crypto/sha2.h" |
#include "net/base/parse_number.h" |
@@ -324,6 +327,36 @@ void SdchManager::RemoveObserver(SdchObserver* observer) { |
observers_.RemoveObserver(observer); |
} |
+void SdchManager::DumpMemoryStats( |
+ base::trace_event::ProcessMemoryDump* pmd, |
+ const std::string& parent_dump_absolute_name) const { |
+ // If there are no dictionaries stored, return early without creating a new |
+ // MemoryAllocatorDump. |
+ size_t total_count = dictionaries_.size(); |
+ if (total_count == 0) |
+ return; |
+ std::string name = base::StringPrintf("net/sdch_manager_%p", this); |
+ base::trace_event::MemoryAllocatorDump* dump = pmd->GetAllocatorDump(name); |
+ if (dump == nullptr) { |
+ dump = pmd->CreateAllocatorDump(name); |
+ size_t total_size = 0; |
+ for (const auto& dictionary : dictionaries_) { |
+ total_size += dictionary.second->data.text().size(); |
+ } |
+ dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
+ base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
+ total_size); |
+ dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameObjectCount, |
+ base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
+ total_count); |
+ } |
+ // Create an empty row under parent's dump so size can be attributed correctly |
+ // if |this| is shared between URLRequestContexts. |
+ base::trace_event::MemoryAllocatorDump* empty_row_dump = |
+ pmd->CreateAllocatorDump(parent_dump_absolute_name + "/sdch_manager"); |
+ pmd->AddOwnershipEdge(empty_row_dump->guid(), dump->guid()); |
+} |
+ |
SdchProblemCode SdchManager::AddSdchDictionary( |
const std::string& dictionary_text, |
const GURL& dictionary_url, |