| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef NET_BASE_CLIENT_SOCKET_H_ | 5 #ifndef NET_BASE_CLIENT_SOCKET_H_ |
| 6 #define NET_BASE_CLIENT_SOCKET_H_ | 6 #define NET_BASE_CLIENT_SOCKET_H_ |
| 7 | 7 |
| 8 #include "base/logging.h" | 8 #include "build/build_config.h" |
| 9 |
| 10 #if defined(OS_LINUX) |
| 11 #include <sys/socket.h> |
| 12 #endif |
| 13 |
| 9 #include "net/base/socket.h" | 14 #include "net/base/socket.h" |
| 10 #include "net/base/net_errors.h" | |
| 11 | 15 |
| 12 namespace net { | 16 namespace net { |
| 13 | 17 |
| 14 class ClientSocket : public Socket { | 18 class ClientSocket : public Socket { |
| 15 public: | 19 public: |
| 16 // Called to establish a connection. Returns OK if the connection could be | 20 // Called to establish a connection. Returns OK if the connection could be |
| 17 // established synchronously. Otherwise, ERR_IO_PENDING is returned and the | 21 // established synchronously. Otherwise, ERR_IO_PENDING is returned and the |
| 18 // given callback will run asynchronously when the connection is established | 22 // given callback will run asynchronously when the connection is established |
| 19 // or when an error occurs. The result is some other error code if the | 23 // or when an error occurs. The result is some other error code if the |
| 20 // connection could not be established. | 24 // connection could not be established. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 39 // Connect again to establish a new connection. | 43 // Connect again to establish a new connection. |
| 40 virtual void Disconnect() = 0; | 44 virtual void Disconnect() = 0; |
| 41 | 45 |
| 42 // Called to test if the connection is still alive. Returns false if a | 46 // Called to test if the connection is still alive. Returns false if a |
| 43 // connection wasn't established or the connection is dead. | 47 // connection wasn't established or the connection is dead. |
| 44 virtual bool IsConnected() const = 0; | 48 virtual bool IsConnected() const = 0; |
| 45 | 49 |
| 46 #if defined(OS_LINUX) | 50 #if defined(OS_LINUX) |
| 47 // Identical to posix system call getpeername(). | 51 // Identical to posix system call getpeername(). |
| 48 // Needed by ssl_client_socket_nss. | 52 // Needed by ssl_client_socket_nss. |
| 49 virtual int GetPeerName(struct sockaddr *name, socklen_t *namelen) { | 53 virtual int GetPeerName(struct sockaddr *name, socklen_t *namelen); |
| 50 // Default implementation just permits some unit tests to link. | |
| 51 NOTREACHED(); | |
| 52 return ERR_UNEXPECTED; | |
| 53 } | |
| 54 #endif | 54 #endif |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 } // namespace net | 57 } // namespace net |
| 58 | 58 |
| 59 #endif // NET_BASE_CLIENT_SOCKET_H_ | 59 #endif // NET_BASE_CLIENT_SOCKET_H_ |
| 60 | 60 |
| OLD | NEW |