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

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

Issue 2574513002: Do not create sub MemoryAllocatorDumps in SSLClientSessionCache (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « net/ssl/ssl_client_session_cache.cc ('k') | no next file » | 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"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "base/trace_event/memory_allocator_dump.h" 12 #include "base/trace_event/memory_allocator_dump.h"
13 #include "base/trace_event/process_memory_dump.h" 13 #include "base/trace_event/process_memory_dump.h"
14 #include "base/trace_event/trace_event_argument.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 #include "third_party/boringssl/src/include/openssl/ssl.h" 16 #include "third_party/boringssl/src/include/openssl/ssl.h"
16 17
17 namespace net { 18 namespace net {
18 19
19 namespace { 20 namespace {
20 21
21 std::unique_ptr<base::SimpleTestClock> MakeTestClock() { 22 std::unique_ptr<base::SimpleTestClock> MakeTestClock() {
22 std::unique_ptr<base::SimpleTestClock> clock = 23 std::unique_ptr<base::SimpleTestClock> clock =
23 base::MakeUnique<base::SimpleTestClock>(); 24 base::MakeUnique<base::SimpleTestClock>();
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 EXPECT_EQ(session3.get(), cache.Lookup("key3").get()); 320 EXPECT_EQ(session3.get(), cache.Lookup("key3").get());
320 EXPECT_EQ(3u, cache.size()); 321 EXPECT_EQ(3u, cache.size());
321 322
322 base::trace_event::MemoryDumpArgs dump_args = { 323 base::trace_event::MemoryDumpArgs dump_args = {
323 base::trace_event::MemoryDumpLevelOfDetail::DETAILED}; 324 base::trace_event::MemoryDumpLevelOfDetail::DETAILED};
324 std::unique_ptr<base::trace_event::ProcessMemoryDump> process_memory_dump( 325 std::unique_ptr<base::trace_event::ProcessMemoryDump> process_memory_dump(
325 new base::trace_event::ProcessMemoryDump(nullptr, dump_args)); 326 new base::trace_event::ProcessMemoryDump(nullptr, dump_args));
326 cache.DumpMemoryStats(process_memory_dump.get()); 327 cache.DumpMemoryStats(process_memory_dump.get());
327 328
328 const base::trace_event::ProcessMemoryDump::AllocatorDumpsMap& 329 const base::trace_event::ProcessMemoryDump::AllocatorDumpsMap&
329 allocator_dumps = process_memory_dump->allocator_dumps(); 330 allocator_dumps = process_memory_dump->allocator_dumps();
ssid 2016/12/12 20:25:24 You do not need to iterate through the list of dum
xunjieli 2016/12/12 20:49:03 Done.
330 331
331 size_t num_entry_dump = 0; 332 bool did_dump = false;
332 for (const auto& pair : allocator_dumps) { 333 for (const auto& pair : allocator_dumps) {
333 const std::string& dump_name = pair.first; 334 const std::string& dump_name = pair.first;
334 if (dump_name.find("net/ssl_session_cache/entry") != std::string::npos) 335 if (dump_name.find("net/ssl_session_cache") != std::string::npos) {
335 num_entry_dump++; 336 std::unique_ptr<base::Value> raw_attrs =
337 pair.second->attributes_for_testing()->ToBaseValue();
338 base::DictionaryValue* attrs;
339 ASSERT_TRUE(raw_attrs->GetAsDictionary(&attrs));
340 ASSERT_TRUE(attrs->HasKey("cert_count"));
341 ASSERT_TRUE(attrs->HasKey("serialized_cert_size"));
342 ASSERT_TRUE(
343 attrs->HasKey(base::trace_event::MemoryAllocatorDump::kNameSize));
344 did_dump = true;
345 }
336 } 346 }
337 ASSERT_EQ(3u, num_entry_dump); 347 ASSERT_TRUE(did_dump);
338 } 348 }
339 349
340 } // namespace net 350 } // namespace net
OLDNEW
« no previous file with comments | « net/ssl/ssl_client_session_cache.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698