| 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. |
| 29 // Called only for external events, i.e. OnSessionClosed() is not |
| 30 // called when Disconnect() is called. |
| 28 class EventHandler { | 31 class EventHandler { |
| 29 public: | 32 public: |
| 30 virtual ~EventHandler() {} | 33 virtual ~EventHandler() {} |
| 31 | 34 |
| 32 // Called to signal that authentication has succeeded. | 35 virtual void OnSessionAuthenticated(ClientSession* client) = 0; |
| 33 virtual void OnAuthenticationComplete( | 36 virtual void OnSessionClosed(ClientSession* client) = 0; |
| 34 scoped_refptr<protocol::ConnectionToClient> client) = 0; | 37 virtual void OnSessionSequenceNumber(ClientSession* client, |
| 38 int64 sequence_number) = 0; |
| 35 }; | 39 }; |
| 36 | 40 |
| 37 // Takes ownership of |user_authenticator|. Does not take ownership of | 41 // Takes ownership of |user_authenticator|. Does not take ownership of |
| 38 // |event_handler|, |input_stub| or |capturer|. | 42 // |event_handler|, |input_stub| or |capturer|. |
| 39 ClientSession(EventHandler* event_handler, | 43 ClientSession(EventHandler* event_handler, |
| 40 scoped_refptr<protocol::ConnectionToClient> connection, | 44 scoped_refptr<protocol::ConnectionToClient> connection, |
| 41 protocol::InputStub* input_stub, | 45 protocol::InputStub* input_stub, |
| 42 Capturer* capturer); | 46 Capturer* capturer); |
| 43 | 47 |
| 44 // protocol::InputStub interface. | 48 // protocol::InputStub interface. |
| 45 virtual void InjectKeyEvent(const protocol::KeyEvent& event); | 49 virtual void InjectKeyEvent(const protocol::KeyEvent& event); |
| 46 virtual void InjectMouseEvent(const protocol::MouseEvent& event); | 50 virtual void InjectMouseEvent(const protocol::MouseEvent& event); |
| 47 | 51 |
| 48 // Notifier called when the client is being disconnected. | 52 // protocol::ConnectionToClient::EventHandler interface. |
| 49 // This should only be called by ChromotingHost. | 53 virtual void OnConnectionOpened( |
| 50 void OnDisconnected(); | 54 protocol::ConnectionToClient* connection) OVERRIDE; |
| 55 virtual void OnConnectionClosed( |
| 56 protocol::ConnectionToClient* connection) OVERRIDE; |
| 57 virtual void OnConnectionFailed( |
| 58 protocol::ConnectionToClient* connection) OVERRIDE; |
| 59 virtual void OnSequenceNumberUpdated( |
| 60 protocol::ConnectionToClient* connection, int64 sequence_number) OVERRIDE; |
| 51 | 61 |
| 52 // Set the authenticated flag. | 62 // Disconnects the session and destroys the transport. Event handler |
| 53 void OnAuthenticationComplete(); | 63 // is guaranteed not to be called after this method is called. Can |
| 64 // be called multiple times. The object should not be used after |
| 65 // this method returns. |
| 66 void Disconnect(); |
| 54 | 67 |
| 55 protocol::ConnectionToClient* connection() const { | 68 protocol::ConnectionToClient* connection() const { |
| 56 return connection_.get(); | 69 return connection_.get(); |
| 57 } | 70 } |
| 58 | 71 |
| 59 bool authenticated() const { | 72 bool authenticated() const { |
| 60 return authenticated_; | 73 return authenticated_; |
| 61 } | 74 } |
| 62 | 75 |
| 63 void set_awaiting_continue_approval(bool awaiting) { | 76 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 | 141 // Set of keys that are currently pressed down by the user. This is used so |
| 129 // we can release them if the user disconnects. | 142 // we can release them if the user disconnects. |
| 130 std::set<int> pressed_keys_; | 143 std::set<int> pressed_keys_; |
| 131 | 144 |
| 132 DISALLOW_COPY_AND_ASSIGN(ClientSession); | 145 DISALLOW_COPY_AND_ASSIGN(ClientSession); |
| 133 }; | 146 }; |
| 134 | 147 |
| 135 } // namespace remoting | 148 } // namespace remoting |
| 136 | 149 |
| 137 #endif // REMOTING_HOST_CLIENT_SESSION_H_ | 150 #endif // REMOTING_HOST_CLIENT_SESSION_H_ |
| OLD | NEW |