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 <list> | 8 #include <list> |
9 #include <set> | 9 #include <set> |
10 | 10 |
11 #include "base/time.h" | 11 #include "base/time.h" |
12 #include "remoting/protocol/connection_to_client.h" | 12 #include "remoting/protocol/connection_to_client.h" |
13 #include "remoting/protocol/host_stub.h" | 13 #include "remoting/protocol/host_stub.h" |
14 #include "remoting/protocol/input_stub.h" | 14 #include "remoting/protocol/input_stub.h" |
15 #include "third_party/skia/include/core/SkPoint.h" | 15 #include "third_party/skia/include/core/SkPoint.h" |
16 | 16 |
17 namespace remoting { | 17 namespace remoting { |
18 | 18 |
19 class Capturer; | 19 class Capturer; |
20 | 20 |
21 // A ClientSession keeps a reference to a connection to a client, and maintains | 21 // A ClientSession keeps a reference to a connection to a client, and maintains |
22 // per-client state. | 22 // per-client state. |
23 class ClientSession : public protocol::HostStub, | 23 class ClientSession : public protocol::HostStub, |
24 public protocol::InputStub, | 24 public protocol::InputStub, |
25 public protocol::ConnectionToClient::EventHandler, | |
25 public base::RefCountedThreadSafe<ClientSession> { | 26 public base::RefCountedThreadSafe<ClientSession> { |
26 public: | 27 public: |
27 // Callback interface for passing events to the ChromotingHost. | 28 // Callback interface for passing events to the ChromotingHost. |
28 class EventHandler { | 29 class EventHandler { |
29 public: | 30 public: |
30 virtual ~EventHandler() {} | 31 virtual ~EventHandler() {} |
31 | 32 |
32 // Called to signal that authentication has succeeded. | 33 virtual void OnSessionAuthenticated(ClientSession* client) = 0; |
33 virtual void OnAuthenticationComplete( | 34 virtual void OnSessionClosed(ClientSession* client) = 0; |
34 scoped_refptr<protocol::ConnectionToClient> client) = 0; | 35 virtual void OnSessionFailed(ClientSession* client) = 0; |
36 virtual void OnSessionSequenceNumber(ClientSession* client, | |
37 int64 sequence_number) = 0; | |
35 }; | 38 }; |
36 | 39 |
37 // Takes ownership of |user_authenticator|. Does not take ownership of | 40 // Takes ownership of |user_authenticator|. Does not take ownership of |
38 // |event_handler|, |input_stub| or |capturer|. | 41 // |event_handler|, |input_stub| or |capturer|. |
39 ClientSession(EventHandler* event_handler, | 42 ClientSession(EventHandler* event_handler, |
40 scoped_refptr<protocol::ConnectionToClient> connection, | 43 scoped_refptr<protocol::ConnectionToClient> connection, |
41 protocol::InputStub* input_stub, | 44 protocol::InputStub* input_stub, |
42 Capturer* capturer); | 45 Capturer* capturer); |
43 | 46 |
44 // protocol::InputStub interface. | 47 // protocol::InputStub interface. |
45 virtual void InjectKeyEvent(const protocol::KeyEvent& event); | 48 virtual void InjectKeyEvent(const protocol::KeyEvent& event); |
46 virtual void InjectMouseEvent(const protocol::MouseEvent& event); | 49 virtual void InjectMouseEvent(const protocol::MouseEvent& event); |
47 | 50 |
48 // Notifier called when the client is being disconnected. | 51 // protocol::ConnectionToClient::EventHandler interface. |
49 // This should only be called by ChromotingHost. | 52 virtual void OnConnectionOpened( |
50 void OnDisconnected(); | 53 protocol::ConnectionToClient* connection) OVERRIDE; |
54 virtual void OnConnectionClosed( | |
55 protocol::ConnectionToClient* connection) OVERRIDE; | |
56 virtual void OnConnectionFailed( | |
57 protocol::ConnectionToClient* connection) OVERRIDE; | |
58 virtual void OnSequenceNumberUpdated( | |
59 protocol::ConnectionToClient* connection, int64 sequence_number) OVERRIDE; | |
51 | 60 |
52 // Set the authenticated flag. | 61 // Disconnect the session |
Wez
2011/11/09 01:35:07
typo: missing .
What does it mean to "disconnect
| |
53 void OnAuthenticationComplete(); | 62 void Disconnect(); |
54 | 63 |
55 protocol::ConnectionToClient* connection() const { | 64 protocol::ConnectionToClient* connection() const { |
56 return connection_.get(); | 65 return connection_.get(); |
57 } | 66 } |
58 | 67 |
59 bool authenticated() const { | 68 bool authenticated() const { |
60 return authenticated_; | 69 return authenticated_; |
61 } | 70 } |
62 | 71 |
63 void set_awaiting_continue_approval(bool awaiting) { | 72 void set_awaiting_continue_approval(bool awaiting) { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 // Set of keys that are currently pressed down by the user. This is used so | 137 // Set of keys that are currently pressed down by the user. This is used so |
129 // we can release them if the user disconnects. | 138 // we can release them if the user disconnects. |
130 std::set<int> pressed_keys_; | 139 std::set<int> pressed_keys_; |
131 | 140 |
132 DISALLOW_COPY_AND_ASSIGN(ClientSession); | 141 DISALLOW_COPY_AND_ASSIGN(ClientSession); |
133 }; | 142 }; |
134 | 143 |
135 } // namespace remoting | 144 } // namespace remoting |
136 | 145 |
137 #endif // REMOTING_HOST_CLIENT_SESSION_H_ | 146 #endif // REMOTING_HOST_CLIENT_SESSION_H_ |
OLD | NEW |