Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef REMOTING_HOST_WEBSOCKET_LISTENER_H_ | |
| 6 #define REMOTING_HOST_WEBSOCKET_LISTENER_H_ | |
| 7 | |
| 8 #include <set> | |
| 9 | |
| 10 #include "base/memory/ref_counted.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/memory/weak_ptr.h" | |
| 13 #include "net/socket/tcp_server_socket.h" | |
| 14 | |
| 15 namespace net { | |
| 16 class IPEndPoint; | |
| 17 class StreamSocket; | |
| 18 } // namespace net | |
| 19 | |
| 20 namespace remoting { | |
| 21 | |
| 22 class WebsocketConnection; | |
| 23 | |
| 24 class WebsocketListener { | |
| 25 public: | |
| 26 typedef base::Callback< | |
| 27 void(scoped_ptr<WebsocketConnection> connection)> NewConnectionCallback; | |
| 28 | |
| 29 WebsocketListener(); | |
| 30 ~WebsocketListener(); | |
| 31 | |
| 32 // 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.
| |
| 33 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
| |
| 34 const NewConnectionCallback& callback); | |
| 35 | |
| 36 private: | |
| 37 void DoAccept(); | |
| 38 void OnAccepted(int result); | |
| 39 void HandleAcceptResult(int result); | |
| 40 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.
| |
| 41 | |
| 42 scoped_ptr<net::TCPServerSocket> tcp_socket_; | |
| 43 NewConnectionCallback new_connection_callback_; | |
| 44 scoped_ptr<net::StreamSocket> accepted_socket_; | |
| 45 std::set<WebsocketConnection*> pending_connections_; | |
| 46 | |
| 47 base::WeakPtrFactory<WebsocketListener> weak_factory_; | |
| 48 | |
| 49 DISALLOW_COPY_AND_ASSIGN(WebsocketListener); | |
| 50 }; | |
| 51 | |
| 52 } // namespace remoting | |
| 53 | |
| 54 #endif // REMOTING_HOST_WEBSOCKET_LISTENER_H_ | |
| OLD | NEW |