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

Side by Side Diff: net/spdy/spdy_session_pool_unittest.cc

Issue 2699163002: Whitelist net/ MemoryDumpProvider (Closed)
Patch Set: fix test on windows Created 3 years, 9 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 | « net/http/http_network_session.cc ('k') | net/ssl/ssl_client_session_cache_unittest.cc » ('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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/spdy/spdy_session_pool.h" 5 #include "net/spdy/spdy_session_pool.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 // FindAvailableSession should return |session| if called with |url| for which 664 // FindAvailableSession should return |session| if called with |url| for which
665 // there is no pushed stream on any sessions owned by |spdy_session_pool_|. 665 // there is no pushed stream on any sessions owned by |spdy_session_pool_|.
666 base::WeakPtr<SpdySession> session2 = 666 base::WeakPtr<SpdySession> session2 =
667 spdy_session_pool_->FindAvailableSession( 667 spdy_session_pool_->FindAvailableSession(
668 key, GURL("http://news.example.org/foo.html"), NetLogWithSource()); 668 key, GURL("http://news.example.org/foo.html"), NetLogWithSource());
669 EXPECT_EQ(session.get(), session2.get()); 669 EXPECT_EQ(session.get(), session2.get());
670 670
671 spdy_session_pool_->CloseCurrentSessions(ERR_ABORTED); 671 spdy_session_pool_->CloseCurrentSessions(ERR_ABORTED);
672 } 672 }
673 673
674 TEST_F(SpdySessionPoolTest, DumpMemoryStats) { 674 class SpdySessionMemoryDumpTest
675 : public SpdySessionPoolTest,
676 public testing::WithParamInterface<
677 base::trace_event::MemoryDumpLevelOfDetail> {};
678
679 INSTANTIATE_TEST_CASE_P(
680 /* no prefix */,
681 SpdySessionMemoryDumpTest,
682 ::testing::Values(base::trace_event::MemoryDumpLevelOfDetail::DETAILED,
683 base::trace_event::MemoryDumpLevelOfDetail::BACKGROUND));
684
685 TEST_P(SpdySessionMemoryDumpTest, DumpMemoryStats) {
675 SpdySessionKey key(HostPortPair("https://www.example.org", 443), 686 SpdySessionKey key(HostPortPair("https://www.example.org", 443),
676 ProxyServer::Direct(), PRIVACY_MODE_DISABLED); 687 ProxyServer::Direct(), PRIVACY_MODE_DISABLED);
677 688
678 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING)}; 689 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING)};
679 StaticSocketDataProvider data(reads, arraysize(reads), nullptr, 0); 690 StaticSocketDataProvider data(reads, arraysize(reads), nullptr, 0);
680 data.set_connect_data(MockConnect(SYNCHRONOUS, OK)); 691 data.set_connect_data(MockConnect(SYNCHRONOUS, OK));
681 session_deps_.socket_factory->AddSocketDataProvider(&data); 692 session_deps_.socket_factory->AddSocketDataProvider(&data);
682 693
683 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); 694 SSLSocketDataProvider ssl(SYNCHRONOUS, OK);
684 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); 695 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
685 696
686 CreateNetworkSession(); 697 CreateNetworkSession();
687 698
688 base::WeakPtr<SpdySession> session = 699 base::WeakPtr<SpdySession> session =
689 CreateSecureSpdySession(http_session_.get(), key, NetLogWithSource()); 700 CreateSecureSpdySession(http_session_.get(), key, NetLogWithSource());
690 701
691 // Flush the SpdySession::OnReadComplete() task. 702 // Flush the SpdySession::OnReadComplete() task.
692 base::RunLoop().RunUntilIdle(); 703 base::RunLoop().RunUntilIdle();
693 704
694 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, key)); 705 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, key));
695 base::trace_event::MemoryDumpArgs dump_args = { 706 base::trace_event::MemoryDumpArgs dump_args = {GetParam()};
696 base::trace_event::MemoryDumpLevelOfDetail::DETAILED};
697 std::unique_ptr<base::trace_event::ProcessMemoryDump> process_memory_dump( 707 std::unique_ptr<base::trace_event::ProcessMemoryDump> process_memory_dump(
698 new base::trace_event::ProcessMemoryDump(nullptr, dump_args)); 708 new base::trace_event::ProcessMemoryDump(nullptr, dump_args));
699 base::trace_event::MemoryAllocatorDump* parent_dump = 709 base::trace_event::MemoryAllocatorDump* parent_dump =
700 process_memory_dump->CreateAllocatorDump("parent"); 710 process_memory_dump->CreateAllocatorDump(
711 "net/http_network_session_0x123");
701 spdy_session_pool_->DumpMemoryStats(process_memory_dump.get(), 712 spdy_session_pool_->DumpMemoryStats(process_memory_dump.get(),
702 parent_dump->absolute_name()); 713 parent_dump->absolute_name());
703 714
704 // Whether SpdySession::DumpMemoryStats() is invoked. 715 // Whether SpdySession::DumpMemoryStats() is invoked.
705 bool did_dump = false; 716 bool did_dump = false;
706 const base::trace_event::ProcessMemoryDump::AllocatorDumpsMap& 717 const base::trace_event::ProcessMemoryDump::AllocatorDumpsMap&
707 allocator_dumps = process_memory_dump->allocator_dumps(); 718 allocator_dumps = process_memory_dump->allocator_dumps();
708 for (const auto& pair : allocator_dumps) { 719 for (const auto& pair : allocator_dumps) {
709 const std::string& dump_name = pair.first; 720 const std::string& dump_name = pair.first;
710 if (dump_name.find("spdy_session_pool") == std::string::npos) 721 if (dump_name.find("spdy_session_pool") == std::string::npos)
(...skipping 10 matching lines...) Expand all
721 active_session_count_attr->GetString("value", &active_session_count)); 732 active_session_count_attr->GetString("value", &active_session_count));
722 // No created stream so the session should be idle. 733 // No created stream so the session should be idle.
723 ASSERT_EQ("0", active_session_count); 734 ASSERT_EQ("0", active_session_count);
724 did_dump = true; 735 did_dump = true;
725 } 736 }
726 EXPECT_TRUE(did_dump); 737 EXPECT_TRUE(did_dump);
727 spdy_session_pool_->CloseCurrentSessions(ERR_ABORTED); 738 spdy_session_pool_->CloseCurrentSessions(ERR_ABORTED);
728 } 739 }
729 740
730 } // namespace net 741 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_session.cc ('k') | net/ssl/ssl_client_session_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698