Chromium Code Reviews| 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 OnSessionSequenceNumber(ClientSession* client, |
| 36 int64 sequence_number) = 0; | |
| 35 }; | 37 }; |
| 36 | 38 |
| 37 // Takes ownership of |user_authenticator|. Does not take ownership of | 39 // Takes ownership of |user_authenticator|. Does not take ownership of |
| 38 // |event_handler|, |input_stub| or |capturer|. | 40 // |event_handler|, |input_stub| or |capturer|. |
| 39 ClientSession(EventHandler* event_handler, | 41 ClientSession(EventHandler* event_handler, |
| 40 scoped_refptr<protocol::ConnectionToClient> connection, | 42 scoped_refptr<protocol::ConnectionToClient> connection, |
| 41 protocol::InputStub* input_stub, | 43 protocol::InputStub* input_stub, |
| 42 Capturer* capturer); | 44 Capturer* capturer); |
| 43 | 45 |
| 44 // protocol::InputStub interface. | 46 // protocol::InputStub interface. |
| 45 virtual void InjectKeyEvent(const protocol::KeyEvent& event); | 47 virtual void InjectKeyEvent(const protocol::KeyEvent& event); |
| 46 virtual void InjectMouseEvent(const protocol::MouseEvent& event); | 48 virtual void InjectMouseEvent(const protocol::MouseEvent& event); |
| 47 | 49 |
| 48 // Notifier called when the client is being disconnected. | 50 // protocol::ConnectionToClient::EventHandler interface. |
| 49 // This should only be called by ChromotingHost. | 51 virtual void OnConnectionOpened( |
| 50 void OnDisconnected(); | 52 protocol::ConnectionToClient* connection) OVERRIDE; |
| 53 virtual void OnConnectionClosed( | |
| 54 protocol::ConnectionToClient* connection) OVERRIDE; | |
| 55 virtual void OnConnectionFailed( | |
| 56 protocol::ConnectionToClient* connection) OVERRIDE; | |
| 57 virtual void OnSequenceNumberUpdated( | |
| 58 protocol::ConnectionToClient* connection, int64 sequence_number) OVERRIDE; | |
| 51 | 59 |
| 52 // Set the authenticated flag. | 60 // Disconnect the session |
| 53 void OnAuthenticationComplete(); | 61 void Disconnect(); |
|
Wez
2011/11/09 01:35:07
Clarify the semantics; does this perform the netwo
Sergey Ulanov
2011/11/09 19:26:13
Done
| |
| 54 | 62 |
| 55 protocol::ConnectionToClient* connection() const { | 63 protocol::ConnectionToClient* connection() const { |
| 56 return connection_.get(); | 64 return connection_.get(); |
| 57 } | 65 } |
| 58 | 66 |
| 59 bool authenticated() const { | 67 bool authenticated() const { |
| 60 return authenticated_; | 68 return authenticated_; |
| 61 } | 69 } |
| 62 | 70 |
| 63 void set_awaiting_continue_approval(bool awaiting) { | 71 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 | 136 // Set of keys that are currently pressed down by the user. This is used so |
| 129 // we can release them if the user disconnects. | 137 // we can release them if the user disconnects. |
| 130 std::set<int> pressed_keys_; | 138 std::set<int> pressed_keys_; |
| 131 | 139 |
| 132 DISALLOW_COPY_AND_ASSIGN(ClientSession); | 140 DISALLOW_COPY_AND_ASSIGN(ClientSession); |
| 133 }; | 141 }; |
| 134 | 142 |
| 135 } // namespace remoting | 143 } // namespace remoting |
| 136 | 144 |
| 137 #endif // REMOTING_HOST_CLIENT_SESSION_H_ | 145 #endif // REMOTING_HOST_CLIENT_SESSION_H_ |
| OLD | NEW |