| 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..d943c1bf1e7501feb547fbcabb50af5611a8b278 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,37 @@ TEST(SSLClientSessionCacheTest, Basic) {
|
| EXPECT_EQ(1u, session3->references);
|
| }
|
|
|
| +// Test that the Net.SSLSessionLookupCount histogram logs calls to Lookup.
|
| +TEST(SSLClientSessionCacheTest, LookupCountUMA) {
|
| + const char kLookupCountHistogram[] = "Net.SSLSessionLookupCount";
|
| + base::HistogramTester histograms;
|
| +
|
| + SSLClientSessionCache::Config config;
|
| + SSLClientSessionCache cache(config);
|
| +
|
| + histograms.ExpectTotalCount(kLookupCountHistogram, 0);
|
| +
|
| + 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.ExpectBucketCount(kLookupCountHistogram, 0, 2);
|
| +
|
| + EXPECT_EQ(session1.get(), cache.Lookup("key1").get());
|
| + histograms.ExpectBucketCount(kLookupCountHistogram, 1, 1);
|
| +
|
| + EXPECT_EQ(session1.get(), cache.Lookup("key1").get());
|
| + histograms.ExpectBucketCount(kLookupCountHistogram, 2, 1);
|
| +
|
| + EXPECT_EQ(session2.get(), cache.Lookup("key2").get());
|
| + histograms.ExpectBucketCount(kLookupCountHistogram, 1, 2);
|
| + // The total value is number of Inserts + number of Lookups, since "0 Lookups"
|
| + // is recorded on Insert.
|
| + histograms.ExpectTotalCount(kLookupCountHistogram, 5);
|
| +
|
| + 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) {
|
|
|