Chromium Code Reviews| Index: net/base/sdch_manager.cc |
| diff --git a/net/base/sdch_manager.cc b/net/base/sdch_manager.cc |
| index e57d73cfb24ab437fff321a170dbc42a5c7e067f..4b23fd3a1bcb930a7500411c06e9bb74cd250aa0 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,32 @@ void SdchManager::RemoveObserver(SdchObserver* observer) { |
| observers_.RemoveObserver(observer); |
| } |
| +void SdchManager::DumpMemoryStats( |
| + base::trace_event::ProcessMemoryDump* pmd) const { |
| + std::string name = base::StringPrintf("net/sdch_manager_%p", this); |
| + base::trace_event::MemoryAllocatorDump* dictionary_dump = |
| + pmd->GetAllocatorDump(name); |
| + if (dictionary_dump) |
|
eroman
2016/11/29 22:22:50
What are the circumstances when this would be reac
xunjieli
2016/11/30 16:02:03
Done.
URLRequestContexts currently don't share a
|
| + return; |
| + size_t total_size = 0; |
| + size_t total_count = 0; |
| + for (const auto& dictionary : dictionaries_) { |
| + total_size += dictionary.second->data.text().size(); |
| + ++total_count; |
|
eroman
2016/11/29 22:22:50
maybe just dictionaries_.size() outside of loop?
xunjieli
2016/11/30 16:02:03
Done.
|
| + } |
| + if (total_count == 0) |
| + return; |
| + dictionary_dump = pmd->CreateAllocatorDump(name); |
| + dictionary_dump->AddScalar( |
| + base::trace_event::MemoryAllocatorDump::kNameSize, |
| + base::trace_event::MemoryAllocatorDump::kUnitsBytes, total_size); |
| + |
| + // Use the existing column name so as not to add a new column. |
|
eroman
2016/11/29 22:22:50
I am not sure what this comment means regarding "e
xunjieli
2016/11/30 16:02:03
Done. Sorry, there is a constant (base::trace_even
|
| + dictionary_dump->AddScalar( |
| + "count", base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| + total_count); |
| +} |
| + |
| SdchProblemCode SdchManager::AddSdchDictionary( |
| const std::string& dictionary_text, |
| const GURL& dictionary_url, |