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

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: Move filtering based on local input to RemoteInputFilter. 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"
12 #include "remoting/host/remote_input_filter.h"
13 #include "remoting/protocol/connection_to_client.h" 13 #include "remoting/protocol/connection_to_client.h"
14 #include "remoting/protocol/host_stub.h" 14 #include "remoting/protocol/host_stub.h"
15 #include "remoting/protocol/input_event_tracker.h"
16 #include "remoting/protocol/input_filter.h"
15 #include "remoting/protocol/input_stub.h" 17 #include "remoting/protocol/input_stub.h"
16 #include "third_party/skia/include/core/SkPoint.h" 18 #include "third_party/skia/include/core/SkPoint.h"
17 19
18 namespace remoting { 20 namespace remoting {
19 21
20 class Capturer; 22 class Capturer;
21 23
22 // A ClientSession keeps a reference to a connection to a client, and maintains 24 // A ClientSession keeps a reference to a connection to a client, and maintains
23 // per-client state. 25 // per-client state.
24 class ClientSession : public protocol::HostStub, 26 class ClientSession : public protocol::HostStub,
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // Disconnects the session and destroys the transport. Event handler 88 // Disconnects the session and destroys the transport. Event handler
87 // is guaranteed not to be called after this method is called. Can 89 // is guaranteed not to be called after this method is called. Can
88 // be called multiple times. The object should not be used after 90 // be called multiple times. The object should not be used after
89 // this method returns. 91 // this method returns.
90 void Disconnect(); 92 void Disconnect();
91 93
92 protocol::ConnectionToClient* connection() const { 94 protocol::ConnectionToClient* connection() const {
93 return connection_.get(); 95 return connection_.get();
94 } 96 }
95 97
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_; } 98 const std::string& client_jid() { return client_jid_; }
105 99
106 // Indicate that local mouse activity has been detected. This causes remote 100 // 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 101 // inputs to be ignored for a short time so that the local user will always
108 // have the upper hand in 'pointer wars'. 102 // have the upper hand in 'pointer wars'.
109 void LocalMouseMoved(const SkIPoint& new_pos); 103 void LocalMouseMoved(const SkIPoint& new_pos);
110 104
111 bool ShouldIgnoreRemoteMouseInput(const protocol::MouseEvent& event) const; 105 // Disable handling of input events from this client. If the client has any
112 bool ShouldIgnoreRemoteKeyboardInput(const protocol::KeyEvent& event) const; 106 // keys or mouse buttons pressed then these will be released.
107 void SetDisableInputs(bool disable_inputs);
113 108
114 private: 109 private:
115 friend class ClientSessionTest_RestoreEventState_Test; 110 friend class ClientSessionTest_RestoreEventState_Test;
116 111
117 // Keep track of input state so that we can clean up the event queue when 112 // Returns whether input should be ignored because of local activity.
118 // the user disconnects. 113 bool ShouldIgnoreInput() const;
119 void RecordKeyEvent(const protocol::KeyEvent& event);
120 void RecordMouseButtonState(const protocol::MouseEvent& event);
121
122 // Synthesize KeyUp and MouseUp events so that we can undo these events
123 // when the user disconnects.
124 void RestoreEventState();
125 114
126 EventHandler* event_handler_; 115 EventHandler* event_handler_;
127 116
128 // The connection to the client. 117 // The connection to the client.
129 scoped_ptr<protocol::ConnectionToClient> connection_; 118 scoped_ptr<protocol::ConnectionToClient> connection_;
130 119
131 std::string client_jid_; 120 std::string client_jid_;
132 121
133 // The input stub to which this object delegates. 122 // Tracker used to release pressed keys and buttons when disconnecting.
134 protocol::InputStub* input_stub_; 123 protocol::InputEventTracker input_tracker_;
124
125 // Filter used to disable remote inputs during local input activity.
126 RemoteInputFilter remote_input_filter_;
127
128 // Filter used to manage enabling & disabling of client input events.
129 protocol::InputFilter input_filter_;
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.
143 bool authenticated_;
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
149 // State to control remote input blocking while the local pointer is in use.
150 uint32 remote_mouse_button_state_;
151
152 // Current location of the mouse pointer. This is used to provide appropriate
153 // coordinates when we release the mouse buttons after a user disconnects.
154 SkIPoint remote_mouse_pos_;
155
156 // 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,
158 // or genuine mouse movements of a local input device.
159 std::list<SkIPoint> injected_mouse_positions_;
160
161 base::Time latest_local_input_time_;
162
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); 137 DISALLOW_COPY_AND_ASSIGN(ClientSession);
168 }; 138 };
169 139
170 } // namespace remoting 140 } // namespace remoting
171 141
172 #endif // REMOTING_HOST_CLIENT_SESSION_H_ 142 #endif // REMOTING_HOST_CLIENT_SESSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698