Chromium Code Reviews| Index: net/socket/server_socket.h |
| diff --git a/net/socket/server_socket.h b/net/socket/server_socket.h |
| index 11151eea1539636928b64aee65876dfacd9e60ec..ad1af018f5c83967d76bb2fe02086c838c91a0f0 100644 |
| --- a/net/socket/server_socket.h |
| +++ b/net/socket/server_socket.h |
| @@ -7,26 +7,26 @@ |
| #include "base/memory/scoped_ptr.h" |
| #include "net/base/completion_callback.h" |
| +#include "net/base/ip_endpoint.h" |
| #include "net/base/net_export.h" |
| namespace net { |
| -class IPEndPoint; |
| class StreamSocket; |
| class NET_EXPORT ServerSocket { |
| public: |
| - ServerSocket() { } |
| - virtual ~ServerSocket() { } |
| + ServerSocket() {} |
| + virtual ~ServerSocket() {} |
| - // Bind the socket and start listening. Destroy the socket to stop |
| + // Binds the socket and start listening. Destroy the socket to stop |
| // listening. |
| virtual int Listen(const net::IPEndPoint& address, int backlog) = 0; |
| // Gets current address the socket is bound to. |
| virtual int GetLocalAddress(IPEndPoint* address) const = 0; |
| - // Accept connection. Callback is called when new connection is |
| + // Accepts connection. Callback is called when new connection is |
| // accepted. |
| virtual int Accept(scoped_ptr<StreamSocket>* socket, |
| const CompletionCallback& callback) = 0; |
| @@ -35,6 +35,36 @@ class NET_EXPORT ServerSocket { |
| DISALLOW_COPY_AND_ASSIGN(ServerSocket); |
| }; |
| +class NET_EXPORT ServerSocketFactory { |
|
mmenke
2014/06/04 16:29:50
What's the motivation behind adding this class?
byungchul
2014/06/04 17:41:28
Devtools builds a socket factory class in UI threa
mmenke
2014/06/04 21:00:00
Hrm...Wonder if it makes more sense to make this D
byungchul
2014/06/06 19:17:35
Done.
|
| + public: |
| + ServerSocketFactory(); |
| + virtual ~ServerSocketFactory(); |
| + |
| + // Returns a new instance of ServerSocket or NULL if an error occurred. |
| + // It calls ServerSocket::Listen() with address and backlog set previously. |
| + // Subclasses may override this function if ServerSocket::Listen() is not a |
| + // right behavior. |
|
mmenke
2014/06/04 16:29:50
nit: "a right behavior" -> "the right behavior"
byungchul
2014/06/06 19:17:35
Done.
|
| + virtual scoped_ptr<ServerSocket> CreateAndListen() const; |
| + |
| + void set_address(const IPEndPoint& address) { address_ = address; } |
|
mmenke
2014/06/04 16:29:50
It seems odd to me that this isn't an argument to
byungchul
2014/06/04 17:41:28
Again, setting address and calling CreateAndListen
|
| + void set_backlog(int backlog) { backlog_ = backlog; } |
|
mmenke
2014/06/04 16:29:50
These should be documented.
byungchul
2014/06/06 19:17:35
Removed and they are passed to constructor.
|
| + |
| + // Sets address with string representation and port. It expects a vaild |
| + // IPv4 or IPv6 address. Otherwise, it returns false. |
| + bool SetAddressAndPort(const std::string& address_string, int port); |
| + |
| + protected: |
| + // Creates a server socket. ServerSocket::Listen() will be called soon unless |
| + // it returns NULL. |
| + virtual scoped_ptr<ServerSocket> Create() const = 0; |
| + |
| + private: |
| + IPEndPoint address_; |
| + int backlog_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ServerSocketFactory); |
| +}; |
| + |
| } // namespace net |
| #endif // NET_SOCKET_SERVER_SOCKET_H_ |