blob: ac124a8399184b5b8e5a6c58d9c295a468645745 [file] [log] [blame]
[email protected]44f60762011-03-23 12:13:351// 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
3// found in the LICENSE file.
4
5#ifndef REMOTING_HOST_CLIENT_SESSION_H_
6#define REMOTING_HOST_CLIENT_SESSION_H_
7
8#include "remoting/protocol/connection_to_client.h"
9#include "remoting/protocol/host_stub.h"
[email protected]4ea2c7c2011-03-31 14:20:0610#include "remoting/protocol/input_stub.h"
[email protected]44f60762011-03-23 12:13:3511
12namespace remoting {
13
[email protected]4ea2c7c2011-03-31 14:20:0614class UserAuthenticator;
15
[email protected]44f60762011-03-23 12:13:3516// A ClientSession keeps a reference to a connection to a client, and maintains
17// per-client state.
18class ClientSession : public protocol::HostStub,
[email protected]4ea2c7c2011-03-31 14:20:0619 public protocol::InputStub,
[email protected]44f60762011-03-23 12:13:3520 public base::RefCountedThreadSafe<ClientSession> {
21 public:
22 // Callback interface for passing events to the ChromotingHost.
23 class EventHandler {
24 public:
25 virtual ~EventHandler() {}
26
27 // Called to signal that local login has succeeded and ChromotingHost can
28 // proceed with the next step.
29 virtual void LocalLoginSucceeded(
30 scoped_refptr<protocol::ConnectionToClient> client) = 0;
31
32 // Called to signal that local login has failed.
33 virtual void LocalLoginFailed(
34 scoped_refptr<protocol::ConnectionToClient> client) = 0;
35 };
36
[email protected]844a3722011-05-13 00:32:0237 // Takes ownership of |user_authenticator|. Does not take ownership of
38 // |event_handler| or |input_stub|.
[email protected]44f60762011-03-23 12:13:3539 ClientSession(EventHandler* event_handler,
[email protected]0b7e4282011-04-04 22:44:1140 UserAuthenticator* user_authenticator,
[email protected]4ea2c7c2011-03-31 14:20:0641 scoped_refptr<protocol::ConnectionToClient> connection,
42 protocol::InputStub* input_stub);
[email protected]44f60762011-03-23 12:13:3543
44 // protocol::HostStub interface.
45 virtual void SuggestResolution(
46 const protocol::SuggestResolutionRequest* msg, Task* done);
47 virtual void BeginSessionRequest(
48 const protocol::LocalLoginCredentials* credentials, Task* done);
49
[email protected]4ea2c7c2011-03-31 14:20:0650 // protocol::InputStub interface.
51 virtual void InjectKeyEvent(const protocol::KeyEvent* event, Task* done);
52 virtual void InjectMouseEvent(const protocol::MouseEvent* event, Task* done);
53
[email protected]44f60762011-03-23 12:13:3554 // Disconnect this client session.
55 void Disconnect();
56
[email protected]1ce457a2011-05-19 19:59:4857 // Set the authenticated flag or log a failure message as appropriate.
58 void OnAuthorizationComplete(bool success);
59
[email protected]4ea2c7c2011-03-31 14:20:0660 protocol::ConnectionToClient* connection() const {
61 return connection_.get();
62 }
[email protected]44f60762011-03-23 12:13:3563
[email protected]4ea2c7c2011-03-31 14:20:0664 bool authenticated() const {
65 return authenticated_;
66 }
[email protected]44f60762011-03-23 12:13:3567
68 private:
[email protected]4ea2c7c2011-03-31 14:20:0669 friend class base::RefCountedThreadSafe<ClientSession>;
70 virtual ~ClientSession();
71
[email protected]44f60762011-03-23 12:13:3572 EventHandler* event_handler_;
[email protected]4ea2c7c2011-03-31 14:20:0673
74 // A factory for user authenticators.
[email protected]0b7e4282011-04-04 22:44:1175 scoped_ptr<UserAuthenticator> user_authenticator_;
[email protected]4ea2c7c2011-03-31 14:20:0676
77 // The connection to the client.
[email protected]44f60762011-03-23 12:13:3578 scoped_refptr<protocol::ConnectionToClient> connection_;
79
[email protected]4ea2c7c2011-03-31 14:20:0680 // The input stub to which this object delegates.
81 protocol::InputStub* input_stub_;
82
83 // Whether this client is authenticated.
84 bool authenticated_;
85
[email protected]44f60762011-03-23 12:13:3586 DISALLOW_COPY_AND_ASSIGN(ClientSession);
87};
88
89} // namespace remoting
90
91#endif // REMOTING_HOST_CLIENT_SESSION_H_