| Index: net/ssl/ssl_client_session_cache.cc
|
| diff --git a/net/ssl/ssl_client_session_cache.cc b/net/ssl/ssl_client_session_cache.cc
|
| index fc817fdba0b410f37294f964c63be70d6e7753c4..8665f02d206a29fb61e601d9ac546961da7c43a9 100644
|
| --- a/net/ssl/ssl_client_session_cache.cc
|
| +++ b/net/ssl/ssl_client_session_cache.cc
|
| @@ -4,6 +4,8 @@
|
|
|
| #include "net/ssl/ssl_client_session_cache.h"
|
|
|
| +#include <openssl/ssl.h>
|
| +#include <openssl/x509.h>
|
| #include <utility>
|
|
|
| #include "base/memory/memory_coordinator_client_registry.h"
|
| @@ -11,6 +13,10 @@
|
| #include "base/time/default_clock.h"
|
| #include "third_party/boringssl/src/include/openssl/ssl.h"
|
|
|
| +#include "base/trace_event/memory_dump_manager.h"
|
| +#include "net/cert/x509_util_openssl.h"
|
| +
|
| +#include "base/strings/stringprintf.h"
|
| namespace net {
|
|
|
| SSLClientSessionCache::SSLClientSessionCache(const Config& config)
|
| @@ -82,6 +88,43 @@ bool SSLClientSessionCache::IsExpired(SSL_SESSION* session, time_t now) {
|
| SSL_SESSION_get_time(session) + SSL_SESSION_get_timeout(session);
|
| }
|
|
|
| +void SSLClientSessionCache::PopulateAllocatorDump(
|
| + base::trace_event::MemoryAllocatorDump* dump) const {
|
| + std::string absolute_name = "net/ssl_session_cache";
|
| + base::trace_event::MemoryAllocatorDump* cache_dump =
|
| + dump->process_memory_dump()->GetAllocatorDump(absolute_name);
|
| + // This is a singleton, so only log it once.
|
| + if (cache_dump)
|
| + return;
|
| + cache_dump =
|
| + dump->process_memory_dump()->CreateAllocatorDump(absolute_name);
|
| + auto iter = cache_.begin();
|
| + while (iter != cache_.end()) {
|
| + auto entry = iter->second.get();
|
| + auto cert_chain = entry->cert_chain;
|
| + size_t cert_count = sk_X509_num(cert_chain);
|
| + base::trace_event::MemoryAllocatorDump* entry_dump =
|
| + dump->process_memory_dump()->CreateAllocatorDump(
|
| + base::StringPrintf("%s/entry_%p", absolute_name.c_str(), entry));
|
| + int cert_size = 0;
|
| + for (size_t i = 0; i < cert_count; ++i) {
|
| + X509* cert = sk_X509_value(cert_chain, i);
|
| + cert_size += i2d_X509(cert, nullptr);
|
| + }
|
| + entry_dump->AddScalar("cert_size",
|
| + base::trace_event::MemoryAllocatorDump::kUnitsBytes,
|
| + cert_size);
|
| + entry_dump->AddScalar("cert_count",
|
| + base::trace_event::MemoryAllocatorDump::kUnitsObjects,
|
| + cert_count);
|
| + entry_dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
|
| + base::trace_event::MemoryAllocatorDump::kUnitsBytes,
|
| + cert_size);
|
| +
|
| + ++iter;
|
| + }
|
| +}
|
| +
|
| void SSLClientSessionCache::FlushExpiredSessions() {
|
| time_t now = clock_->Now().ToTimeT();
|
| auto iter = cache_.begin();
|
|
|