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..cf59c1808fd563bccfcb48c836181ca0e69c78c5 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,40 @@ void SdchManager::RemoveObserver(SdchObserver* observer) { |
| observers_.RemoveObserver(observer); |
| } |
| +void SdchManager::DumpMemoryStats( |
| + base::trace_event::MemoryAllocatorDump* url_request_context_dump) const { |
|
ssid
2016/12/02 21:36:35
Please pass ProcessMemoryDump* here instead.
|
| + std::string name = base::StringPrintf("net/sdch_manager_%p", this); |
| + base::trace_event::MemoryAllocatorDump* sdch_manager_dump = |
| + url_request_context_dump->process_memory_dump()->GetAllocatorDump(name); |
|
ssid
2016/12/02 21:36:35
Please do not use process_memory_dump() method. I
|
| + // If |this| is shared with another URLRequestContext, add an Ownership Edge |
| + // and return early. |
| + if (sdch_manager_dump != nullptr) { |
| + url_request_context_dump->process_memory_dump()->AddOwnershipEdge( |
| + url_request_context_dump->guid(), sdch_manager_dump->guid()); |
| + return; |
| + } |
| + // If there are no dictionaries stored, return early without creating a new |
| + // MemoryAllocatorDump. |
| + size_t total_count = dictionaries_.size(); |
| + if (total_count == 0) |
| + return; |
| + sdch_manager_dump = |
| + url_request_context_dump->process_memory_dump()->CreateAllocatorDump( |
| + name); |
| + url_request_context_dump->process_memory_dump()->AddOwnershipEdge( |
| + url_request_context_dump->guid(), sdch_manager_dump->guid()); |
| + size_t total_size = 0; |
| + for (const auto& dictionary : dictionaries_) { |
| + total_size += dictionary.second->data.text().size(); |
| + } |
| + sdch_manager_dump->AddScalar( |
| + base::trace_event::MemoryAllocatorDump::kNameSize, |
| + base::trace_event::MemoryAllocatorDump::kUnitsBytes, total_size); |
| + sdch_manager_dump->AddScalar( |
| + base::trace_event::MemoryAllocatorDump::kNameObjectCount, |
| + base::trace_event::MemoryAllocatorDump::kUnitsObjects, total_count); |
| +} |
| + |
| SdchProblemCode SdchManager::AddSdchDictionary( |
| const std::string& dictionary_text, |
| const GURL& dictionary_url, |