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

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

Issue 8572041: Make ClientSocketPoolManager into an interface. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix some straggler renames. Created 9 years, 1 month 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/spdy/spdy_proxy_client_socket_unittest.cc ('k') | net/spdy/spdy_stream_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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ip_endpoint.h" 7 #include "net/base/ip_endpoint.h"
8 #include "net/spdy/spdy_io_buffer.h" 8 #include "net/spdy/spdy_io_buffer.h"
9 #include "net/spdy/spdy_session_pool.h" 9 #include "net/spdy/spdy_session_pool.h"
10 #include "net/spdy/spdy_stream.h" 10 #include "net/spdy/spdy_stream.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 138
139 scoped_refptr<TransportSocketParams> transport_params( 139 scoped_refptr<TransportSocketParams> transport_params(
140 new TransportSocketParams(test_host_port_pair, 140 new TransportSocketParams(test_host_port_pair,
141 MEDIUM, 141 MEDIUM,
142 false, 142 false,
143 false)); 143 false));
144 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); 144 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle);
145 EXPECT_EQ(OK, 145 EXPECT_EQ(OK,
146 connection->Init(test_host_port_pair.ToString(), 146 connection->Init(test_host_port_pair.ToString(),
147 transport_params, MEDIUM, 147 transport_params, MEDIUM,
148 NULL, http_session->transport_socket_pool(), 148 NULL, http_session->GetTransportSocketPool(),
149 BoundNetLog())); 149 BoundNetLog()));
150 EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK)); 150 EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK));
151 151
152 // Flush the SpdySession::OnReadComplete() task. 152 // Flush the SpdySession::OnReadComplete() task.
153 MessageLoop::current()->RunAllPending(); 153 MessageLoop::current()->RunAllPending();
154 154
155 EXPECT_FALSE(spdy_session_pool->HasSession(pair)); 155 EXPECT_FALSE(spdy_session_pool->HasSession(pair));
156 156
157 scoped_refptr<SpdySession> session2 = 157 scoped_refptr<SpdySession> session2 =
158 spdy_session_pool->Get(pair, BoundNetLog()); 158 spdy_session_pool->Get(pair, BoundNetLog());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 new TransportSocketParams(test_host_port_pair, 211 new TransportSocketParams(test_host_port_pair,
212 MEDIUM, 212 MEDIUM,
213 false, 213 false,
214 false)); 214 false));
215 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); 215 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle);
216 EXPECT_EQ(OK, 216 EXPECT_EQ(OK,
217 connection->Init(test_host_port_pair.ToString(), 217 connection->Init(test_host_port_pair.ToString(),
218 transport_params, 218 transport_params,
219 MEDIUM, 219 MEDIUM,
220 NULL, 220 NULL,
221 http_session->transport_socket_pool(), 221 http_session->GetTransportSocketPool(),
222 BoundNetLog())); 222 BoundNetLog()));
223 EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK)); 223 EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK));
224 224
225 scoped_refptr<SpdyStream> spdy_stream1; 225 scoped_refptr<SpdyStream> spdy_stream1;
226 TestOldCompletionCallback callback1; 226 TestOldCompletionCallback callback1;
227 EXPECT_EQ(OK, session->CreateStream(url, 227 EXPECT_EQ(OK, session->CreateStream(url,
228 MEDIUM, 228 MEDIUM,
229 &spdy_stream1, 229 &spdy_stream1,
230 BoundNetLog(), 230 BoundNetLog(),
231 &callback1)); 231 &callback1));
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 new TransportSocketParams(test_host_port_pair, 302 new TransportSocketParams(test_host_port_pair,
303 MEDIUM, 303 MEDIUM,
304 false, 304 false,
305 false)); 305 false));
306 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); 306 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle);
307 EXPECT_EQ(OK, 307 EXPECT_EQ(OK,
308 connection->Init(test_host_port_pair.ToString(), 308 connection->Init(test_host_port_pair.ToString(),
309 transport_params, 309 transport_params,
310 MEDIUM, 310 MEDIUM,
311 NULL, 311 NULL,
312 http_session->transport_socket_pool(), 312 http_session->GetTransportSocketPool(),
313 BoundNetLog())); 313 BoundNetLog()));
314 EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK)); 314 EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK));
315 315
316 scoped_refptr<SpdyStream> spdy_stream1; 316 scoped_refptr<SpdyStream> spdy_stream1;
317 TestOldCompletionCallback callback1; 317 TestOldCompletionCallback callback1;
318 EXPECT_EQ(OK, session->CreateStream(url, 318 EXPECT_EQ(OK, session->CreateStream(url,
319 MEDIUM, 319 MEDIUM,
320 &spdy_stream1, 320 &spdy_stream1,
321 BoundNetLog(), 321 BoundNetLog(),
322 &callback1)); 322 &callback1));
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 546
547 scoped_refptr<TransportSocketParams> transport_params( 547 scoped_refptr<TransportSocketParams> transport_params(
548 new TransportSocketParams(test_host_port_pair, 548 new TransportSocketParams(test_host_port_pair,
549 MEDIUM, 549 MEDIUM,
550 false, 550 false,
551 false)); 551 false));
552 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); 552 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle);
553 EXPECT_EQ(OK, 553 EXPECT_EQ(OK,
554 connection->Init(test_host_port_pair.ToString(), 554 connection->Init(test_host_port_pair.ToString(),
555 transport_params, MEDIUM, 555 transport_params, MEDIUM,
556 NULL, http_session->transport_socket_pool(), 556 NULL, http_session->GetTransportSocketPool(),
557 BoundNetLog())); 557 BoundNetLog()));
558 EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK)); 558 EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK));
559 559
560 // Create 2 streams. First will succeed. Second will be pending. 560 // Create 2 streams. First will succeed. Second will be pending.
561 scoped_refptr<SpdyStream> spdy_stream1; 561 scoped_refptr<SpdyStream> spdy_stream1;
562 TestOldCompletionCallback callback1; 562 TestOldCompletionCallback callback1;
563 GURL url("http://www.google.com"); 563 GURL url("http://www.google.com");
564 EXPECT_EQ(OK, 564 EXPECT_EQ(OK,
565 session->CreateStream(url, 565 session->CreateStream(url,
566 MEDIUM, /* priority, not important */ 566 MEDIUM, /* priority, not important */
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 631
632 scoped_refptr<TransportSocketParams> transport_params( 632 scoped_refptr<TransportSocketParams> transport_params(
633 new TransportSocketParams(test_host_port_pair, 633 new TransportSocketParams(test_host_port_pair,
634 MEDIUM, 634 MEDIUM,
635 false, 635 false,
636 false)); 636 false));
637 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); 637 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle);
638 EXPECT_EQ(OK, 638 EXPECT_EQ(OK,
639 connection->Init(test_host_port_pair.ToString(), 639 connection->Init(test_host_port_pair.ToString(),
640 transport_params, MEDIUM, 640 transport_params, MEDIUM,
641 NULL, http_session->transport_socket_pool(), 641 NULL, http_session->GetTransportSocketPool(),
642 BoundNetLog())); 642 BoundNetLog()));
643 EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK)); 643 EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK));
644 644
645 // Use scoped_ptr to let us invalidate the memory when we want to, to trigger 645 // Use scoped_ptr to let us invalidate the memory when we want to, to trigger
646 // a valgrind error if the callback is invoked when it's not supposed to be. 646 // a valgrind error if the callback is invoked when it's not supposed to be.
647 scoped_ptr<TestOldCompletionCallback> callback(new TestOldCompletionCallback); 647 scoped_ptr<TestOldCompletionCallback> callback(new TestOldCompletionCallback);
648 648
649 // Create 2 streams. First will succeed. Second will be pending. 649 // Create 2 streams. First will succeed. Second will be pending.
650 scoped_refptr<SpdyStream> spdy_stream1; 650 scoped_refptr<SpdyStream> spdy_stream1;
651 GURL url("http://www.google.com"); 651 GURL url("http://www.google.com");
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 730
731 scoped_refptr<TransportSocketParams> transport_params( 731 scoped_refptr<TransportSocketParams> transport_params(
732 new TransportSocketParams(test_host_port_pair, 732 new TransportSocketParams(test_host_port_pair,
733 MEDIUM, 733 MEDIUM,
734 false, 734 false,
735 false)); 735 false));
736 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); 736 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle);
737 EXPECT_EQ(OK, 737 EXPECT_EQ(OK,
738 connection->Init(test_host_port_pair.ToString(), 738 connection->Init(test_host_port_pair.ToString(),
739 transport_params, MEDIUM, 739 transport_params, MEDIUM,
740 NULL, http_session->transport_socket_pool(), 740 NULL, http_session->GetTransportSocketPool(),
741 BoundNetLog())); 741 BoundNetLog()));
742 EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK)); 742 EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK));
743 MessageLoop::current()->RunAllPending(); 743 MessageLoop::current()->RunAllPending();
744 EXPECT_TRUE(data.at_write_eof()); 744 EXPECT_TRUE(data.at_write_eof());
745 } 745 }
746 746
747 // This test has two variants, one for each style of closing the connection. 747 // This test has two variants, one for each style of closing the connection.
748 // If |clean_via_close_current_sessions| is false, the sessions are closed 748 // If |clean_via_close_current_sessions| is false, the sessions are closed
749 // manually, calling SpdySessionPool::Remove() directly. If it is true, 749 // manually, calling SpdySessionPool::Remove() directly. If it is true,
750 // sessions are closed with SpdySessionPool::CloseCurrentSessions(). 750 // sessions are closed with SpdySessionPool::CloseCurrentSessions().
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 HostPortPair test_host_port_pair(test_hosts[0].name, kTestPort); 803 HostPortPair test_host_port_pair(test_hosts[0].name, kTestPort);
804 scoped_refptr<TransportSocketParams> transport_params( 804 scoped_refptr<TransportSocketParams> transport_params(
805 new TransportSocketParams(test_host_port_pair, 805 new TransportSocketParams(test_host_port_pair,
806 MEDIUM, 806 MEDIUM,
807 false, 807 false,
808 false)); 808 false));
809 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); 809 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle);
810 EXPECT_EQ(OK, 810 EXPECT_EQ(OK,
811 connection->Init(test_host_port_pair.ToString(), 811 connection->Init(test_host_port_pair.ToString(),
812 transport_params, MEDIUM, 812 transport_params, MEDIUM,
813 NULL, http_session->transport_socket_pool(), 813 NULL, http_session->GetTransportSocketPool(),
814 BoundNetLog())); 814 BoundNetLog()));
815 EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK)); 815 EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK));
816 816
817 // TODO(rtenneti): MockClientSocket::GetPeerAddress return's 0 as the port 817 // TODO(rtenneti): MockClientSocket::GetPeerAddress return's 0 as the port
818 // number. Fix it to return port 80 and then use GetPeerAddress to AddAlias. 818 // number. Fix it to return port 80 and then use GetPeerAddress to AddAlias.
819 const addrinfo* address = test_hosts[0].addresses.head(); 819 const addrinfo* address = test_hosts[0].addresses.head();
820 SpdySessionPoolPeer pool_peer(spdy_session_pool); 820 SpdySessionPoolPeer pool_peer(spdy_session_pool);
821 pool_peer.AddAlias(address, test_hosts[0].pair); 821 pool_peer.AddAlias(address, test_hosts[0].pair);
822 822
823 // Flush the SpdySession::OnReadComplete() task. 823 // Flush the SpdySession::OnReadComplete() task.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 test_http_server_properties->SetSpdySettings(test_host_port_pair, 910 test_http_server_properties->SetSpdySettings(test_host_port_pair,
911 test_settings); 911 test_settings);
912 EXPECT_NE(0u, test_http_server_properties->GetSpdySettings( 912 EXPECT_NE(0u, test_http_server_properties->GetSpdySettings(
913 test_host_port_pair).size()); 913 test_host_port_pair).size());
914 spdy_session_pool->OnIPAddressChanged(); 914 spdy_session_pool->OnIPAddressChanged();
915 EXPECT_EQ(0u, test_http_server_properties->GetSpdySettings( 915 EXPECT_EQ(0u, test_http_server_properties->GetSpdySettings(
916 test_host_port_pair).size()); 916 test_host_port_pair).size());
917 } 917 }
918 918
919 } // namespace net 919 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_proxy_client_socket_unittest.cc ('k') | net/spdy/spdy_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698