OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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.h" | 5 #include "net/spdy/spdy_session.h" |
6 | 6 |
7 #include "net/base/cert_test_util.h" | 7 #include "net/base/cert_test_util.h" |
8 #include "net/base/host_cache.h" | 8 #include "net/base/host_cache.h" |
9 #include "net/base/ip_endpoint.h" | 9 #include "net/base/ip_endpoint.h" |
10 #include "net/base/net_log_unittest.h" | 10 #include "net/base/net_log_unittest.h" |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 // Give the session a SPDY3 framer. | 390 // Give the session a SPDY3 framer. |
391 session->buffered_spdy_framer_.reset(new BufferedSpdyFramer(3)); | 391 session->buffered_spdy_framer_.reset(new BufferedSpdyFramer(3)); |
392 | 392 |
393 // Create the associated stream and add to active streams. | 393 // Create the associated stream and add to active streams. |
394 scoped_ptr<SpdyHeaderBlock> request_headers(new SpdyHeaderBlock); | 394 scoped_ptr<SpdyHeaderBlock> request_headers(new SpdyHeaderBlock); |
395 (*request_headers)[":scheme"] = "http"; | 395 (*request_headers)[":scheme"] = "http"; |
396 (*request_headers)[":host"] = "www.google.com"; | 396 (*request_headers)[":host"] = "www.google.com"; |
397 (*request_headers)[":path"] = "/"; | 397 (*request_headers)[":path"] = "/"; |
398 | 398 |
399 scoped_refptr<SpdyStream> stream( | 399 scoped_refptr<SpdyStream> stream( |
400 new SpdyStream(session, false, session->net_log_)); | 400 new SpdyStream(session.get(), false, session->net_log_)); |
401 stream->set_spdy_headers(request_headers.Pass()); | 401 stream->set_spdy_headers(request_headers.Pass()); |
402 session->ActivateStream(stream); | 402 session->ActivateStream(stream.get()); |
403 | 403 |
404 SpdyHeaderBlock headers; | 404 SpdyHeaderBlock headers; |
405 headers[":scheme"] = "http"; | 405 headers[":scheme"] = "http"; |
406 headers[":host"] = "www.google.com"; | 406 headers[":host"] = "www.google.com"; |
407 headers[":path"] = "/a.dat"; | 407 headers[":path"] = "/a.dat"; |
408 session->OnSynStream(2, 1, 0, 0, true, false, headers); | 408 session->OnSynStream(2, 1, 0, 0, true, false, headers); |
409 | 409 |
410 // Verify that there is one unclaimed push stream. | 410 // Verify that there is one unclaimed push stream. |
411 EXPECT_EQ(1u, session->num_unclaimed_pushed_streams()); | 411 EXPECT_EQ(1u, session->num_unclaimed_pushed_streams()); |
412 SpdySession::PushedStreamMap::iterator iter = | 412 SpdySession::PushedStreamMap::iterator iter = |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 spdy_session_pool->CloseIdleSessions(); | 620 spdy_session_pool->CloseIdleSessions(); |
621 EXPECT_TRUE(session1->is_active()); | 621 EXPECT_TRUE(session1->is_active()); |
622 EXPECT_FALSE(session1->IsClosed()); | 622 EXPECT_FALSE(session1->IsClosed()); |
623 EXPECT_TRUE(session2->is_active()); | 623 EXPECT_TRUE(session2->is_active()); |
624 EXPECT_FALSE(session2->IsClosed()); | 624 EXPECT_FALSE(session2->IsClosed()); |
625 EXPECT_TRUE(session3->is_active()); | 625 EXPECT_TRUE(session3->is_active()); |
626 EXPECT_FALSE(session3->IsClosed()); | 626 EXPECT_FALSE(session3->IsClosed()); |
627 | 627 |
628 // Make sessions 1 and 3 inactive, but keep them open. | 628 // Make sessions 1 and 3 inactive, but keep them open. |
629 // Session 2 still open and active | 629 // Session 2 still open and active |
630 session1->CloseCreatedStream(spdy_stream1, OK); | 630 session1->CloseCreatedStream(spdy_stream1.get(), OK); |
631 session3->CloseCreatedStream(spdy_stream3, OK); | 631 session3->CloseCreatedStream(spdy_stream3.get(), OK); |
632 EXPECT_FALSE(session1->is_active()); | 632 EXPECT_FALSE(session1->is_active()); |
633 EXPECT_FALSE(session1->IsClosed()); | 633 EXPECT_FALSE(session1->IsClosed()); |
634 EXPECT_TRUE(session2->is_active()); | 634 EXPECT_TRUE(session2->is_active()); |
635 EXPECT_FALSE(session2->IsClosed()); | 635 EXPECT_FALSE(session2->IsClosed()); |
636 EXPECT_FALSE(session3->is_active()); | 636 EXPECT_FALSE(session3->is_active()); |
637 EXPECT_FALSE(session3->IsClosed()); | 637 EXPECT_FALSE(session3->IsClosed()); |
638 | 638 |
639 // Should close session 1 and 3, 2 should be left open | 639 // Should close session 1 and 3, 2 should be left open |
640 spdy_session_pool->CloseIdleSessions(); | 640 spdy_session_pool->CloseIdleSessions(); |
641 EXPECT_FALSE(session1->is_active()); | 641 EXPECT_FALSE(session1->is_active()); |
642 EXPECT_TRUE(session1->IsClosed()); | 642 EXPECT_TRUE(session1->IsClosed()); |
643 EXPECT_TRUE(session2->is_active()); | 643 EXPECT_TRUE(session2->is_active()); |
644 EXPECT_FALSE(session2->IsClosed()); | 644 EXPECT_FALSE(session2->IsClosed()); |
645 EXPECT_FALSE(session3->is_active()); | 645 EXPECT_FALSE(session3->is_active()); |
646 EXPECT_TRUE(session3->IsClosed()); | 646 EXPECT_TRUE(session3->IsClosed()); |
647 | 647 |
648 // Should not do anything | 648 // Should not do anything |
649 spdy_session_pool->CloseIdleSessions(); | 649 spdy_session_pool->CloseIdleSessions(); |
650 EXPECT_TRUE(session2->is_active()); | 650 EXPECT_TRUE(session2->is_active()); |
651 EXPECT_FALSE(session2->IsClosed()); | 651 EXPECT_FALSE(session2->IsClosed()); |
652 | 652 |
653 // Make 2 not active | 653 // Make 2 not active |
654 session2->CloseCreatedStream(spdy_stream2, OK); | 654 session2->CloseCreatedStream(spdy_stream2.get(), OK); |
655 EXPECT_FALSE(session2->is_active()); | 655 EXPECT_FALSE(session2->is_active()); |
656 EXPECT_FALSE(session2->IsClosed()); | 656 EXPECT_FALSE(session2->IsClosed()); |
657 | 657 |
658 // This should close session 2 | 658 // This should close session 2 |
659 spdy_session_pool->CloseIdleSessions(); | 659 spdy_session_pool->CloseIdleSessions(); |
660 EXPECT_FALSE(session2->is_active()); | 660 EXPECT_FALSE(session2->is_active()); |
661 EXPECT_TRUE(session2->IsClosed()); | 661 EXPECT_TRUE(session2->IsClosed()); |
662 } | 662 } |
663 | 663 |
664 // Start with max concurrent streams set to 1. Request two streams. Receive a | 664 // Start with max concurrent streams set to 1. Request two streams. Receive a |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 scoped_refptr<SpdyStream> spdy_stream1; | 732 scoped_refptr<SpdyStream> spdy_stream1; |
733 TestCompletionCallback callback1; | 733 TestCompletionCallback callback1; |
734 GURL url("http://www.google.com"); | 734 GURL url("http://www.google.com"); |
735 EXPECT_EQ(OK, | 735 EXPECT_EQ(OK, |
736 session->CreateStream(url, | 736 session->CreateStream(url, |
737 MEDIUM, /* priority, not important */ | 737 MEDIUM, /* priority, not important */ |
738 &spdy_stream1, | 738 &spdy_stream1, |
739 BoundNetLog(), | 739 BoundNetLog(), |
740 callback1.callback())); | 740 callback1.callback())); |
741 | 741 |
742 StreamReleaserCallback stream_releaser(session, spdy_stream1); | 742 StreamReleaserCallback stream_releaser(session.get(), spdy_stream1.get()); |
743 | 743 |
744 ASSERT_EQ(ERR_IO_PENDING, | 744 ASSERT_EQ(ERR_IO_PENDING, |
745 session->CreateStream(url, | 745 session->CreateStream(url, |
746 MEDIUM, /* priority, not important */ | 746 MEDIUM, /* priority, not important */ |
747 stream_releaser.stream(), | 747 stream_releaser.stream(), |
748 BoundNetLog(), | 748 BoundNetLog(), |
749 stream_releaser.callback())); | 749 stream_releaser.callback())); |
750 | 750 |
751 // Make sure |stream_releaser| holds the last refs. | 751 // Make sure |stream_releaser| holds the last refs. |
752 session = NULL; | 752 session = NULL; |
(...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1919 BoundNetLog())); | 1919 BoundNetLog())); |
1920 | 1920 |
1921 EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK)); | 1921 EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK)); |
1922 EXPECT_TRUE(session->VerifyDomainAuthentication("www.example.org")); | 1922 EXPECT_TRUE(session->VerifyDomainAuthentication("www.example.org")); |
1923 EXPECT_TRUE(session->VerifyDomainAuthentication("mail.example.org")); | 1923 EXPECT_TRUE(session->VerifyDomainAuthentication("mail.example.org")); |
1924 EXPECT_FALSE(session->VerifyDomainAuthentication("mail.example.com")); | 1924 EXPECT_FALSE(session->VerifyDomainAuthentication("mail.example.com")); |
1925 EXPECT_FALSE(session->VerifyDomainAuthentication("mail.google.com")); | 1925 EXPECT_FALSE(session->VerifyDomainAuthentication("mail.google.com")); |
1926 } | 1926 } |
1927 | 1927 |
1928 } // namespace net | 1928 } // namespace net |
OLD | NEW |