Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 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_GNUBBY_AUTH_HANDLER_H_ | |
| 6 #define REMOTING_HOST_GNUBBY_AUTH_HANDLER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <utility> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/basictypes.h" | |
| 13 #include "base/files/file_path.h" | |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 #include "base/threading/non_thread_safe.h" | |
| 16 #include "net/socket/stream_listen_socket.h" | |
| 17 | |
| 18 namespace base { | |
| 19 class SingleThreadTaskRunner; | |
| 20 } // namespace base | |
| 21 | |
| 22 namespace remoting { | |
| 23 namespace protocol { | |
| 24 class ClientStub; | |
| 25 } // namespace protocol | |
| 26 | |
| 27 // Class responsible for proxying authentication data between a local gnubbyd | |
| 28 // and the client. | |
| 29 | |
|
Sergey Ulanov
2014/02/09 22:29:54
nit: don't need this empty line.
psj
2014/02/10 22:57:22
Done.
| |
| 30 class GnubbyAuthHandler : public base::NonThreadSafe, | |
| 31 public net::StreamListenSocket::Delegate { | |
| 32 public: | |
| 33 explicit GnubbyAuthHandler(protocol::ClientStub* client_stub); | |
| 34 virtual ~GnubbyAuthHandler(); | |
| 35 | |
| 36 // StreamListenSocket::Delegate interface. | |
|
Sergey Ulanov
2014/02/09 22:29:54
nit: If this interface is not intended to be used
psj
2014/02/10 22:57:22
Done.
| |
| 37 virtual void DidAccept(net::StreamListenSocket* server, | |
| 38 scoped_ptr<net::StreamListenSocket> socket); | |
|
Sergey Ulanov
2014/02/09 22:29:54
add OVERRIDE at then end of overridden method.
psj
2014/02/10 22:57:22
Done.
| |
| 39 virtual void DidRead(net::StreamListenSocket* socket, | |
| 40 const char* data, | |
| 41 int len); | |
| 42 virtual void DidClose(net::StreamListenSocket* socket); | |
| 43 | |
| 44 // A message was received from the client. | |
| 45 virtual void DeliverClientMessage(const std::string message); | |
|
Sergey Ulanov
2014/02/09 22:29:54
do these methods need to be virtual?
Sergey Ulanov
2014/02/09 22:29:54
use const reference to pass strings. Same for the
psj
2014/02/10 22:57:22
Done.
psj
2014/02/10 22:57:22
They are virtual for test mocks
| |
| 46 | |
| 47 // Send control message to client. | |
| 48 virtual void DeliverHostControlMessage(const std::string control_type, | |
| 49 const std::string data) const; | |
| 50 | |
| 51 // Send data to client. | |
| 52 virtual void DeliverHostDataMessage(int connection_id, | |
| 53 const std::string data) const; | |
| 54 | |
| 55 // Specify the name of the socket to listen to gnubby requests on. | |
| 56 static void SetGnubbySocketName(base::FilePath gnubby_socket_name); | |
|
Sergey Ulanov
2014/02/09 22:29:54
const base::FilePath&
Sergey Ulanov
2014/02/09 22:29:54
nit: move this after the destructor before all pu
psj
2014/02/10 22:57:22
Done.
psj
2014/02/10 22:57:22
Done.
| |
| 57 | |
| 58 // Returns true if the socket is being tracked as active. | |
| 59 bool HasActiveSocketForTesting(net::StreamListenSocket*) const; | |
| 60 private: | |
|
Sergey Ulanov
2014/02/09 22:29:54
nit: empty line above this one.
psj
2014/02/10 22:57:22
Done.
| |
| 61 // Create socket for authorization. | |
| 62 void CreateAuthorizationSocket(); | |
| 63 | |
| 64 // Interfaces through which communication with the client occurs. | |
| 65 protocol::ClientStub* client_stub_; | |
| 66 | |
| 67 // Socket used to listen for authorization requests. | |
| 68 scoped_ptr<net::StreamListenSocket> auth_socket_; | |
| 69 | |
| 70 // The current gnubby connection id. | |
| 71 int current_connection_id_; | |
|
Sergey Ulanov
2014/02/09 22:29:54
Maybe last_connection_id_? To make it clear that t
psj
2014/02/10 22:57:22
Done.
| |
| 72 | |
| 73 // Socket and connection id pairs used to process gnubbyd requests | |
| 74 typedef std::vector<std::pair<net::StreamListenSocket*, int> > ActiveSockets; | |
|
Sergey Ulanov
2014/02/09 22:29:54
Can this be std::map? Then you wouldn't need both
psj
2014/02/10 22:57:22
No, I need to search both by socket (for incoming
Sergey Ulanov
2014/02/11 08:20:37
Right, but you can still use find_if() with map<>
psj
2014/02/12 09:01:01
Done.
| |
| 75 ActiveSockets active_sockets_; | |
| 76 | |
| 77 DISALLOW_COPY_AND_ASSIGN(GnubbyAuthHandler); | |
| 78 }; | |
| 79 | |
| 80 } // namespace remoting | |
| 81 | |
| 82 #endif // REMOTING_HOST_GNUBBY_AUTH_HANDLER_H_ | |
| OLD | NEW |