OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_SOCKET_CLIENT_SOCKET_H_ | 5 #ifndef NET_SOCKET_CLIENT_SOCKET_H_ |
6 #define NET_SOCKET_CLIENT_SOCKET_H_ | 6 #define NET_SOCKET_CLIENT_SOCKET_H_ |
7 | 7 |
8 #include "net/socket/socket.h" | 8 #include "net/socket/socket.h" |
9 | 9 |
10 namespace net { | 10 namespace net { |
11 | 11 |
12 class AddressList; | 12 class AddressList; |
13 class BoundNetLog; | 13 class BoundNetLog; |
14 | 14 |
15 class ClientSocket : public Socket { | 15 class ClientSocket : public Socket { |
16 public: | 16 public: |
17 // Called to establish a connection. Returns OK if the connection could be | 17 // Called to establish a connection. Returns OK if the connection could be |
18 // established synchronously. Otherwise, ERR_IO_PENDING is returned and the | 18 // established synchronously. Otherwise, ERR_IO_PENDING is returned and the |
19 // given callback will run asynchronously when the connection is established | 19 // given callback will run asynchronously when the connection is established |
20 // or when an error occurs. The result is some other error code if the | 20 // or when an error occurs. The result is some other error code if the |
21 // connection could not be established. | 21 // connection could not be established. |
22 // | 22 // |
23 // The socket's Read and Write methods may not be called until Connect | 23 // The socket's Read and Write methods may not be called until Connect |
24 // succeeds. | 24 // succeeds. |
25 // | 25 // |
26 // It is valid to call Connect on an already connected socket, in which case | 26 // It is valid to call Connect on an already connected socket, in which case |
27 // OK is simply returned. | 27 // OK is simply returned. |
28 // | 28 // |
29 // Connect may also be called again after a call to the Disconnect method. | 29 // Connect may also be called again after a call to the Disconnect method. |
30 // | 30 // |
31 virtual int Connect(CompletionCallback* callback, | 31 virtual int Connect(CompletionCallback* callback) = 0; |
32 const BoundNetLog& net_log) = 0; | |
33 | 32 |
34 // Called to disconnect a socket. Does nothing if the socket is already | 33 // Called to disconnect a socket. Does nothing if the socket is already |
35 // disconnected. After calling Disconnect it is possible to call Connect | 34 // disconnected. After calling Disconnect it is possible to call Connect |
36 // again to establish a new connection. | 35 // again to establish a new connection. |
37 // | 36 // |
38 // If IO (Connect, Read, or Write) is pending when the socket is | 37 // If IO (Connect, Read, or Write) is pending when the socket is |
39 // disconnected, the pending IO is cancelled, and the completion callback | 38 // disconnected, the pending IO is cancelled, and the completion callback |
40 // will not be called. | 39 // will not be called. |
41 virtual void Disconnect() = 0; | 40 virtual void Disconnect() = 0; |
42 | 41 |
43 // 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 |
44 // connection wasn't established or the connection is dead. | 43 // connection wasn't established or the connection is dead. |
45 virtual bool IsConnected() const = 0; | 44 virtual bool IsConnected() const = 0; |
46 | 45 |
47 // Called to test if the connection is still alive and idle. Returns false | 46 // Called to test if the connection is still alive and idle. Returns false |
48 // if a connection wasn't established, the connection is dead, or some data | 47 // if a connection wasn't established, the connection is dead, or some data |
49 // have been received. | 48 // have been received. |
50 virtual bool IsConnectedAndIdle() const = 0; | 49 virtual bool IsConnectedAndIdle() const = 0; |
51 | 50 |
52 // Copies the peer address to |address| and returns a network error code. | 51 // Copies the peer address to |address| and returns a network error code. |
53 virtual int GetPeerAddress(AddressList* address) const = 0; | 52 virtual int GetPeerAddress(AddressList* address) const = 0; |
| 53 |
| 54 // Gets the NetLog for this socket. |
| 55 virtual const BoundNetLog& NetLog() const = 0; |
54 }; | 56 }; |
55 | 57 |
56 } // namespace net | 58 } // namespace net |
57 | 59 |
58 #endif // NET_SOCKET_CLIENT_SOCKET_H_ | 60 #endif // NET_SOCKET_CLIENT_SOCKET_H_ |
OLD | NEW |