| 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 c9cf6f28c4f19ff4d4f50cadad90c42cfc45584c..f742f08349793ef5fde9c6b2c110d57564d0f02c 100644
|
| --- a/net/ssl/ssl_client_session_cache_unittest.cc
|
| +++ b/net/ssl/ssl_client_session_cache_unittest.cc
|
| @@ -7,6 +7,7 @@
|
| #include "base/memory/ptr_util.h"
|
| #include "base/run_loop.h"
|
| #include "base/strings/string_number_conversions.h"
|
| +#include "base/test/histogram_tester.h"
|
| #include "base/test/simple_test_clock.h"
|
| #include "base/time/time.h"
|
| #include "base/trace_event/memory_allocator_dump.h"
|
| @@ -87,6 +88,50 @@ TEST(SSLClientSessionCacheTest, Basic) {
|
| EXPECT_EQ(1u, session3->references);
|
| }
|
|
|
| +// Test that pairs of calls to Lookup/DecrementLookupCount appropriately log to
|
| +// UMA.
|
| +TEST(SSLClientSessionCacheTest, LookupCountUMA) {
|
| + const char kLookupCountHistogram[] = "Net.SSLSessionConcurrentLookupCount";
|
| + base::HistogramTester histograms;
|
| +
|
| + SSLClientSessionCache::Config config;
|
| + SSLClientSessionCache cache(config);
|
| +
|
| + bssl::UniquePtr<SSL_SESSION> session1(SSL_SESSION_new());
|
| + bssl::UniquePtr<SSL_SESSION> session2(SSL_SESSION_new());
|
| + cache.Insert("key1", session1.get());
|
| + cache.Insert("key2", session2.get());
|
| + histograms.ExpectTotalCount(kLookupCountHistogram, 0);
|
| +
|
| + // Test that multiple lookups of the same key are grouped, but that only the
|
| + // number of concurrent uses is logged, not the total number of uses before
|
| + // the count returns to 0.
|
| + EXPECT_EQ(session1.get(), cache.Lookup("key1").get());
|
| + EXPECT_EQ(session1.get(), cache.Lookup("key1").get());
|
| + cache.DecrementLookupCount("key1", true);
|
| + EXPECT_EQ(session1.get(), cache.Lookup("key1").get());
|
| + cache.DecrementLookupCount("key1", true);
|
| + cache.DecrementLookupCount("key1", true);
|
| + histograms.ExpectBucketCount(kLookupCountHistogram, 2, 1);
|
| +
|
| + // Test that independent keys are logged separately.
|
| + EXPECT_EQ(session1.get(), cache.Lookup("key1").get());
|
| + EXPECT_EQ(session2.get(), cache.Lookup("key2").get());
|
| + cache.DecrementLookupCount("key1", true);
|
| + cache.DecrementLookupCount("key2", true);
|
| + histograms.ExpectBucketCount(kLookupCountHistogram, 1, 2);
|
| +
|
| + histograms.ExpectTotalCount(kLookupCountHistogram, 3);
|
| +
|
| + // Check that nothing gets logged if false is passed into
|
| + // DecrementLookupCount.
|
| + EXPECT_EQ(session1.get(), cache.Lookup("key1").get());
|
| + cache.DecrementLookupCount("key1", false);
|
| + histograms.ExpectTotalCount(kLookupCountHistogram, 3);
|
| +
|
| + EXPECT_EQ(2u, cache.size());
|
| +}
|
| +
|
| // Test that a session may be inserted at two different keys. This should never
|
| // be necessary, but the API doesn't prohibit it.
|
| TEST(SSLClientSessionCacheTest, DoubleInsert) {
|
|
|