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

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

Issue 200723004: Fix SPDY error-handling if the connection gets closed just after use. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « net/spdy/spdy_test_util_common.h ('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 (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_test_util_common.h" 5 #include "net/spdy/spdy_test_util_common.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 http_session->GetTransportSocketPool( 533 http_session->GetTransportSocketPool(
534 HttpNetworkSession::NORMAL_SOCKET_POOL), 534 HttpNetworkSession::NORMAL_SOCKET_POOL),
535 net_log); 535 net_log);
536 } 536 }
537 537
538 if (rv == ERR_IO_PENDING) 538 if (rv == ERR_IO_PENDING)
539 rv = callback.WaitForResult(); 539 rv = callback.WaitForResult();
540 540
541 EXPECT_EQ(OK, rv); 541 EXPECT_EQ(OK, rv);
542 542
543 base::WeakPtr<SpdySession> spdy_session; 543 base::WeakPtr<SpdySession> spdy_session =
544 EXPECT_EQ(
545 expected_status,
546 http_session->spdy_session_pool()->CreateAvailableSessionFromSocket( 544 http_session->spdy_session_pool()->CreateAvailableSessionFromSocket(
547 key, connection.Pass(), net_log, OK, &spdy_session, 545 key, connection.Pass(), net_log, OK, is_secure);
548 is_secure)); 546 // Failure is reported asynchronously.
549 EXPECT_EQ(expected_status == OK, spdy_session != NULL); 547 EXPECT_TRUE(spdy_session != NULL);
550 EXPECT_EQ(expected_status == OK, 548 EXPECT_TRUE(HasSpdySession(http_session->spdy_session_pool(), key));
551 HasSpdySession(http_session->spdy_session_pool(), key));
552 return spdy_session; 549 return spdy_session;
553 } 550 }
554 551
555 } // namespace 552 } // namespace
556 553
557 base::WeakPtr<SpdySession> CreateInsecureSpdySession( 554 base::WeakPtr<SpdySession> CreateInsecureSpdySession(
558 const scoped_refptr<HttpNetworkSession>& http_session, 555 const scoped_refptr<HttpNetworkSession>& http_session,
559 const SpdySessionKey& key, 556 const SpdySessionKey& key,
560 const BoundNetLog& net_log) { 557 const BoundNetLog& net_log) {
561 return CreateSpdySessionHelper(http_session, key, net_log, 558 return CreateSpdySessionHelper(http_session, key, net_log,
562 OK, false /* is_secure */); 559 OK, false /* is_secure */);
563 } 560 }
564 561
565 void TryCreateInsecureSpdySessionExpectingFailure( 562 base::WeakPtr<SpdySession> TryCreateInsecureSpdySessionExpectingFailure(
566 const scoped_refptr<HttpNetworkSession>& http_session, 563 const scoped_refptr<HttpNetworkSession>& http_session,
567 const SpdySessionKey& key, 564 const SpdySessionKey& key,
568 Error expected_error, 565 Error expected_error,
569 const BoundNetLog& net_log) { 566 const BoundNetLog& net_log) {
570 DCHECK_LT(expected_error, ERR_IO_PENDING); 567 DCHECK_LT(expected_error, ERR_IO_PENDING);
571 CreateSpdySessionHelper(http_session, key, net_log, 568 return CreateSpdySessionHelper(http_session, key, net_log,
572 expected_error, false /* is_secure */); 569 expected_error, false /* is_secure */);
573 } 570 }
574 571
575 base::WeakPtr<SpdySession> CreateSecureSpdySession( 572 base::WeakPtr<SpdySession> CreateSecureSpdySession(
576 const scoped_refptr<HttpNetworkSession>& http_session, 573 const scoped_refptr<HttpNetworkSession>& http_session,
577 const SpdySessionKey& key, 574 const SpdySessionKey& key,
578 const BoundNetLog& net_log) { 575 const BoundNetLog& net_log) {
579 return CreateSpdySessionHelper(http_session, key, net_log, 576 return CreateSpdySessionHelper(http_session, key, net_log,
580 OK, true /* is_secure */); 577 OK, true /* is_secure */);
581 } 578 }
582 579
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 private: 633 private:
637 int read_result_; 634 int read_result_;
638 }; 635 };
639 636
640 base::WeakPtr<SpdySession> CreateFakeSpdySessionHelper( 637 base::WeakPtr<SpdySession> CreateFakeSpdySessionHelper(
641 SpdySessionPool* pool, 638 SpdySessionPool* pool,
642 const SpdySessionKey& key, 639 const SpdySessionKey& key,
643 Error expected_status) { 640 Error expected_status) {
644 EXPECT_NE(expected_status, ERR_IO_PENDING); 641 EXPECT_NE(expected_status, ERR_IO_PENDING);
645 EXPECT_FALSE(HasSpdySession(pool, key)); 642 EXPECT_FALSE(HasSpdySession(pool, key));
646 base::WeakPtr<SpdySession> spdy_session;
647 scoped_ptr<ClientSocketHandle> handle(new ClientSocketHandle()); 643 scoped_ptr<ClientSocketHandle> handle(new ClientSocketHandle());
648 handle->SetSocket(scoped_ptr<StreamSocket>(new FakeSpdySessionClientSocket( 644 handle->SetSocket(scoped_ptr<StreamSocket>(new FakeSpdySessionClientSocket(
649 expected_status == OK ? ERR_IO_PENDING : expected_status))); 645 expected_status == OK ? ERR_IO_PENDING : expected_status)));
650 EXPECT_EQ( 646 base::WeakPtr<SpdySession> spdy_session =
651 expected_status,
652 pool->CreateAvailableSessionFromSocket( 647 pool->CreateAvailableSessionFromSocket(
653 key, handle.Pass(), BoundNetLog(), OK, &spdy_session, 648 key, handle.Pass(), BoundNetLog(), OK, true /* is_secure */);
654 true /* is_secure */)); 649 // Failure is reported asynchronously.
655 EXPECT_EQ(expected_status == OK, spdy_session != NULL); 650 EXPECT_TRUE(spdy_session != NULL);
656 EXPECT_EQ(expected_status == OK, HasSpdySession(pool, key)); 651 EXPECT_TRUE(HasSpdySession(pool, key));
657 return spdy_session; 652 return spdy_session;
658 } 653 }
659 654
660 } // namespace 655 } // namespace
661 656
662 base::WeakPtr<SpdySession> CreateFakeSpdySession(SpdySessionPool* pool, 657 base::WeakPtr<SpdySession> CreateFakeSpdySession(SpdySessionPool* pool,
663 const SpdySessionKey& key) { 658 const SpdySessionKey& key) {
664 return CreateFakeSpdySessionHelper(pool, key, OK); 659 return CreateFakeSpdySessionHelper(pool, key, OK);
665 } 660 }
666 661
667 void TryCreateFakeSpdySessionExpectingFailure(SpdySessionPool* pool, 662 base::WeakPtr<SpdySession> TryCreateFakeSpdySessionExpectingFailure(
668 const SpdySessionKey& key, 663 SpdySessionPool* pool,
669 Error expected_error) { 664 const SpdySessionKey& key,
665 Error expected_error) {
670 DCHECK_LT(expected_error, ERR_IO_PENDING); 666 DCHECK_LT(expected_error, ERR_IO_PENDING);
671 CreateFakeSpdySessionHelper(pool, key, expected_error); 667 return CreateFakeSpdySessionHelper(pool, key, expected_error);
672 } 668 }
673 669
674 SpdySessionPoolPeer::SpdySessionPoolPeer(SpdySessionPool* pool) : pool_(pool) { 670 SpdySessionPoolPeer::SpdySessionPoolPeer(SpdySessionPool* pool) : pool_(pool) {
675 } 671 }
676 672
677 void SpdySessionPoolPeer::RemoveAliases(const SpdySessionKey& key) { 673 void SpdySessionPoolPeer::RemoveAliases(const SpdySessionKey& key) {
678 pool_->RemoveAliases(key); 674 pool_->RemoveAliases(key);
679 } 675 }
680 676
681 void SpdySessionPoolPeer::DisableDomainAuthenticationVerification() { 677 void SpdySessionPoolPeer::DisableDomainAuthenticationVerification() {
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 (*headers)[GetSchemeKey()] = scheme.c_str(); 1233 (*headers)[GetSchemeKey()] = scheme.c_str();
1238 (*headers)[GetVersionKey()] = "HTTP/1.1"; 1234 (*headers)[GetVersionKey()] = "HTTP/1.1";
1239 if (content_length) { 1235 if (content_length) {
1240 std::string length_str = base::Int64ToString(*content_length); 1236 std::string length_str = base::Int64ToString(*content_length);
1241 (*headers)["content-length"] = length_str; 1237 (*headers)["content-length"] = length_str;
1242 } 1238 }
1243 return headers.Pass(); 1239 return headers.Pass();
1244 } 1240 }
1245 1241
1246 } // namespace net 1242 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_test_util_common.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698