Chromium Code Reviews| Index: chrome/browser/extensions/api/socket/tcp_socket.h |
| diff --git a/chrome/browser/extensions/api/socket/tcp_socket.h b/chrome/browser/extensions/api/socket/tcp_socket.h |
| index 4d5b94467824b5118b518d4c17f30c873ce2a5ff..c66ab12796a1004ef28f153b817807647cf0153d 100644 |
| --- a/chrome/browser/extensions/api/socket/tcp_socket.h |
| +++ b/chrome/browser/extensions/api/socket/tcp_socket.h |
| @@ -12,6 +12,7 @@ |
| // This looks like it should be forward-declarable, but it does some tricky |
| // moves that make it easier to just include it. |
| #include "net/socket/tcp_client_socket.h" |
| +#include "net/socket/tcp_server_socket.h" |
| namespace net { |
| class Socket; |
| @@ -24,6 +25,10 @@ class ApiResourceEventNotifier; |
| class TCPSocket : public Socket { |
| public: |
| explicit TCPSocket(ApiResourceEventNotifier* event_notifier); |
| + TCPSocket(net::TCPClientSocket* tcp_client_socket, |
| + ApiResourceEventNotifier* event_notifier, |
| + bool is_connected = false); |
| + |
| virtual ~TCPSocket(); |
| virtual void Connect(const std::string& address, |
| @@ -42,6 +47,9 @@ class TCPSocket : public Socket { |
| const CompletionCallback& callback) OVERRIDE; |
| virtual bool SetKeepAlive(bool enable, int delay) OVERRIDE; |
| virtual bool SetNoDelay(bool no_delay) OVERRIDE; |
| + virtual int Listen(int backlog, std::string& error_msg) OVERRIDE; |
| + virtual void Accept(const AcceptCompletionCallback &callback) OVERRIDE; |
| + |
| virtual bool GetPeerAddress(net::IPEndPoint* address) OVERRIDE; |
| virtual bool GetLocalAddress(net::IPEndPoint* address) OVERRIDE; |
| virtual Socket::SocketType GetSocketType() const OVERRIDE; |
| @@ -49,6 +57,8 @@ class TCPSocket : public Socket { |
| static TCPSocket* CreateSocketForTesting( |
| net::TCPClientSocket* tcp_client_socket, |
| ApiResourceEventNotifier* event_notifier); |
| + static TCPSocket* CreateServerSocketForTesting( |
| + net::TCPServerSocket* tcp_server_socket); |
| protected: |
| virtual int WriteImpl(net::IOBuffer* io_buffer, |
| @@ -59,15 +69,23 @@ class TCPSocket : public Socket { |
| void OnConnectComplete(int result); |
| void OnReadComplete(scoped_refptr<net::IOBuffer> io_buffer, |
| int result); |
| + void OnAccept(int result); |
| - TCPSocket(net::TCPClientSocket* tcp_client_socket, |
| - ApiResourceEventNotifier* event_notifier); |
| + explicit TCPSocket(net::TCPServerSocket*); |
| scoped_ptr<net::TCPClientSocket> socket_; |
| + scoped_ptr<net::TCPServerSocket> server_socket_; |
| + scoped_ptr<net::IPEndPoint> bind_address_; |
| + |
| + bool is_client_socket_; |
| + bool is_server_socket_; |
|
Peng
2012/09/11 14:01:18
Could we use one variable? Like int socket_mode_,
justinlin
2012/09/12 07:29:42
Done.
|
| CompletionCallback connect_callback_; |
| ReadCompletionCallback read_callback_; |
| + |
| + scoped_ptr<net::StreamSocket> accept_socket_; |
| + AcceptCompletionCallback accept_callback_; |
| }; |
| } // namespace extensions |