| OLD | NEW |
| 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/socket/tcp_client_socket.h" | 5 #include "net/socket/tcp_client_socket.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "net/base/address_list.h" | 8 #include "net/base/address_list.h" |
| 9 #include "net/base/host_resolver.h" | 9 #include "net/base/host_resolver.h" |
| 10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 } | 67 } |
| 68 | 68 |
| 69 void ResumeServerReads() { | 69 void ResumeServerReads() { |
| 70 connected_sock_->ResumeReads(); | 70 connected_sock_->ResumeReads(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 protected: | 73 protected: |
| 74 int listen_port_; | 74 int listen_port_; |
| 75 CapturingNetLog net_log_; | 75 CapturingNetLog net_log_; |
| 76 ClientSocketFactory* const socket_factory_; | 76 ClientSocketFactory* const socket_factory_; |
| 77 scoped_ptr<ClientSocket> sock_; | 77 scoped_ptr<StreamSocket> sock_; |
| 78 | 78 |
| 79 private: | 79 private: |
| 80 scoped_refptr<ListenSocket> listen_sock_; | 80 scoped_refptr<ListenSocket> listen_sock_; |
| 81 scoped_refptr<ListenSocket> connected_sock_; | 81 scoped_refptr<ListenSocket> connected_sock_; |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 void TransportClientSocketTest::SetUp() { | 84 void TransportClientSocketTest::SetUp() { |
| 85 ::testing::TestWithParam<ClientSocketTestTypes>::SetUp(); | 85 ::testing::TestWithParam<ClientSocketTestTypes>::SetUp(); |
| 86 | 86 |
| 87 // Find a free port to listen on | 87 // Find a free port to listen on |
| (...skipping 21 matching lines...) Expand all Loading... |
| 109 HostResolver::RequestInfo info(HostPortPair("localhost", listen_port_)); | 109 HostResolver::RequestInfo info(HostPortPair("localhost", listen_port_)); |
| 110 int rv = resolver->Resolve(info, &addr, NULL, NULL, BoundNetLog()); | 110 int rv = resolver->Resolve(info, &addr, NULL, NULL, BoundNetLog()); |
| 111 CHECK_EQ(rv, OK); | 111 CHECK_EQ(rv, OK); |
| 112 sock_.reset( | 112 sock_.reset( |
| 113 socket_factory_->CreateTransportClientSocket(addr, | 113 socket_factory_->CreateTransportClientSocket(addr, |
| 114 &net_log_, | 114 &net_log_, |
| 115 NetLog::Source())); | 115 NetLog::Source())); |
| 116 } | 116 } |
| 117 | 117 |
| 118 // TODO(leighton): Add SCTP to this list when it is ready. | 118 // TODO(leighton): Add SCTP to this list when it is ready. |
| 119 INSTANTIATE_TEST_CASE_P(ClientSocket, | 119 INSTANTIATE_TEST_CASE_P(StreamSocket, |
| 120 TransportClientSocketTest, | 120 TransportClientSocketTest, |
| 121 ::testing::Values(TCP)); | 121 ::testing::Values(TCP)); |
| 122 | 122 |
| 123 TEST_P(TransportClientSocketTest, Connect) { | 123 TEST_P(TransportClientSocketTest, Connect) { |
| 124 TestCompletionCallback callback; | 124 TestCompletionCallback callback; |
| 125 EXPECT_FALSE(sock_->IsConnected()); | 125 EXPECT_FALSE(sock_->IsConnected()); |
| 126 | 126 |
| 127 int rv = sock_->Connect(&callback); | 127 int rv = sock_->Connect(&callback); |
| 128 | 128 |
| 129 net::CapturingNetLog::EntryList net_log_entries; | 129 net::CapturingNetLog::EntryList net_log_entries; |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 // Close the server socket, so there will at least be a 0-byte read. | 366 // Close the server socket, so there will at least be a 0-byte read. |
| 367 CloseServerSocket(); | 367 CloseServerSocket(); |
| 368 | 368 |
| 369 rv = callback.WaitForResult(); | 369 rv = callback.WaitForResult(); |
| 370 EXPECT_GE(rv, 0); | 370 EXPECT_GE(rv, 0); |
| 371 } | 371 } |
| 372 | 372 |
| 373 } // namespace | 373 } // namespace |
| 374 | 374 |
| 375 } // namespace net | 375 } // namespace net |
| OLD | NEW |