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 |
| 37 typedef UserAuthenticator* UserAuthenticatorFactory(); |
| 38 |
33 ClientSession(EventHandler* event_handler, | 39 ClientSession(EventHandler* event_handler, |
34 scoped_refptr<protocol::ConnectionToClient> connection); | 40 const base::Callback<UserAuthenticatorFactory>& auth_factory, |
| 41 scoped_refptr<protocol::ConnectionToClient> connection, |
| 42 protocol::InputStub* input_stub); |
35 | 43 |
36 // protocol::HostStub interface. | 44 // protocol::HostStub interface. |
37 virtual void SuggestResolution( | 45 virtual void SuggestResolution( |
38 const protocol::SuggestResolutionRequest* msg, Task* done); | 46 const protocol::SuggestResolutionRequest* msg, Task* done); |
39 virtual void BeginSessionRequest( | 47 virtual void BeginSessionRequest( |
40 const protocol::LocalLoginCredentials* credentials, Task* done); | 48 const protocol::LocalLoginCredentials* credentials, Task* done); |
41 | 49 |
| 50 // protocol::InputStub interface. |
| 51 virtual void InjectKeyEvent(const protocol::KeyEvent* event, Task* done); |
| 52 virtual void InjectMouseEvent(const protocol::MouseEvent* event, Task* done); |
| 53 |
42 // Disconnect this client session. | 54 // Disconnect this client session. |
43 void Disconnect(); | 55 void Disconnect(); |
44 | 56 |
45 protocol::ConnectionToClient* connection() const; | 57 protocol::ConnectionToClient* connection() const { |
| 58 return connection_.get(); |
| 59 } |
46 | 60 |
47 protected: | 61 bool authenticated() const { |
48 friend class base::RefCountedThreadSafe<ClientSession>; | 62 return authenticated_; |
49 ~ClientSession(); | 63 } |
50 | 64 |
51 private: | 65 private: |
| 66 friend class base::RefCountedThreadSafe<ClientSession>; |
| 67 virtual ~ClientSession(); |
| 68 |
52 EventHandler* event_handler_; | 69 EventHandler* event_handler_; |
| 70 |
| 71 // A factory for user authenticators. |
| 72 base::Callback<UserAuthenticatorFactory> auth_factory_; |
| 73 |
| 74 // The connection to the client. |
53 scoped_refptr<protocol::ConnectionToClient> connection_; | 75 scoped_refptr<protocol::ConnectionToClient> connection_; |
54 | 76 |
| 77 // The input stub to which this object delegates. |
| 78 protocol::InputStub* input_stub_; |
| 79 |
| 80 // Whether this client is authenticated. |
| 81 bool authenticated_; |
| 82 |
55 DISALLOW_COPY_AND_ASSIGN(ClientSession); | 83 DISALLOW_COPY_AND_ASSIGN(ClientSession); |
56 }; | 84 }; |
57 | 85 |
58 } // namespace remoting | 86 } // namespace remoting |
59 | 87 |
60 #endif // REMOTING_HOST_CLIENT_SESSION_H_ | 88 #endif // REMOTING_HOST_CLIENT_SESSION_H_ |
OLD | NEW |