| 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 30 matching lines...) Expand all Loading... |
| 41 : listen_port_(0), | 41 : listen_port_(0), |
| 42 socket_factory_(ClientSocketFactory::GetDefaultFactory()), | 42 socket_factory_(ClientSocketFactory::GetDefaultFactory()), |
| 43 close_server_socket_on_next_send_(false) { | 43 close_server_socket_on_next_send_(false) { |
| 44 } | 44 } |
| 45 | 45 |
| 46 virtual ~TransportClientSocketTest() { | 46 virtual ~TransportClientSocketTest() { |
| 47 } | 47 } |
| 48 | 48 |
| 49 // Implement StreamListenSocket::Delegate methods | 49 // Implement StreamListenSocket::Delegate methods |
| 50 virtual void DidAccept(StreamListenSocket* server, | 50 virtual void DidAccept(StreamListenSocket* server, |
| 51 scoped_ptr<StreamListenSocket> connection) OVERRIDE { | 51 scoped_ptr<StreamListenSocket> connection) override { |
| 52 connected_sock_.reset( | 52 connected_sock_.reset( |
| 53 static_cast<TCPListenSocket*>(connection.release())); | 53 static_cast<TCPListenSocket*>(connection.release())); |
| 54 } | 54 } |
| 55 virtual void DidRead(StreamListenSocket*, const char* str, int len) OVERRIDE { | 55 virtual void DidRead(StreamListenSocket*, const char* str, int len) override { |
| 56 // TODO(dkegel): this might not be long enough to tickle some bugs. | 56 // TODO(dkegel): this might not be long enough to tickle some bugs. |
| 57 connected_sock_->Send(kServerReply, arraysize(kServerReply) - 1, | 57 connected_sock_->Send(kServerReply, arraysize(kServerReply) - 1, |
| 58 false /* Don't append line feed */); | 58 false /* Don't append line feed */); |
| 59 if (close_server_socket_on_next_send_) | 59 if (close_server_socket_on_next_send_) |
| 60 CloseServerSocket(); | 60 CloseServerSocket(); |
| 61 } | 61 } |
| 62 virtual void DidClose(StreamListenSocket* sock) OVERRIDE {} | 62 virtual void DidClose(StreamListenSocket* sock) override {} |
| 63 | 63 |
| 64 // Testcase hooks | 64 // Testcase hooks |
| 65 virtual void SetUp(); | 65 virtual void SetUp(); |
| 66 | 66 |
| 67 void CloseServerSocket() { | 67 void CloseServerSocket() { |
| 68 // delete the connected_sock_, which will close it. | 68 // delete the connected_sock_, which will close it. |
| 69 connected_sock_.reset(); | 69 connected_sock_.reset(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void PauseServerReads() { | 72 void PauseServerReads() { |
| (...skipping 368 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 |