Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1116)

Unified Diff: net/socket/server_socket.h

Issue 296053012: Replace StreamListenSocket with StreamSocket in HttpServer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use base::StringPiece in some places not to copy data. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_

Powered by Google App Engine
This is Rietveld 408576698