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 "net/base/socket.h" | 9 #include "net/base/socket.h" |
| 10 #include "net/base/net_errors.h" |
9 | 11 |
10 namespace net { | 12 namespace net { |
11 | 13 |
12 class ClientSocket : public Socket { | 14 class ClientSocket : public Socket { |
13 public: | 15 public: |
14 // Called to establish a connection. Returns OK if the connection could be | 16 // Called to establish a connection. Returns OK if the connection could be |
15 // established synchronously. Otherwise, ERR_IO_PENDING is returned and the | 17 // established synchronously. Otherwise, ERR_IO_PENDING is returned and the |
16 // given callback will run asynchronously when the connection is established | 18 // given callback will run asynchronously when the connection is established |
17 // or when an error occurs. The result is some other error code if the | 19 // or when an error occurs. The result is some other error code if the |
18 // connection could not be established. | 20 // connection could not be established. |
(...skipping 14 matching lines...) Expand all Loading... |
33 virtual int ReconnectIgnoringLastError(CompletionCallback* callback) = 0; | 35 virtual int ReconnectIgnoringLastError(CompletionCallback* callback) = 0; |
34 | 36 |
35 // Called to disconnect a connected socket. Does nothing if the socket is | 37 // Called to disconnect a connected socket. Does nothing if the socket is |
36 // already disconnected. After calling Disconnect it is possible to call | 38 // already disconnected. After calling Disconnect it is possible to call |
37 // Connect again to establish a new connection. | 39 // Connect again to establish a new connection. |
38 virtual void Disconnect() = 0; | 40 virtual void Disconnect() = 0; |
39 | 41 |
40 // Called to test if the connection is still alive. Returns false if a | 42 // Called to test if the connection is still alive. Returns false if a |
41 // connection wasn't established or the connection is dead. | 43 // connection wasn't established or the connection is dead. |
42 virtual bool IsConnected() const = 0; | 44 virtual bool IsConnected() const = 0; |
| 45 |
| 46 #if defined(OS_LINUX) |
| 47 // Identical to posix system call getpeername(). |
| 48 // Needed by ssl_client_socket_nss. |
| 49 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 |
43 }; | 55 }; |
44 | 56 |
45 } // namespace net | 57 } // namespace net |
46 | 58 |
47 #endif // NET_BASE_CLIENT_SOCKET_H_ | 59 #endif // NET_BASE_CLIENT_SOCKET_H_ |
48 | 60 |
OLD | NEW |