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

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

Issue 10911248: Revert 156297 - [Chromoting] Refactoring DesktopEnvironment and moving screen/audio recorders to Cl… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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
« no previous file with comments | « remoting/host/chromoting_host_unittest.cc ('k') | remoting/host/client_session.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9
10 #include "base/memory/ref_counted.h"
11 #include "base/sequenced_task_runner_helpers.h"
12 #include "base/time.h" 10 #include "base/time.h"
13 #include "base/timer.h" 11 #include "base/timer.h"
14 #include "base/threading/non_thread_safe.h" 12 #include "base/threading/non_thread_safe.h"
15 #include "remoting/host/mouse_clamping_filter.h" 13 #include "remoting/host/mouse_clamping_filter.h"
16 #include "remoting/host/remote_input_filter.h" 14 #include "remoting/host/remote_input_filter.h"
17 #include "remoting/protocol/clipboard_echo_filter.h" 15 #include "remoting/protocol/clipboard_echo_filter.h"
18 #include "remoting/protocol/clipboard_filter.h" 16 #include "remoting/protocol/clipboard_filter.h"
19 #include "remoting/protocol/clipboard_stub.h" 17 #include "remoting/protocol/clipboard_stub.h"
20 #include "remoting/protocol/connection_to_client.h" 18 #include "remoting/protocol/connection_to_client.h"
21 #include "remoting/protocol/host_stub.h" 19 #include "remoting/protocol/host_stub.h"
22 #include "remoting/protocol/input_event_tracker.h" 20 #include "remoting/protocol/input_event_tracker.h"
23 #include "remoting/protocol/input_filter.h" 21 #include "remoting/protocol/input_filter.h"
24 #include "remoting/protocol/input_stub.h" 22 #include "remoting/protocol/input_stub.h"
25 #include "third_party/skia/include/core/SkPoint.h" 23 #include "third_party/skia/include/core/SkPoint.h"
26 24
27 namespace base {
28 class SingleThreadTaskRunner;
29 } // namespace base
30
31 namespace remoting { 25 namespace remoting {
32 26
33 class AudioEncoder;
34 class AudioScheduler;
35 struct ClientSessionTraits;
36 class DesktopEnvironment;
37 class ScreenRecorder;
38 class VideoEncoder;
39 class VideoFrameCapturer; 27 class VideoFrameCapturer;
40 28
41 // A ClientSession keeps a reference to a connection to a client, and maintains 29 // A ClientSession keeps a reference to a connection to a client, and maintains
42 // per-client state. 30 // per-client state.
43 class ClientSession 31 class ClientSession : public protocol::HostStub,
44 : public base::RefCountedThreadSafe<ClientSession, ClientSessionTraits>, 32 public protocol::ConnectionToClient::EventHandler,
45 public protocol::HostStub, 33 public base::NonThreadSafe {
46 public protocol::ConnectionToClient::EventHandler,
47 public base::NonThreadSafe {
48 public: 34 public:
49 // Callback interface for passing events to the ChromotingHost. 35 // Callback interface for passing events to the ChromotingHost.
50 class EventHandler { 36 class EventHandler {
51 public: 37 public:
52 // Called after authentication has finished successfully. 38 // Called after authentication has finished successfully.
53 virtual void OnSessionAuthenticated(ClientSession* client) = 0; 39 virtual void OnSessionAuthenticated(ClientSession* client) = 0;
54 40
55 // Called after we've finished connecting all channels. 41 // Called after we've finished connecting all channels.
56 virtual void OnSessionChannelsConnected(ClientSession* client) = 0; 42 virtual void OnSessionChannelsConnected(ClientSession* client) = 0;
57 43
(...skipping 15 matching lines...) Expand all
73 virtual void OnSessionRouteChange( 59 virtual void OnSessionRouteChange(
74 ClientSession* client, 60 ClientSession* client,
75 const std::string& channel_name, 61 const std::string& channel_name,
76 const protocol::TransportRoute& route) = 0; 62 const protocol::TransportRoute& route) = 0;
77 63
78 protected: 64 protected:
79 virtual ~EventHandler() {} 65 virtual ~EventHandler() {}
80 }; 66 };
81 67
82 ClientSession(EventHandler* event_handler, 68 ClientSession(EventHandler* event_handler,
83 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner,
84 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner,
85 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
86 scoped_ptr<protocol::ConnectionToClient> connection, 69 scoped_ptr<protocol::ConnectionToClient> connection,
87 scoped_ptr<DesktopEnvironment> desktop_environment, 70 protocol::ClipboardStub* host_clipboard_stub,
71 protocol::InputStub* host_input_stub,
72 VideoFrameCapturer* capturer,
88 const base::TimeDelta& max_duration); 73 const base::TimeDelta& max_duration);
74 virtual ~ClientSession();
89 75
90 // protocol::HostStub interface. 76 // protocol::HostStub interface.
91 virtual void NotifyClientDimensions( 77 virtual void NotifyClientDimensions(
92 const protocol::ClientDimensions& dimensions) OVERRIDE; 78 const protocol::ClientDimensions& dimensions) OVERRIDE;
93 virtual void ControlVideo( 79 virtual void ControlVideo(
94 const protocol::VideoControl& video_control) OVERRIDE; 80 const protocol::VideoControl& video_control) OVERRIDE;
95 81
96 // protocol::ConnectionToClient::EventHandler interface. 82 // protocol::ConnectionToClient::EventHandler interface.
97 virtual void OnConnectionAuthenticated( 83 virtual void OnConnectionAuthenticated(
98 protocol::ConnectionToClient* connection) OVERRIDE; 84 protocol::ConnectionToClient* connection) OVERRIDE;
99 virtual void OnConnectionChannelsConnected( 85 virtual void OnConnectionChannelsConnected(
100 protocol::ConnectionToClient* connection) OVERRIDE; 86 protocol::ConnectionToClient* connection) OVERRIDE;
101 virtual void OnConnectionClosed(protocol::ConnectionToClient* connection, 87 virtual void OnConnectionClosed(protocol::ConnectionToClient* connection,
102 protocol::ErrorCode error) OVERRIDE; 88 protocol::ErrorCode error) OVERRIDE;
103 virtual void OnSequenceNumberUpdated( 89 virtual void OnSequenceNumberUpdated(
104 protocol::ConnectionToClient* connection, int64 sequence_number) OVERRIDE; 90 protocol::ConnectionToClient* connection, int64 sequence_number) OVERRIDE;
105 virtual void OnRouteChange( 91 virtual void OnRouteChange(
106 protocol::ConnectionToClient* connection, 92 protocol::ConnectionToClient* connection,
107 const std::string& channel_name, 93 const std::string& channel_name,
108 const protocol::TransportRoute& route) OVERRIDE; 94 const protocol::TransportRoute& route) OVERRIDE;
109 95
110 // Disconnects the session and destroys the transport. Event handler 96 // Disconnects the session and destroys the transport. Event handler
111 // is guaranteed not to be called after this method is called. The object 97 // is guaranteed not to be called after this method is called. Can
112 // should not be used after this method returns. 98 // be called multiple times. The object should not be used after
99 // this method returns.
113 void Disconnect(); 100 void Disconnect();
114 101
115 // Stop all recorders asynchronously. |done_task| is executed when the session
116 // is completely stopped.
117 void Stop(const base::Closure& done_task);
118
119 protocol::ConnectionToClient* connection() const { 102 protocol::ConnectionToClient* connection() const {
120 return connection_.get(); 103 return connection_.get();
121 } 104 }
122 105
123 DesktopEnvironment* desktop_environment() const {
124 return desktop_environment_.get();
125 }
126
127 const std::string& client_jid() { return client_jid_; } 106 const std::string& client_jid() { return client_jid_; }
128 107
129 bool is_authenticated() { return auth_input_filter_.enabled(); } 108 bool is_authenticated() { return auth_input_filter_.enabled(); }
130 109
131 // Indicate that local mouse activity has been detected. This causes remote 110 // Indicate that local mouse activity has been detected. This causes remote
132 // inputs to be ignored for a short time so that the local user will always 111 // inputs to be ignored for a short time so that the local user will always
133 // have the upper hand in 'pointer wars'. 112 // have the upper hand in 'pointer wars'.
134 void LocalMouseMoved(const SkIPoint& new_pos); 113 void LocalMouseMoved(const SkIPoint& new_pos);
135 114
136 // Disable handling of input events from this client. If the client has any 115 // Disable handling of input events from this client. If the client has any
137 // keys or mouse buttons pressed then these will be released. 116 // keys or mouse buttons pressed then these will be released.
138 void SetDisableInputs(bool disable_inputs); 117 void SetDisableInputs(bool disable_inputs);
139 118
140 private:
141 friend class base::DeleteHelper<ClientSession>;
142 friend struct ClientSessionTraits;
143 virtual ~ClientSession();
144
145 // Creates a proxy for sending clipboard events to the client. 119 // Creates a proxy for sending clipboard events to the client.
146 scoped_ptr<protocol::ClipboardStub> CreateClipboardProxy(); 120 scoped_ptr<protocol::ClipboardStub> CreateClipboardProxy();
147 121
148 void OnRecorderStopped(); 122 private:
149
150 // Creates an audio encoder for the specified configuration.
151 static scoped_ptr<AudioEncoder> CreateAudioEncoder(
152 const protocol::SessionConfig& config);
153
154 // Creates a video encoder for the specified configuration.
155 static VideoEncoder* CreateVideoEncoder(
156 const protocol::SessionConfig& config);
157
158 EventHandler* event_handler_; 123 EventHandler* event_handler_;
159 124
160 // The connection to the client. 125 // The connection to the client.
161 scoped_ptr<protocol::ConnectionToClient> connection_; 126 scoped_ptr<protocol::ConnectionToClient> connection_;
162 127
163 // The desktop environment used by this session.
164 scoped_ptr<DesktopEnvironment> desktop_environment_;
165
166 std::string client_jid_; 128 std::string client_jid_;
167 129
168 // The host clipboard and input stubs to which this object delegates. 130 // The host clipboard and input stubs to which this object delegates.
169 // These are the final elements in the clipboard & input pipelines, which 131 // These are the final elements in the clipboard & input pipelines, which
170 // appear in order below. 132 // appear in order below.
171 protocol::ClipboardStub* host_clipboard_stub_; 133 protocol::ClipboardStub* host_clipboard_stub_;
172 protocol::InputStub* host_input_stub_; 134 protocol::InputStub* host_input_stub_;
173 135
174 // Tracker used to release pressed keys and buttons when disconnecting. 136 // Tracker used to release pressed keys and buttons when disconnecting.
175 protocol::InputEventTracker input_tracker_; 137 protocol::InputEventTracker input_tracker_;
(...skipping 14 matching lines...) Expand all
190 152
191 // Filters used to disable input & clipboard when we're not authenticated. 153 // Filters used to disable input & clipboard when we're not authenticated.
192 protocol::InputFilter auth_input_filter_; 154 protocol::InputFilter auth_input_filter_;
193 protocol::ClipboardFilter auth_clipboard_filter_; 155 protocol::ClipboardFilter auth_clipboard_filter_;
194 156
195 // Factory for weak pointers to the client clipboard stub. 157 // Factory for weak pointers to the client clipboard stub.
196 // This must appear after |clipboard_echo_filter_|, so that it won't outlive 158 // This must appear after |clipboard_echo_filter_|, so that it won't outlive
197 // it. 159 // it.
198 base::WeakPtrFactory<protocol::ClipboardStub> client_clipboard_factory_; 160 base::WeakPtrFactory<protocol::ClipboardStub> client_clipboard_factory_;
199 161
162 // VideoFrameCapturer, used to determine current screen size for ensuring
163 // injected mouse events fall within the screen area.
164 // TODO(lambroslambrou): Move floor-control logic, and clamping to screen
165 // area, out of this class (crbug.com/96508).
166 VideoFrameCapturer* capturer_;
167
200 // The maximum duration of this session. 168 // The maximum duration of this session.
201 // There is no maximum if this value is <= 0. 169 // There is no maximum if this value is <= 0.
202 base::TimeDelta max_duration_; 170 base::TimeDelta max_duration_;
203 171
204 // A timer that triggers a disconnect when the maximum session duration 172 // A timer that triggers a disconnect when the maximum session duration
205 // is reached. 173 // is reached.
206 base::OneShotTimer<ClientSession> max_duration_timer_; 174 base::OneShotTimer<ClientSession> max_duration_timer_;
207 175
208 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_;
209 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_;
210 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
211
212 // Schedulers for audio and video capture.
213 scoped_refptr<AudioScheduler> audio_scheduler_;
214 scoped_refptr<ScreenRecorder> video_recorder_;
215
216 // Number of screen recorders and audio schedulers that are currently being
217 // used or shutdown. Used to delay shutdown if one or more
218 // recorders/schedulers are asynchronously shutting down.
219 int active_recorders_;
220
221 // The task to be executed when the session is completely stopped.
222 base::Closure done_task_;
223
224 DISALLOW_COPY_AND_ASSIGN(ClientSession); 176 DISALLOW_COPY_AND_ASSIGN(ClientSession);
225 }; 177 };
226 178
227 // Destroys |ClienSession| instances on the network thread.
228 struct ClientSessionTraits {
229 static void Destruct(const ClientSession* client);
230 };
231
232 } // namespace remoting 179 } // namespace remoting
233 180
234 #endif // REMOTING_HOST_CLIENT_SESSION_H_ 181 #endif // REMOTING_HOST_CLIENT_SESSION_H_
OLDNEW
« no previous file with comments | « remoting/host/chromoting_host_unittest.cc ('k') | remoting/host/client_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698