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