Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Unified Diff: net/ssl/ssl_client_session_cache_unittest.cc

Issue 2541093003: Instrument SSL sockets using MemoryDumpProvider (Closed)
Patch Set: Fix flaky test Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/ssl/ssl_client_session_cache.cc ('k') | net/url_request/url_request_context.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/ssl/ssl_client_session_cache_unittest.cc
diff --git a/net/ssl/ssl_client_session_cache_unittest.cc b/net/ssl/ssl_client_session_cache_unittest.cc
index b3e53469aee04f50866b0fc1cff601667d206891..2f14ae86597a4c1dad691651a7345ccdd797fbb5 100644
--- a/net/ssl/ssl_client_session_cache_unittest.cc
+++ b/net/ssl/ssl_client_session_cache_unittest.cc
@@ -9,6 +9,8 @@
#include "base/strings/string_number_conversions.h"
#include "base/test/simple_test_clock.h"
#include "base/time/time.h"
+#include "base/trace_event/memory_allocator_dump.h"
+#include "base/trace_event/process_memory_dump.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/boringssl/src/include/openssl/ssl.h"
@@ -299,4 +301,40 @@ TEST(SSLClientSessionCacheTest, TestFlushOnMemoryNotifications) {
EXPECT_EQ(0u, cache.size());
}
+// Basic test for dumping memory stats.
+TEST(SSLClientSessionCacheTest, TestDumpMemoryStats) {
+ SSLClientSessionCache::Config config;
+ SSLClientSessionCache cache(config);
+
+ bssl::UniquePtr<SSL_SESSION> session1(SSL_SESSION_new());
+ bssl::UniquePtr<SSL_SESSION> session2(SSL_SESSION_new());
+ bssl::UniquePtr<SSL_SESSION> session3(SSL_SESSION_new());
+
+ // Insert three entries.
+ cache.Insert("key1", session1.get());
+ cache.Insert("key2", session2.get());
+ cache.Insert("key3", session3.get());
+ EXPECT_EQ(session1.get(), cache.Lookup("key1").get());
+ EXPECT_EQ(session2.get(), cache.Lookup("key2").get());
+ EXPECT_EQ(session3.get(), cache.Lookup("key3").get());
+ EXPECT_EQ(3u, cache.size());
+
+ base::trace_event::MemoryDumpArgs dump_args = {
+ base::trace_event::MemoryDumpLevelOfDetail::DETAILED};
+ std::unique_ptr<base::trace_event::ProcessMemoryDump> process_memory_dump(
+ new base::trace_event::ProcessMemoryDump(nullptr, dump_args));
+ cache.DumpMemoryStats(process_memory_dump.get());
+
+ const base::trace_event::ProcessMemoryDump::AllocatorDumpsMap&
+ allocator_dumps = process_memory_dump->allocator_dumps();
+
+ size_t num_entry_dump = 0;
+ for (const auto& pair : allocator_dumps) {
+ const std::string& dump_name = pair.first;
+ if (dump_name.find("net/ssl_session_cache/entry") != std::string::npos)
+ num_entry_dump++;
+ }
+ ASSERT_EQ(3u, num_entry_dump);
+}
+
} // namespace net
« no previous file with comments | « net/ssl/ssl_client_session_cache.cc ('k') | net/url_request/url_request_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698