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

Side by Side Diff: net/ssl/ssl_client_session_cache_unittest.cc

Issue 2695223006: Roll src/third_party/boringssl/src dc8c1d962..0f28691d3 (Closed)
Patch Set: Use correct parent. Created 3 years, 10 months 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 unified diff | Download patch
« no previous file with comments | « DEPS ('k') | third_party/boringssl/BUILD.generated.gni » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/ssl/ssl_client_session_cache.h" 5 #include "net/ssl/ssl_client_session_cache.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/test/simple_test_clock.h" 10 #include "base/test/simple_test_clock.h"
(...skipping 10 matching lines...) Expand all
21 21
22 std::unique_ptr<base::SimpleTestClock> MakeTestClock() { 22 std::unique_ptr<base::SimpleTestClock> MakeTestClock() {
23 std::unique_ptr<base::SimpleTestClock> clock = 23 std::unique_ptr<base::SimpleTestClock> clock =
24 base::MakeUnique<base::SimpleTestClock>(); 24 base::MakeUnique<base::SimpleTestClock>();
25 // SimpleTestClock starts at the null base::Time which converts to and from 25 // SimpleTestClock starts at the null base::Time which converts to and from
26 // time_t confusingly. 26 // time_t confusingly.
27 clock->SetNow(base::Time::FromTimeT(1000000000)); 27 clock->SetNow(base::Time::FromTimeT(1000000000));
28 return clock; 28 return clock;
29 } 29 }
30 30
31 bssl::UniquePtr<SSL_SESSION> MakeTestSession(base::Time now, 31 class SSLClientSessionCacheTest : public testing::Test {
32 base::TimeDelta timeout) { 32 public:
33 bssl::UniquePtr<SSL_SESSION> session(SSL_SESSION_new()); 33 SSLClientSessionCacheTest() : ssl_ctx_(SSL_CTX_new(TLS_method())) {}
34 SSL_SESSION_set_time(session.get(), now.ToTimeT()); 34
35 SSL_SESSION_set_timeout(session.get(), timeout.InSeconds()); 35 protected:
36 return session; 36 bssl::UniquePtr<SSL_SESSION> NewSSLSession() {
37 } 37 return bssl::UniquePtr<SSL_SESSION>(SSL_SESSION_new(ssl_ctx_.get()));
38 }
39
40 bssl::UniquePtr<SSL_SESSION> MakeTestSession(base::Time now,
41 base::TimeDelta timeout) {
42 bssl::UniquePtr<SSL_SESSION> session = NewSSLSession();
43 SSL_SESSION_set_time(session.get(), now.ToTimeT());
44 SSL_SESSION_set_timeout(session.get(), timeout.InSeconds());
45 return session;
46 }
47
48 private:
49 bssl::UniquePtr<SSL_CTX> ssl_ctx_;
50 };
38 51
39 } // namespace 52 } // namespace
40 53
41 // Test basic insertion and lookup operations. 54 // Test basic insertion and lookup operations.
42 TEST(SSLClientSessionCacheTest, Basic) { 55 TEST_F(SSLClientSessionCacheTest, Basic) {
43 SSLClientSessionCache::Config config; 56 SSLClientSessionCache::Config config;
44 SSLClientSessionCache cache(config); 57 SSLClientSessionCache cache(config);
45 58
46 bssl::UniquePtr<SSL_SESSION> session1(SSL_SESSION_new()); 59 bssl::UniquePtr<SSL_SESSION> session1 = NewSSLSession();
47 bssl::UniquePtr<SSL_SESSION> session2(SSL_SESSION_new()); 60 bssl::UniquePtr<SSL_SESSION> session2 = NewSSLSession();
48 bssl::UniquePtr<SSL_SESSION> session3(SSL_SESSION_new()); 61 bssl::UniquePtr<SSL_SESSION> session3 = NewSSLSession();
49 EXPECT_EQ(1u, session1->references); 62 EXPECT_EQ(1u, session1->references);
50 EXPECT_EQ(1u, session2->references); 63 EXPECT_EQ(1u, session2->references);
51 EXPECT_EQ(1u, session3->references); 64 EXPECT_EQ(1u, session3->references);
52 65
53 EXPECT_EQ(nullptr, cache.Lookup("key1", nullptr).get()); 66 EXPECT_EQ(nullptr, cache.Lookup("key1", nullptr).get());
54 EXPECT_EQ(nullptr, cache.Lookup("key2", nullptr).get()); 67 EXPECT_EQ(nullptr, cache.Lookup("key2", nullptr).get());
55 EXPECT_EQ(0u, cache.size()); 68 EXPECT_EQ(0u, cache.size());
56 69
57 cache.Insert("key1", session1.get()); 70 cache.Insert("key1", session1.get());
58 EXPECT_EQ(session1.get(), cache.Lookup("key1", nullptr).get()); 71 EXPECT_EQ(session1.get(), cache.Lookup("key1", nullptr).get());
(...skipping 23 matching lines...) Expand all
82 EXPECT_EQ(nullptr, cache.Lookup("key3", nullptr).get()); 95 EXPECT_EQ(nullptr, cache.Lookup("key3", nullptr).get());
83 EXPECT_EQ(0u, cache.size()); 96 EXPECT_EQ(0u, cache.size());
84 97
85 EXPECT_EQ(1u, session1->references); 98 EXPECT_EQ(1u, session1->references);
86 EXPECT_EQ(1u, session2->references); 99 EXPECT_EQ(1u, session2->references);
87 EXPECT_EQ(1u, session3->references); 100 EXPECT_EQ(1u, session3->references);
88 } 101 }
89 102
90 // Test that pairs of calls to Lookup/ResetLookupCount appropriately log to 103 // Test that pairs of calls to Lookup/ResetLookupCount appropriately log to
91 // UMA. 104 // UMA.
92 TEST(SSLClientSessionCacheTest, LookupCountUMA) { 105 TEST_F(SSLClientSessionCacheTest, LookupCountUMA) {
93 SSLClientSessionCache::Config config; 106 SSLClientSessionCache::Config config;
94 SSLClientSessionCache cache(config); 107 SSLClientSessionCache cache(config);
95 108
96 bssl::UniquePtr<SSL_SESSION> session1(SSL_SESSION_new()); 109 bssl::UniquePtr<SSL_SESSION> session1 = NewSSLSession();
97 bssl::UniquePtr<SSL_SESSION> session2(SSL_SESSION_new()); 110 bssl::UniquePtr<SSL_SESSION> session2 = NewSSLSession();
98 cache.Insert("key1", session1.get()); 111 cache.Insert("key1", session1.get());
99 cache.Insert("key2", session2.get()); 112 cache.Insert("key2", session2.get());
100 113
101 // Test that the count returned increments when multiple lookups of the same 114 // Test that the count returned increments when multiple lookups of the same
102 // key/session occur before the count is reset. 115 // key/session occur before the count is reset.
103 int count; 116 int count;
104 EXPECT_EQ(session1.get(), cache.Lookup("key1", &count).get()); 117 EXPECT_EQ(session1.get(), cache.Lookup("key1", &count).get());
105 EXPECT_EQ(1, count); 118 EXPECT_EQ(1, count);
106 EXPECT_EQ(session1.get(), cache.Lookup("key1", &count).get()); 119 EXPECT_EQ(session1.get(), cache.Lookup("key1", &count).get());
107 EXPECT_EQ(2, count); 120 EXPECT_EQ(2, count);
(...skipping 13 matching lines...) Expand all
121 EXPECT_EQ(0, count); 134 EXPECT_EQ(0, count);
122 135
123 // Check that ResetLookupCount doesn't explode if there's a cache miss. 136 // Check that ResetLookupCount doesn't explode if there's a cache miss.
124 cache.ResetLookupCount("not present"); 137 cache.ResetLookupCount("not present");
125 138
126 EXPECT_EQ(2u, cache.size()); 139 EXPECT_EQ(2u, cache.size());
127 } 140 }
128 141
129 // Test that a session may be inserted at two different keys. This should never 142 // Test that a session may be inserted at two different keys. This should never
130 // be necessary, but the API doesn't prohibit it. 143 // be necessary, but the API doesn't prohibit it.
131 TEST(SSLClientSessionCacheTest, DoubleInsert) { 144 TEST_F(SSLClientSessionCacheTest, DoubleInsert) {
132 SSLClientSessionCache::Config config; 145 SSLClientSessionCache::Config config;
133 SSLClientSessionCache cache(config); 146 SSLClientSessionCache cache(config);
134 147
135 bssl::UniquePtr<SSL_SESSION> session(SSL_SESSION_new()); 148 bssl::UniquePtr<SSL_SESSION> session = NewSSLSession();
136 EXPECT_EQ(1u, session->references); 149 EXPECT_EQ(1u, session->references);
137 150
138 EXPECT_EQ(nullptr, cache.Lookup("key1", nullptr).get()); 151 EXPECT_EQ(nullptr, cache.Lookup("key1", nullptr).get());
139 EXPECT_EQ(nullptr, cache.Lookup("key2", nullptr).get()); 152 EXPECT_EQ(nullptr, cache.Lookup("key2", nullptr).get());
140 EXPECT_EQ(0u, cache.size()); 153 EXPECT_EQ(0u, cache.size());
141 154
142 cache.Insert("key1", session.get()); 155 cache.Insert("key1", session.get());
143 EXPECT_EQ(session.get(), cache.Lookup("key1", nullptr).get()); 156 EXPECT_EQ(session.get(), cache.Lookup("key1", nullptr).get());
144 EXPECT_EQ(nullptr, cache.Lookup("key2", nullptr).get()); 157 EXPECT_EQ(nullptr, cache.Lookup("key2", nullptr).get());
145 EXPECT_EQ(1u, cache.size()); 158 EXPECT_EQ(1u, cache.size());
146 159
147 EXPECT_EQ(2u, session->references); 160 EXPECT_EQ(2u, session->references);
148 161
149 cache.Insert("key2", session.get()); 162 cache.Insert("key2", session.get());
150 EXPECT_EQ(session.get(), cache.Lookup("key1", nullptr).get()); 163 EXPECT_EQ(session.get(), cache.Lookup("key1", nullptr).get());
151 EXPECT_EQ(session.get(), cache.Lookup("key2", nullptr).get()); 164 EXPECT_EQ(session.get(), cache.Lookup("key2", nullptr).get());
152 EXPECT_EQ(2u, cache.size()); 165 EXPECT_EQ(2u, cache.size());
153 166
154 EXPECT_EQ(3u, session->references); 167 EXPECT_EQ(3u, session->references);
155 168
156 cache.Flush(); 169 cache.Flush();
157 EXPECT_EQ(nullptr, cache.Lookup("key1", nullptr).get()); 170 EXPECT_EQ(nullptr, cache.Lookup("key1", nullptr).get());
158 EXPECT_EQ(nullptr, cache.Lookup("key2", nullptr).get()); 171 EXPECT_EQ(nullptr, cache.Lookup("key2", nullptr).get());
159 EXPECT_EQ(0u, cache.size()); 172 EXPECT_EQ(0u, cache.size());
160 173
161 EXPECT_EQ(1u, session->references); 174 EXPECT_EQ(1u, session->references);
162 } 175 }
163 176
164 // Tests that the session cache's size is correctly bounded. 177 // Tests that the session cache's size is correctly bounded.
165 TEST(SSLClientSessionCacheTest, MaxEntries) { 178 TEST_F(SSLClientSessionCacheTest, MaxEntries) {
166 SSLClientSessionCache::Config config; 179 SSLClientSessionCache::Config config;
167 config.max_entries = 3; 180 config.max_entries = 3;
168 SSLClientSessionCache cache(config); 181 SSLClientSessionCache cache(config);
169 182
170 bssl::UniquePtr<SSL_SESSION> session1(SSL_SESSION_new()); 183 bssl::UniquePtr<SSL_SESSION> session1 = NewSSLSession();
171 bssl::UniquePtr<SSL_SESSION> session2(SSL_SESSION_new()); 184 bssl::UniquePtr<SSL_SESSION> session2 = NewSSLSession();
172 bssl::UniquePtr<SSL_SESSION> session3(SSL_SESSION_new()); 185 bssl::UniquePtr<SSL_SESSION> session3 = NewSSLSession();
173 bssl::UniquePtr<SSL_SESSION> session4(SSL_SESSION_new()); 186 bssl::UniquePtr<SSL_SESSION> session4 = NewSSLSession();
174 187
175 // Insert three entries. 188 // Insert three entries.
176 cache.Insert("key1", session1.get()); 189 cache.Insert("key1", session1.get());
177 cache.Insert("key2", session2.get()); 190 cache.Insert("key2", session2.get());
178 cache.Insert("key3", session3.get()); 191 cache.Insert("key3", session3.get());
179 EXPECT_EQ(session1.get(), cache.Lookup("key1", nullptr).get()); 192 EXPECT_EQ(session1.get(), cache.Lookup("key1", nullptr).get());
180 EXPECT_EQ(session2.get(), cache.Lookup("key2", nullptr).get()); 193 EXPECT_EQ(session2.get(), cache.Lookup("key2", nullptr).get());
181 EXPECT_EQ(session3.get(), cache.Lookup("key3", nullptr).get()); 194 EXPECT_EQ(session3.get(), cache.Lookup("key3", nullptr).get());
182 EXPECT_EQ(3u, cache.size()); 195 EXPECT_EQ(3u, cache.size());
183 196
184 // On insertion of a fourth, the first is removed. 197 // On insertion of a fourth, the first is removed.
185 cache.Insert("key4", session4.get()); 198 cache.Insert("key4", session4.get());
186 EXPECT_EQ(nullptr, cache.Lookup("key1", nullptr).get()); 199 EXPECT_EQ(nullptr, cache.Lookup("key1", nullptr).get());
187 EXPECT_EQ(session4.get(), cache.Lookup("key4", nullptr).get()); 200 EXPECT_EQ(session4.get(), cache.Lookup("key4", nullptr).get());
188 EXPECT_EQ(session3.get(), cache.Lookup("key3", nullptr).get()); 201 EXPECT_EQ(session3.get(), cache.Lookup("key3", nullptr).get());
189 EXPECT_EQ(session2.get(), cache.Lookup("key2", nullptr).get()); 202 EXPECT_EQ(session2.get(), cache.Lookup("key2", nullptr).get());
190 EXPECT_EQ(3u, cache.size()); 203 EXPECT_EQ(3u, cache.size());
191 204
192 // Despite being newest, the next to be removed is session4 as it was accessed 205 // Despite being newest, the next to be removed is session4 as it was accessed
193 // least. recently. 206 // least. recently.
194 cache.Insert("key1", session1.get()); 207 cache.Insert("key1", session1.get());
195 EXPECT_EQ(session1.get(), cache.Lookup("key1", nullptr).get()); 208 EXPECT_EQ(session1.get(), cache.Lookup("key1", nullptr).get());
196 EXPECT_EQ(session2.get(), cache.Lookup("key2", nullptr).get()); 209 EXPECT_EQ(session2.get(), cache.Lookup("key2", nullptr).get());
197 EXPECT_EQ(session3.get(), cache.Lookup("key3", nullptr).get()); 210 EXPECT_EQ(session3.get(), cache.Lookup("key3", nullptr).get());
198 EXPECT_EQ(nullptr, cache.Lookup("key4", nullptr).get()); 211 EXPECT_EQ(nullptr, cache.Lookup("key4", nullptr).get());
199 EXPECT_EQ(3u, cache.size()); 212 EXPECT_EQ(3u, cache.size());
200 } 213 }
201 214
202 // Tests that session expiration works properly. 215 // Tests that session expiration works properly.
203 TEST(SSLClientSessionCacheTest, Expiration) { 216 TEST_F(SSLClientSessionCacheTest, Expiration) {
204 const size_t kNumEntries = 20; 217 const size_t kNumEntries = 20;
205 const size_t kExpirationCheckCount = 10; 218 const size_t kExpirationCheckCount = 10;
206 const base::TimeDelta kTimeout = base::TimeDelta::FromSeconds(1000); 219 const base::TimeDelta kTimeout = base::TimeDelta::FromSeconds(1000);
207 220
208 SSLClientSessionCache::Config config; 221 SSLClientSessionCache::Config config;
209 config.expiration_check_count = kExpirationCheckCount; 222 config.expiration_check_count = kExpirationCheckCount;
210 SSLClientSessionCache cache(config); 223 SSLClientSessionCache cache(config);
211 base::SimpleTestClock* clock = MakeTestClock().release(); 224 base::SimpleTestClock* clock = MakeTestClock().release();
212 cache.SetClockForTesting(base::WrapUnique(clock)); 225 cache.SetClockForTesting(base::WrapUnique(clock));
213 226
(...skipping 27 matching lines...) Expand all
241 EXPECT_EQ(1u, cache.size()); 254 EXPECT_EQ(1u, cache.size());
242 EXPECT_EQ(session.get(), cache.Lookup("key", nullptr).get()); 255 EXPECT_EQ(session.get(), cache.Lookup("key", nullptr).get());
243 for (size_t i = 0; i < kNumEntries - 1; i++) { 256 for (size_t i = 0; i < kNumEntries - 1; i++) {
244 SCOPED_TRACE(i); 257 SCOPED_TRACE(i);
245 EXPECT_EQ(nullptr, cache.Lookup(base::SizeTToString(i), nullptr)); 258 EXPECT_EQ(nullptr, cache.Lookup(base::SizeTToString(i), nullptr));
246 } 259 }
247 } 260 }
248 261
249 // Tests that Lookup performs an expiration check before returning a cached 262 // Tests that Lookup performs an expiration check before returning a cached
250 // session. 263 // session.
251 TEST(SSLClientSessionCacheTest, LookupExpirationCheck) { 264 TEST_F(SSLClientSessionCacheTest, LookupExpirationCheck) {
252 // kExpirationCheckCount is set to a suitably large number so the automated 265 // kExpirationCheckCount is set to a suitably large number so the automated
253 // pruning never triggers. 266 // pruning never triggers.
254 const size_t kExpirationCheckCount = 1000; 267 const size_t kExpirationCheckCount = 1000;
255 const base::TimeDelta kTimeout = base::TimeDelta::FromSeconds(1000); 268 const base::TimeDelta kTimeout = base::TimeDelta::FromSeconds(1000);
256 269
257 SSLClientSessionCache::Config config; 270 SSLClientSessionCache::Config config;
258 config.expiration_check_count = kExpirationCheckCount; 271 config.expiration_check_count = kExpirationCheckCount;
259 SSLClientSessionCache cache(config); 272 SSLClientSessionCache cache(config);
260 base::SimpleTestClock* clock = MakeTestClock().release(); 273 base::SimpleTestClock* clock = MakeTestClock().release();
261 cache.SetClockForTesting(base::WrapUnique(clock)); 274 cache.SetClockForTesting(base::WrapUnique(clock));
(...skipping 27 matching lines...) Expand all
289 EXPECT_EQ(session.get(), cache.Lookup("key", nullptr).get()); 302 EXPECT_EQ(session.get(), cache.Lookup("key", nullptr).get());
290 EXPECT_EQ(1u, cache.size()); 303 EXPECT_EQ(1u, cache.size());
291 304
292 // Sessions also are treated as expired if the clock rewinds. 305 // Sessions also are treated as expired if the clock rewinds.
293 clock->Advance(base::TimeDelta::FromSeconds(-1)); 306 clock->Advance(base::TimeDelta::FromSeconds(-1));
294 EXPECT_EQ(nullptr, cache.Lookup("key", nullptr).get()); 307 EXPECT_EQ(nullptr, cache.Lookup("key", nullptr).get());
295 EXPECT_EQ(0u, cache.size()); 308 EXPECT_EQ(0u, cache.size());
296 } 309 }
297 310
298 // Test that SSL cache is flushed on low memory notifications 311 // Test that SSL cache is flushed on low memory notifications
299 TEST(SSLClientSessionCacheTest, TestFlushOnMemoryNotifications) { 312 TEST_F(SSLClientSessionCacheTest, TestFlushOnMemoryNotifications) {
300 // kExpirationCheckCount is set to a suitably large number so the automated 313 // kExpirationCheckCount is set to a suitably large number so the automated
301 // pruning never triggers. 314 // pruning never triggers.
302 const size_t kExpirationCheckCount = 1000; 315 const size_t kExpirationCheckCount = 1000;
303 const base::TimeDelta kTimeout = base::TimeDelta::FromSeconds(1000); 316 const base::TimeDelta kTimeout = base::TimeDelta::FromSeconds(1000);
304 317
305 SSLClientSessionCache::Config config; 318 SSLClientSessionCache::Config config;
306 config.expiration_check_count = kExpirationCheckCount; 319 config.expiration_check_count = kExpirationCheckCount;
307 SSLClientSessionCache cache(config); 320 SSLClientSessionCache cache(config);
308 base::SimpleTestClock* clock = MakeTestClock().release(); 321 base::SimpleTestClock* clock = MakeTestClock().release();
309 cache.SetClockForTesting(base::WrapUnique(clock)); 322 cache.SetClockForTesting(base::WrapUnique(clock));
(...skipping 25 matching lines...) Expand all
335 EXPECT_EQ(1u, cache.size()); 348 EXPECT_EQ(1u, cache.size());
336 349
337 // Fire notification that will flush everything. 350 // Fire notification that will flush everything.
338 base::MemoryPressureListener::NotifyMemoryPressure( 351 base::MemoryPressureListener::NotifyMemoryPressure(
339 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL); 352 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL);
340 base::RunLoop().RunUntilIdle(); 353 base::RunLoop().RunUntilIdle();
341 EXPECT_EQ(0u, cache.size()); 354 EXPECT_EQ(0u, cache.size());
342 } 355 }
343 356
344 // Basic test for dumping memory stats. 357 // Basic test for dumping memory stats.
345 TEST(SSLClientSessionCacheTest, TestDumpMemoryStats) { 358 TEST_F(SSLClientSessionCacheTest, TestDumpMemoryStats) {
346 SSLClientSessionCache::Config config; 359 SSLClientSessionCache::Config config;
347 SSLClientSessionCache cache(config); 360 SSLClientSessionCache cache(config);
348 361
349 bssl::UniquePtr<SSL_SESSION> session1(SSL_SESSION_new()); 362 bssl::UniquePtr<SSL_SESSION> session1 = NewSSLSession();
350 bssl::UniquePtr<SSL_SESSION> session2(SSL_SESSION_new()); 363 bssl::UniquePtr<SSL_SESSION> session2 = NewSSLSession();
351 bssl::UniquePtr<SSL_SESSION> session3(SSL_SESSION_new()); 364 bssl::UniquePtr<SSL_SESSION> session3 = NewSSLSession();
352 365
353 // Insert three entries. 366 // Insert three entries.
354 cache.Insert("key1", session1.get()); 367 cache.Insert("key1", session1.get());
355 cache.Insert("key2", session2.get()); 368 cache.Insert("key2", session2.get());
356 cache.Insert("key3", session3.get()); 369 cache.Insert("key3", session3.get());
357 EXPECT_EQ(session1.get(), cache.Lookup("key1", nullptr).get()); 370 EXPECT_EQ(session1.get(), cache.Lookup("key1", nullptr).get());
358 EXPECT_EQ(session2.get(), cache.Lookup("key2", nullptr).get()); 371 EXPECT_EQ(session2.get(), cache.Lookup("key2", nullptr).get());
359 EXPECT_EQ(session3.get(), cache.Lookup("key3", nullptr).get()); 372 EXPECT_EQ(session3.get(), cache.Lookup("key3", nullptr).get());
360 EXPECT_EQ(3u, cache.size()); 373 EXPECT_EQ(3u, cache.size());
361 374
362 base::trace_event::MemoryDumpArgs dump_args = { 375 base::trace_event::MemoryDumpArgs dump_args = {
363 base::trace_event::MemoryDumpLevelOfDetail::DETAILED}; 376 base::trace_event::MemoryDumpLevelOfDetail::DETAILED};
364 std::unique_ptr<base::trace_event::ProcessMemoryDump> process_memory_dump( 377 std::unique_ptr<base::trace_event::ProcessMemoryDump> process_memory_dump(
365 new base::trace_event::ProcessMemoryDump(nullptr, dump_args)); 378 new base::trace_event::ProcessMemoryDump(nullptr, dump_args));
366 cache.DumpMemoryStats(process_memory_dump.get()); 379 cache.DumpMemoryStats(process_memory_dump.get());
367 380
368 const base::trace_event::MemoryAllocatorDump* dump = 381 const base::trace_event::MemoryAllocatorDump* dump =
369 process_memory_dump->GetAllocatorDump("net/ssl_session_cache"); 382 process_memory_dump->GetAllocatorDump("net/ssl_session_cache");
370 ASSERT_NE(nullptr, dump); 383 ASSERT_NE(nullptr, dump);
371 std::unique_ptr<base::Value> raw_attrs = 384 std::unique_ptr<base::Value> raw_attrs =
372 dump->attributes_for_testing()->ToBaseValue(); 385 dump->attributes_for_testing()->ToBaseValue();
373 base::DictionaryValue* attrs; 386 base::DictionaryValue* attrs;
374 ASSERT_TRUE(raw_attrs->GetAsDictionary(&attrs)); 387 ASSERT_TRUE(raw_attrs->GetAsDictionary(&attrs));
375 ASSERT_TRUE(attrs->HasKey("cert_count")); 388 ASSERT_TRUE(attrs->HasKey("cert_count"));
376 ASSERT_TRUE(attrs->HasKey("serialized_cert_size")); 389 ASSERT_TRUE(attrs->HasKey("serialized_cert_size"));
377 ASSERT_TRUE(attrs->HasKey(base::trace_event::MemoryAllocatorDump::kNameSize)); 390 ASSERT_TRUE(attrs->HasKey(base::trace_event::MemoryAllocatorDump::kNameSize));
378 } 391 }
379 392
380 } // namespace net 393 } // namespace net
OLDNEW
« no previous file with comments | « DEPS ('k') | third_party/boringssl/BUILD.generated.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698