Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: remoting/host/client_session.h

Issue 9465035: Move ClientSession's input logic into separate components. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge authenticated and awaiting-continue states. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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>
10 9
11 #include "base/time.h" 10 #include "base/time.h"
12 #include "base/threading/non_thread_safe.h" 11 #include "base/threading/non_thread_safe.h"
13 #include "remoting/protocol/connection_to_client.h" 12 #include "remoting/protocol/connection_to_client.h"
14 #include "remoting/protocol/host_stub.h" 13 #include "remoting/protocol/host_stub.h"
15 #include "remoting/protocol/input_stub.h" 14 #include "remoting/protocol/input_stub.h"
15 #include "remoting/protocol/key_event_tracker.h"
16 #include "third_party/skia/include/core/SkPoint.h" 16 #include "third_party/skia/include/core/SkPoint.h"
17 17
18 namespace remoting { 18 namespace remoting {
19 19
20 class Capturer; 20 class Capturer;
21 21
22 // A ClientSession keeps a reference to a connection to a client, and maintains 22 // A ClientSession keeps a reference to a connection to a client, and maintains
23 // per-client state. 23 // per-client state.
24 class ClientSession : public protocol::HostStub, 24 class ClientSession : public protocol::HostStub,
25 public protocol::InputStub, 25 public protocol::InputStub,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // Disconnects the session and destroys the transport. Event handler 86 // Disconnects the session and destroys the transport. Event handler
87 // is guaranteed not to be called after this method is called. Can 87 // is guaranteed not to be called after this method is called. Can
88 // be called multiple times. The object should not be used after 88 // be called multiple times. The object should not be used after
89 // this method returns. 89 // this method returns.
90 void Disconnect(); 90 void Disconnect();
91 91
92 protocol::ConnectionToClient* connection() const { 92 protocol::ConnectionToClient* connection() const {
93 return connection_.get(); 93 return connection_.get();
94 } 94 }
95 95
96 bool authenticated() const {
97 return authenticated_;
98 }
99
100 void set_awaiting_continue_approval(bool awaiting) {
101 awaiting_continue_approval_ = awaiting;
102 }
103
104 const std::string& client_jid() { return client_jid_; } 96 const std::string& client_jid() { return client_jid_; }
105 97
106 // Indicate that local mouse activity has been detected. This causes remote 98 // Indicate that local mouse activity has been detected. This causes remote
107 // inputs to be ignored for a short time so that the local user will always 99 // inputs to be ignored for a short time so that the local user will always
108 // have the upper hand in 'pointer wars'. 100 // have the upper hand in 'pointer wars'.
109 void LocalMouseMoved(const SkIPoint& new_pos); 101 void LocalMouseMoved(const SkIPoint& new_pos);
110 102
111 bool ShouldIgnoreRemoteMouseInput(const protocol::MouseEvent& event) const; 103 // Disable handling of input events from this client. If the client has any
112 bool ShouldIgnoreRemoteKeyboardInput(const protocol::KeyEvent& event) const; 104 // keys or mouse buttons pressed then these will be released.
105 void SetDisableInputs(bool disable_inputs);
113 106
114 private: 107 private:
115 friend class ClientSessionTest_RestoreEventState_Test; 108 friend class ClientSessionTest_RestoreEventState_Test;
Jamie 2012/03/15 18:38:56 Should this be the appropriate ALL_PREFIXES macro?
Wez 2012/03/15 22:25:29 Actually, I don't think it's required at all. Rem
116 109
117 // Keep track of input state so that we can clean up the event queue when 110 // Returns whether input should be ignored because of local activity.
111 bool ShouldIgnoreInput() const;
112
113 // Keep track of mouse state so that we can clean up the event queue when
118 // the user disconnects. 114 // the user disconnects.
119 void RecordKeyEvent(const protocol::KeyEvent& event);
120 void RecordMouseButtonState(const protocol::MouseEvent& event); 115 void RecordMouseButtonState(const protocol::MouseEvent& event);
121 116
122 // Synthesize KeyUp and MouseUp events so that we can undo these events 117 // Synthesize KeyUp and MouseUp events so that we can undo these events
123 // when the user disconnects. 118 // when the user disconnects.
124 void RestoreEventState(); 119 void RestoreEventState();
125 120
126 EventHandler* event_handler_; 121 EventHandler* event_handler_;
127 122
128 // The connection to the client. 123 // The connection to the client.
129 scoped_ptr<protocol::ConnectionToClient> connection_; 124 scoped_ptr<protocol::ConnectionToClient> connection_;
130 125
131 std::string client_jid_; 126 std::string client_jid_;
132 127
133 // The input stub to which this object delegates. 128 // Key event tracker used to release pressed keys when disconnecting.
134 protocol::InputStub* input_stub_; 129 protocol::KeyEventTracker key_tracker_;
135 130
136 // Capturer, used to determine current screen size for ensuring injected 131 // Capturer, used to determine current screen size for ensuring injected
137 // mouse events fall within the screen area. 132 // mouse events fall within the screen area.
138 // TODO(lambroslambrou): Move floor-control logic, and clamping to screen 133 // TODO(lambroslambrou): Move floor-control logic, and clamping to screen
139 // area, out of this class (crbug.com/96508). 134 // area, out of this class (crbug.com/96508).
140 Capturer* capturer_; 135 Capturer* capturer_;
141 136
142 // Whether this client is authenticated. 137 // Whether or not input events from the client should be processed.
143 bool authenticated_; 138 bool disable_inputs_;
144
145 // Whether or not inputs from this client are blocked pending approval from
146 // the host user to continue the connection.
147 bool awaiting_continue_approval_;
148 139
149 // State to control remote input blocking while the local pointer is in use. 140 // State to control remote input blocking while the local pointer is in use.
150 uint32 remote_mouse_button_state_; 141 uint32 remote_mouse_button_state_;
151 142
152 // Current location of the mouse pointer. This is used to provide appropriate 143 // Current location of the mouse pointer. This is used to provide appropriate
153 // coordinates when we release the mouse buttons after a user disconnects. 144 // coordinates when we release the mouse buttons after a user disconnects.
154 SkIPoint remote_mouse_pos_; 145 SkIPoint remote_mouse_pos_;
155 146
156 // Queue of recently-injected mouse positions. This is used to detect whether 147 // Queue of recently-injected mouse positions. This is used to detect whether
157 // mouse events from the local input monitor are echoes of injected positions, 148 // mouse events from the local input monitor are echoes of injected positions,
158 // or genuine mouse movements of a local input device. 149 // or genuine mouse movements of a local input device.
159 std::list<SkIPoint> injected_mouse_positions_; 150 std::list<SkIPoint> injected_mouse_positions_;
160 151
161 base::Time latest_local_input_time_; 152 base::Time latest_local_input_time_;
162 153
163 // Set of keys that are currently pressed down by the user. This is used so
164 // we can release them if the user disconnects.
165 std::set<int> pressed_keys_;
166
167 DISALLOW_COPY_AND_ASSIGN(ClientSession); 154 DISALLOW_COPY_AND_ASSIGN(ClientSession);
168 }; 155 };
169 156
170 } // namespace remoting 157 } // namespace remoting
171 158
172 #endif // REMOTING_HOST_CLIENT_SESSION_H_ 159 #endif // REMOTING_HOST_CLIENT_SESSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698