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

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

Issue 2699163002: Whitelist net/ MemoryDumpProvider (Closed)
Patch Set: 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
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("parent");
701 spdy_session_pool_->DumpMemoryStats(process_memory_dump.get(), 711 spdy_session_pool_->DumpMemoryStats(process_memory_dump.get(),
702 parent_dump->absolute_name()); 712 parent_dump->absolute_name());
703 713
704 // Whether SpdySession::DumpMemoryStats() is invoked. 714 // Whether SpdySession::DumpMemoryStats() is invoked.
705 bool did_dump = false; 715 bool did_dump = false;
706 const base::trace_event::ProcessMemoryDump::AllocatorDumpsMap& 716 const base::trace_event::ProcessMemoryDump::AllocatorDumpsMap&
(...skipping 14 matching lines...) Expand all
721 active_session_count_attr->GetString("value", &active_session_count)); 731 active_session_count_attr->GetString("value", &active_session_count));
722 // No created stream so the session should be idle. 732 // No created stream so the session should be idle.
723 ASSERT_EQ("0", active_session_count); 733 ASSERT_EQ("0", active_session_count);
724 did_dump = true; 734 did_dump = true;
725 } 735 }
726 EXPECT_TRUE(did_dump); 736 EXPECT_TRUE(did_dump);
727 spdy_session_pool_->CloseCurrentSessions(ERR_ABORTED); 737 spdy_session_pool_->CloseCurrentSessions(ERR_ABORTED);
728 } 738 }
729 739
730 } // namespace net 740 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698