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

Unified Diff: remoting/host/websocket_listener.h

Issue 11358190: Add simple WebSocket server implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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: remoting/host/websocket_listener.h
diff --git a/remoting/host/websocket_listener.h b/remoting/host/websocket_listener.h
new file mode 100644
index 0000000000000000000000000000000000000000..80752e6a55dbad5e8f76e9bc747a759fdefd09ce
--- /dev/null
+++ b/remoting/host/websocket_listener.h
@@ -0,0 +1,54 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef REMOTING_HOST_WEBSOCKET_LISTENER_H_
+#define REMOTING_HOST_WEBSOCKET_LISTENER_H_
+
+#include <set>
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "net/socket/tcp_server_socket.h"
+
+namespace net {
+class IPEndPoint;
+class StreamSocket;
+} // namespace net
+
+namespace remoting {
+
+class WebsocketConnection;
+
+class WebsocketListener {
+ public:
+ typedef base::Callback<
+ void(scoped_ptr<WebsocketConnection> connection)> NewConnectionCallback;
+
+ WebsocketListener();
+ ~WebsocketListener();
+
+ // Start listening on the specified port. Returns false in case of a failure.
Wez 2012/11/15 02:28:37 Why not return a net/ error, or provide a result c
Wez 2012/11/15 02:28:37 nit: Clarify the tear-down semantics; is |callback
Wez 2012/11/15 02:28:37 nit: port -> address, Start -> Starts
Sergey Ulanov 2012/11/15 21:01:03 Done.
Sergey Ulanov 2012/11/15 21:01:03 Done.
Sergey Ulanov 2012/11/15 21:01:03 Done.
+ bool Listen(const net::IPEndPoint& address,
Wez 2012/11/15 02:28:37 nit: If you make |address| an in-out parameter, it
Sergey Ulanov 2012/11/15 21:01:03 I don't think that using in-out parameter here is
+ const NewConnectionCallback& callback);
+
+ private:
+ void DoAccept();
+ void OnAccepted(int result);
+ void HandleAcceptResult(int result);
+ void OnConnected(WebsocketConnection* connection_ptr, bool handshake_result);
Wez 2012/11/15 02:28:37 Each of these methods need a (short) comment expla
Sergey Ulanov 2012/11/15 21:01:03 Done.
+
+ scoped_ptr<net::TCPServerSocket> tcp_socket_;
+ NewConnectionCallback new_connection_callback_;
+ scoped_ptr<net::StreamSocket> accepted_socket_;
+ std::set<WebsocketConnection*> pending_connections_;
+
+ base::WeakPtrFactory<WebsocketListener> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebsocketListener);
+};
+
+} // namespace remoting
+
+#endif // REMOTING_HOST_WEBSOCKET_LISTENER_H_

Powered by Google App Engine
This is Rietveld 408576698