| 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/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 "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "net/base/address_list.h" | 10 #include "net/base/address_list.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 uint32 bytes_to_read, | 82 uint32 bytes_to_read, |
| 83 TestCompletionCallback* callback); | 83 TestCompletionCallback* callback); |
| 84 | 84 |
| 85 void SendClientRequest(); | 85 void SendClientRequest(); |
| 86 | 86 |
| 87 void set_close_server_socket_on_next_send(bool close) { | 87 void set_close_server_socket_on_next_send(bool close) { |
| 88 close_server_socket_on_next_send_ = close; | 88 close_server_socket_on_next_send_ = close; |
| 89 } | 89 } |
| 90 | 90 |
| 91 protected: | 91 protected: |
| 92 int listen_port_; | 92 uint16 listen_port_; |
| 93 CapturingNetLog net_log_; | 93 CapturingNetLog net_log_; |
| 94 ClientSocketFactory* const socket_factory_; | 94 ClientSocketFactory* const socket_factory_; |
| 95 scoped_ptr<StreamSocket> sock_; | 95 scoped_ptr<StreamSocket> sock_; |
| 96 | 96 |
| 97 private: | 97 private: |
| 98 scoped_ptr<TCPListenSocket> listen_sock_; | 98 scoped_ptr<TCPListenSocket> listen_sock_; |
| 99 scoped_ptr<TCPListenSocket> connected_sock_; | 99 scoped_ptr<TCPListenSocket> connected_sock_; |
| 100 bool close_server_socket_on_next_send_; | 100 bool close_server_socket_on_next_send_; |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 void TransportClientSocketTest::SetUp() { | 103 void TransportClientSocketTest::SetUp() { |
| 104 ::testing::TestWithParam<ClientSocketTestTypes>::SetUp(); | 104 ::testing::TestWithParam<ClientSocketTestTypes>::SetUp(); |
| 105 | 105 |
| 106 // Find a free port to listen on | 106 // Find a free port to listen on |
| 107 scoped_ptr<TCPListenSocket> sock; | 107 scoped_ptr<TCPListenSocket> sock; |
| 108 int port; | 108 uint16 port; |
| 109 // Range of ports to listen on. Shouldn't need to try many. | 109 // Range of ports to listen on. Shouldn't need to try many. |
| 110 const int kMinPort = 10100; | 110 const uint16 kMinPort = 10100; |
| 111 const int kMaxPort = 10200; | 111 const uint16 kMaxPort = 10200; |
| 112 #if defined(OS_WIN) | 112 #if defined(OS_WIN) |
| 113 EnsureWinsockInit(); | 113 EnsureWinsockInit(); |
| 114 #endif | 114 #endif |
| 115 for (port = kMinPort; port < kMaxPort; port++) { | 115 for (port = kMinPort; port < kMaxPort; port++) { |
| 116 sock = TCPListenSocket::CreateAndListen("127.0.0.1", port, this); | 116 sock = TCPListenSocket::CreateAndListen("127.0.0.1", port, this); |
| 117 if (sock.get()) | 117 if (sock.get()) |
| 118 break; | 118 break; |
| 119 } | 119 } |
| 120 ASSERT_TRUE(sock.get() != NULL); | 120 ASSERT_TRUE(sock.get() != NULL); |
| 121 listen_sock_ = sock.Pass(); | 121 listen_sock_ = sock.Pass(); |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 | 441 |
| 442 // It's possible the read is blocked because it's already read all the data. | 442 // It's possible the read is blocked because it's already read all the data. |
| 443 // Close the server socket, so there will at least be a 0-byte read. | 443 // Close the server socket, so there will at least be a 0-byte read. |
| 444 CloseServerSocket(); | 444 CloseServerSocket(); |
| 445 | 445 |
| 446 rv = callback.WaitForResult(); | 446 rv = callback.WaitForResult(); |
| 447 EXPECT_GE(rv, 0); | 447 EXPECT_GE(rv, 0); |
| 448 } | 448 } |
| 449 | 449 |
| 450 } // namespace net | 450 } // namespace net |
| OLD | NEW |