| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 EXTENSIONS_BROWSER_API_SOCKET_TCP_SOCKET_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_SOCKET_TCP_SOCKET_H_ |
| 6 #define EXTENSIONS_BROWSER_API_SOCKET_TCP_SOCKET_H_ | 6 #define EXTENSIONS_BROWSER_API_SOCKET_TCP_SOCKET_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "extensions/browser/api/socket/socket.h" | 10 #include "extensions/browser/api/socket/socket.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 virtual int Listen(const std::string& address, | 47 virtual int Listen(const std::string& address, |
| 48 int port, | 48 int port, |
| 49 int backlog, | 49 int backlog, |
| 50 std::string* error_msg) OVERRIDE; | 50 std::string* error_msg) OVERRIDE; |
| 51 virtual void Accept(const AcceptCompletionCallback& callback) OVERRIDE; | 51 virtual void Accept(const AcceptCompletionCallback& callback) OVERRIDE; |
| 52 | 52 |
| 53 virtual bool IsConnected() OVERRIDE; | 53 virtual bool IsConnected() OVERRIDE; |
| 54 | 54 |
| 55 virtual bool GetPeerAddress(net::IPEndPoint* address) OVERRIDE; | 55 virtual bool GetPeerAddress(net::IPEndPoint* address) OVERRIDE; |
| 56 virtual bool GetLocalAddress(net::IPEndPoint* address) OVERRIDE; | 56 virtual bool GetLocalAddress(net::IPEndPoint* address) OVERRIDE; |
| 57 |
| 58 // Like Disconnect(), only Release() doesn't delete the underlying stream |
| 59 // or attempt to close it. Useful when giving away ownership with |
| 60 // ClientStream(). |
| 61 virtual void Release(); |
| 62 |
| 57 virtual Socket::SocketType GetSocketType() const OVERRIDE; | 63 virtual Socket::SocketType GetSocketType() const OVERRIDE; |
| 58 | 64 |
| 59 static TCPSocket* CreateSocketForTesting( | 65 static TCPSocket* CreateSocketForTesting( |
| 60 net::TCPClientSocket* tcp_client_socket, | 66 net::TCPClientSocket* tcp_client_socket, |
| 61 const std::string& owner_extension_id, | 67 const std::string& owner_extension_id, |
| 62 bool is_connected = false); | 68 bool is_connected = false); |
| 63 static TCPSocket* CreateServerSocketForTesting( | 69 static TCPSocket* CreateServerSocketForTesting( |
| 64 net::TCPServerSocket* tcp_server_socket, | 70 net::TCPServerSocket* tcp_server_socket, |
| 65 const std::string& owner_extension_id); | 71 const std::string& owner_extension_id); |
| 66 | 72 |
| 73 // Returns NULL if GetSocketType() isn't TYPE_TCP or if the connection |
| 74 // wasn't set up via Connect() (vs Listen()/Accept()). |
| 75 net::TCPClientSocket* ClientStream(); |
| 76 |
| 77 // Whether a Read() has been issued, that hasn't come back yet. |
| 78 bool HasPendingRead() const; |
| 79 |
| 67 protected: | 80 protected: |
| 68 virtual int WriteImpl(net::IOBuffer* io_buffer, | 81 virtual int WriteImpl(net::IOBuffer* io_buffer, |
| 69 int io_buffer_size, | 82 int io_buffer_size, |
| 70 const net::CompletionCallback& callback) OVERRIDE; | 83 const net::CompletionCallback& callback) OVERRIDE; |
| 71 | 84 |
| 72 private: | 85 private: |
| 73 void RefreshConnectionStatus(); | 86 void RefreshConnectionStatus(); |
| 74 void OnConnectComplete(int result); | 87 void OnConnectComplete(int result); |
| 75 void OnReadComplete(scoped_refptr<net::IOBuffer> io_buffer, int result); | 88 void OnReadComplete(scoped_refptr<net::IOBuffer> io_buffer, int result); |
| 76 void OnAccept(int result); | 89 void OnAccept(int result); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 // suspended - see sockets_tcp_server.idl. | 177 // suspended - see sockets_tcp_server.idl. |
| 165 bool persistent_; | 178 bool persistent_; |
| 166 // Flag indicating whether a connected socket blocks its peer from sending | 179 // Flag indicating whether a connected socket blocks its peer from sending |
| 167 // more data - see sockets_tcp_server.idl. | 180 // more data - see sockets_tcp_server.idl. |
| 168 bool paused_; | 181 bool paused_; |
| 169 }; | 182 }; |
| 170 | 183 |
| 171 } // namespace extensions | 184 } // namespace extensions |
| 172 | 185 |
| 173 #endif // EXTENSIONS_BROWSER_API_SOCKET_TCP_SOCKET_H_ | 186 #endif // EXTENSIONS_BROWSER_API_SOCKET_TCP_SOCKET_H_ |
| OLD | NEW |