OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef REMOTING_HOST_CLIENT_SESSION_H_ | 5 #ifndef REMOTING_HOST_CLIENT_SESSION_H_ |
6 #define REMOTING_HOST_CLIENT_SESSION_H_ | 6 #define REMOTING_HOST_CLIENT_SESSION_H_ |
7 | 7 |
8 #include "remoting/protocol/connection_to_client.h" | 8 #include "remoting/protocol/connection_to_client.h" |
9 #include "remoting/protocol/host_stub.h" | 9 #include "remoting/protocol/host_stub.h" |
10 #include "remoting/protocol/input_stub.h" | |
10 | 11 |
11 namespace remoting { | 12 namespace remoting { |
12 | 13 |
14 class UserAuthenticator; | |
15 | |
13 // A ClientSession keeps a reference to a connection to a client, and maintains | 16 // A ClientSession keeps a reference to a connection to a client, and maintains |
14 // per-client state. | 17 // per-client state. |
15 class ClientSession : public protocol::HostStub, | 18 class ClientSession : public protocol::HostStub, |
19 public protocol::InputStub, | |
16 public base::RefCountedThreadSafe<ClientSession> { | 20 public base::RefCountedThreadSafe<ClientSession> { |
17 public: | 21 public: |
18 // Callback interface for passing events to the ChromotingHost. | 22 // Callback interface for passing events to the ChromotingHost. |
19 class EventHandler { | 23 class EventHandler { |
20 public: | 24 public: |
21 virtual ~EventHandler() {} | 25 virtual ~EventHandler() {} |
22 | 26 |
23 // Called to signal that local login has succeeded and ChromotingHost can | 27 // Called to signal that local login has succeeded and ChromotingHost can |
24 // proceed with the next step. | 28 // proceed with the next step. |
25 virtual void LocalLoginSucceeded( | 29 virtual void LocalLoginSucceeded( |
26 scoped_refptr<protocol::ConnectionToClient> client) = 0; | 30 scoped_refptr<protocol::ConnectionToClient> client) = 0; |
27 | 31 |
28 // Called to signal that local login has failed. | 32 // Called to signal that local login has failed. |
29 virtual void LocalLoginFailed( | 33 virtual void LocalLoginFailed( |
30 scoped_refptr<protocol::ConnectionToClient> client) = 0; | 34 scoped_refptr<protocol::ConnectionToClient> client) = 0; |
31 }; | 35 }; |
32 | 36 |
33 ClientSession(EventHandler* event_handler, | 37 ClientSession(EventHandler* event_handler, |
34 scoped_refptr<protocol::ConnectionToClient> connection); | 38 const base::Callback<UserAuthenticator*(void)>& auth_factory, |
Alpha Left Google
2011/03/28 16:22:26
I'm a but confused looking at this, can you do som
simonmorris
2011/03/29 17:07:51
Done.
| |
39 scoped_refptr<protocol::ConnectionToClient> connection, | |
40 protocol::InputStub* input_stub); | |
35 | 41 |
36 // protocol::HostStub interface. | 42 // protocol::HostStub interface. |
37 virtual void SuggestResolution( | 43 virtual void SuggestResolution( |
38 const protocol::SuggestResolutionRequest* msg, Task* done); | 44 const protocol::SuggestResolutionRequest* msg, Task* done); |
39 virtual void BeginSessionRequest( | 45 virtual void BeginSessionRequest( |
40 const protocol::LocalLoginCredentials* credentials, Task* done); | 46 const protocol::LocalLoginCredentials* credentials, Task* done); |
41 | 47 |
48 // protocol::InputStub interface. | |
49 virtual void InjectKeyEvent(const protocol::KeyEvent* event, Task* done); | |
50 virtual void InjectMouseEvent(const protocol::MouseEvent* event, Task* done); | |
51 | |
42 // Disconnect this client session. | 52 // Disconnect this client session. |
43 void Disconnect(); | 53 void Disconnect(); |
44 | 54 |
45 protocol::ConnectionToClient* connection() const; | 55 protocol::ConnectionToClient* connection() const; |
Alpha Left Google
2011/03/28 16:22:26
nit: this getter can be inline.
simonmorris
2011/03/29 17:07:51
Done.
| |
56 bool authenticated() const; | |
Alpha Left Google
2011/03/28 16:22:26
nit: for simple getter like this you can simply do
simonmorris
2011/03/29 17:07:51
Done.
| |
46 | 57 |
47 protected: | 58 protected: |
Alpha Left Google
2011/03/28 16:22:26
nit: Is there other class that inherit this? I thi
simonmorris
2011/03/29 17:07:51
Done.
| |
48 friend class base::RefCountedThreadSafe<ClientSession>; | 59 friend class base::RefCountedThreadSafe<ClientSession>; |
49 ~ClientSession(); | 60 ~ClientSession(); |
Alpha Left Google
2011/03/28 16:22:26
virtual ~ClientSession();
simonmorris
2011/03/29 17:07:51
Done.
| |
50 | 61 |
51 private: | 62 private: |
52 EventHandler* event_handler_; | 63 EventHandler* event_handler_; |
64 | |
65 // A factory for user authenticators. | |
66 base::Callback<UserAuthenticator*(void)> auth_factory_; | |
67 | |
68 // The connection to the client. | |
53 scoped_refptr<protocol::ConnectionToClient> connection_; | 69 scoped_refptr<protocol::ConnectionToClient> connection_; |
54 | 70 |
71 // The input stub to which this object delegates. | |
72 protocol::InputStub* input_stub_; | |
73 | |
74 // Whether this client is authenticated. | |
75 bool authenticated_; | |
76 | |
55 DISALLOW_COPY_AND_ASSIGN(ClientSession); | 77 DISALLOW_COPY_AND_ASSIGN(ClientSession); |
56 }; | 78 }; |
57 | 79 |
58 } // namespace remoting | 80 } // namespace remoting |
59 | 81 |
60 #endif // REMOTING_HOST_CLIENT_SESSION_H_ | 82 #endif // REMOTING_HOST_CLIENT_SESSION_H_ |
OLD | NEW |