| 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_TCP_CLIENT_SOCKET_LIBEVENT_H_ | 5 #ifndef NET_SOCKET_TCP_CLIENT_SOCKET_LIBEVENT_H_ |
| 6 #define NET_SOCKET_TCP_CLIENT_SOCKET_LIBEVENT_H_ | 6 #define NET_SOCKET_TCP_CLIENT_SOCKET_LIBEVENT_H_ |
| 7 | 7 |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/ref_counted.h" | 9 #include "base/ref_counted.h" |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| 11 #include "net/base/address_list.h" | 11 #include "net/base/address_list.h" |
| 12 #include "net/base/completion_callback.h" | 12 #include "net/base/completion_callback.h" |
| 13 #include "net/base/net_log.h" | 13 #include "net/base/net_log.h" |
| 14 #include "net/socket/client_socket.h" | 14 #include "net/socket/client_socket.h" |
| 15 | 15 |
| 16 struct event; // From libevent | 16 struct event; // From libevent |
| 17 | 17 |
| 18 namespace net { | 18 namespace net { |
| 19 | 19 |
| 20 class BoundNetLog; | 20 class BoundNetLog; |
| 21 | 21 |
| 22 // A client socket that uses TCP as the transport layer. | 22 // A client socket that uses TCP as the transport layer. |
| 23 class TCPClientSocketLibevent : public ClientSocket { | 23 class TCPClientSocketLibevent : public ClientSocket { |
| 24 public: | 24 public: |
| 25 // The IP address(es) and port number to connect to. The TCP socket will try | 25 // The IP address(es) and port number to connect to. The TCP socket will try |
| 26 // each IP address in the list until it succeeds in establishing a | 26 // each IP address in the list until it succeeds in establishing a |
| 27 // connection. | 27 // connection. |
| 28 explicit TCPClientSocketLibevent(const AddressList& addresses); | 28 explicit TCPClientSocketLibevent(const AddressList& addresses, |
| 29 net::NetLog* net_log); |
| 29 | 30 |
| 30 virtual ~TCPClientSocketLibevent(); | 31 virtual ~TCPClientSocketLibevent(); |
| 31 | 32 |
| 32 // ClientSocket methods: | 33 // ClientSocket methods: |
| 33 virtual int Connect(CompletionCallback* callback, const BoundNetLog& net_log); | 34 virtual int Connect(CompletionCallback* callback); |
| 34 virtual void Disconnect(); | 35 virtual void Disconnect(); |
| 35 virtual bool IsConnected() const; | 36 virtual bool IsConnected() const; |
| 36 virtual bool IsConnectedAndIdle() const; | 37 virtual bool IsConnectedAndIdle() const; |
| 37 virtual int GetPeerAddress(AddressList* address) const; | 38 virtual int GetPeerAddress(AddressList* address) const; |
| 39 virtual const BoundNetLog& NetLog() const { return net_log_; } |
| 38 | 40 |
| 39 // Socket methods: | 41 // Socket methods: |
| 40 // Multiple outstanding requests are not supported. | 42 // Multiple outstanding requests are not supported. |
| 41 // Full duplex mode (reading and writing at the same time) is supported | 43 // Full duplex mode (reading and writing at the same time) is supported |
| 42 virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback); | 44 virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback); |
| 43 virtual int Write(IOBuffer* buf, int buf_len, CompletionCallback* callback); | 45 virtual int Write(IOBuffer* buf, int buf_len, CompletionCallback* callback); |
| 44 virtual bool SetReceiveBufferSize(int32 size); | 46 virtual bool SetReceiveBufferSize(int32 size); |
| 45 virtual bool SetSendBufferSize(int32 size); | 47 virtual bool SetSendBufferSize(int32 size); |
| 46 | 48 |
| 47 private: | 49 private: |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 CompletionCallback* write_callback_; | 133 CompletionCallback* write_callback_; |
| 132 | 134 |
| 133 BoundNetLog net_log_; | 135 BoundNetLog net_log_; |
| 134 | 136 |
| 135 DISALLOW_COPY_AND_ASSIGN(TCPClientSocketLibevent); | 137 DISALLOW_COPY_AND_ASSIGN(TCPClientSocketLibevent); |
| 136 }; | 138 }; |
| 137 | 139 |
| 138 } // namespace net | 140 } // namespace net |
| 139 | 141 |
| 140 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_LIBEVENT_H_ | 142 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_LIBEVENT_H_ |
| OLD | NEW |