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

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

Issue 11778049: Making DesktopEnvironment a factory class used by ClientSession to create audio/video capturers and… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h"
11 #include "base/sequenced_task_runner_helpers.h" 12 #include "base/sequenced_task_runner_helpers.h"
12 #include "base/time.h" 13 #include "base/time.h"
13 #include "base/timer.h" 14 #include "base/timer.h"
14 #include "base/threading/non_thread_safe.h" 15 #include "base/threading/non_thread_safe.h"
15 #include "remoting/host/mouse_clamping_filter.h" 16 #include "remoting/host/mouse_clamping_filter.h"
16 #include "remoting/host/remote_input_filter.h" 17 #include "remoting/host/remote_input_filter.h"
17 #include "remoting/protocol/clipboard_echo_filter.h" 18 #include "remoting/protocol/clipboard_echo_filter.h"
18 #include "remoting/protocol/clipboard_filter.h" 19 #include "remoting/protocol/clipboard_filter.h"
19 #include "remoting/protocol/clipboard_stub.h" 20 #include "remoting/protocol/clipboard_stub.h"
20 #include "remoting/protocol/connection_to_client.h" 21 #include "remoting/protocol/connection_to_client.h"
21 #include "remoting/protocol/host_stub.h" 22 #include "remoting/protocol/host_stub.h"
22 #include "remoting/protocol/input_event_tracker.h" 23 #include "remoting/protocol/input_event_tracker.h"
23 #include "remoting/protocol/input_filter.h" 24 #include "remoting/protocol/input_filter.h"
24 #include "remoting/protocol/input_stub.h" 25 #include "remoting/protocol/input_stub.h"
25 #include "third_party/skia/include/core/SkPoint.h" 26 #include "third_party/skia/include/core/SkPoint.h"
26 #include "third_party/skia/include/core/SkSize.h" 27 #include "third_party/skia/include/core/SkSize.h"
27 28
28 namespace base { 29 namespace base {
29 class SingleThreadTaskRunner; 30 class SingleThreadTaskRunner;
30 } // namespace base 31 } // namespace base
31 32
32 namespace remoting { 33 namespace remoting {
33 34
34 class AudioEncoder; 35 class AudioEncoder;
35 class AudioScheduler; 36 class AudioScheduler;
36 struct ClientSessionTraits; 37 struct ClientSessionTraits;
37 class DesktopEnvironment; 38 class DesktopEnvironment;
38 class DesktopEnvironmentFactory; 39 class DesktopEnvironmentFactory;
40 class EventExecutor;
39 class VideoEncoder; 41 class VideoEncoder;
40 class VideoFrameCapturer;
41 class VideoScheduler; 42 class VideoScheduler;
42 43
43 // A ClientSession keeps a reference to a connection to a client, and maintains 44 // A ClientSession keeps a reference to a connection to a client, and maintains
44 // per-client state. 45 // per-client state.
45 class ClientSession 46 class ClientSession
46 : public base::RefCountedThreadSafe<ClientSession, ClientSessionTraits>, 47 : public base::RefCountedThreadSafe<ClientSession, ClientSessionTraits>,
47 public protocol::HostStub, 48 public protocol::HostStub,
48 public protocol::ConnectionToClient::EventHandler, 49 public protocol::ConnectionToClient::EventHandler,
49 public base::NonThreadSafe { 50 public base::NonThreadSafe {
50 public: 51 public:
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 85
85 protected: 86 protected:
86 virtual ~EventHandler() {} 87 virtual ~EventHandler() {}
87 }; 88 };
88 89
89 // |event_handler| must outlive |this|. |desktop_environment_factory| is only 90 // |event_handler| must outlive |this|. |desktop_environment_factory| is only
90 // used by the constructor to create an instance of DesktopEnvironment. 91 // used by the constructor to create an instance of DesktopEnvironment.
91 ClientSession( 92 ClientSession(
92 EventHandler* event_handler, 93 EventHandler* event_handler,
93 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, 94 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner,
95 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
94 scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner, 96 scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner,
95 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner, 97 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner,
96 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, 98 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
99 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
97 scoped_ptr<protocol::ConnectionToClient> connection, 100 scoped_ptr<protocol::ConnectionToClient> connection,
98 DesktopEnvironmentFactory* desktop_environment_factory, 101 DesktopEnvironmentFactory* desktop_environment_factory,
99 const base::TimeDelta& max_duration); 102 const base::TimeDelta& max_duration);
100 103
101 // protocol::HostStub interface. 104 // protocol::HostStub interface.
102 virtual void NotifyClientDimensions( 105 virtual void NotifyClientDimensions(
103 const protocol::ClientDimensions& dimensions) OVERRIDE; 106 const protocol::ClientDimensions& dimensions) OVERRIDE;
104 virtual void ControlVideo( 107 virtual void ControlVideo(
105 const protocol::VideoControl& video_control) OVERRIDE; 108 const protocol::VideoControl& video_control) OVERRIDE;
106 virtual void ControlAudio( 109 virtual void ControlAudio(
(...skipping 11 matching lines...) Expand all
118 virtual void OnRouteChange( 121 virtual void OnRouteChange(
119 protocol::ConnectionToClient* connection, 122 protocol::ConnectionToClient* connection,
120 const std::string& channel_name, 123 const std::string& channel_name,
121 const protocol::TransportRoute& route) OVERRIDE; 124 const protocol::TransportRoute& route) OVERRIDE;
122 125
123 // Disconnects the session, tears down transport resources and stops scheduler 126 // Disconnects the session, tears down transport resources and stops scheduler
124 // components. |event_handler_| is guaranteed not to be called after this 127 // components. |event_handler_| is guaranteed not to be called after this
125 // method returns. 128 // method returns.
126 void Disconnect(); 129 void Disconnect();
127 130
128 // Stops the ClientSession, and calls |stopped_task| on |network_task_runner_| 131 // Stops the ClientSession.
Wez 2013/01/11 02:23:41 Clarify that the semantics; once ClientSession is
alexeypa (please no reviews) 2013/01/11 19:59:46 Done.
129 // when fully stopped. 132 void Stop();
130 void Stop(const base::Closure& stopped_task);
131 133
132 protocol::ConnectionToClient* connection() const { 134 protocol::ConnectionToClient* connection() const {
133 return connection_.get(); 135 return connection_.get();
134 } 136 }
135 137
136 const std::string& client_jid() { return client_jid_; } 138 const std::string& client_jid() { return client_jid_; }
137 139
138 bool is_authenticated() { return auth_input_filter_.enabled(); } 140 bool is_authenticated() { return auth_input_filter_.enabled(); }
139 141
140 // Indicate that local mouse activity has been detected. This causes remote 142 // Indicate that local mouse activity has been detected. This causes remote
141 // inputs to be ignored for a short time so that the local user will always 143 // inputs to be ignored for a short time so that the local user will always
142 // have the upper hand in 'pointer wars'. 144 // have the upper hand in 'pointer wars'.
143 void LocalMouseMoved(const SkIPoint& new_pos); 145 void LocalMouseMoved(const SkIPoint& new_pos);
144 146
145 // Disable handling of input events from this client. If the client has any 147 // Disable handling of input events from this client. If the client has any
146 // keys or mouse buttons pressed then these will be released. 148 // keys or mouse buttons pressed then these will be released.
147 void SetDisableInputs(bool disable_inputs); 149 void SetDisableInputs(bool disable_inputs);
148 150
149 private: 151 private:
150 friend class base::DeleteHelper<ClientSession>; 152 friend class base::DeleteHelper<ClientSession>;
151 friend struct ClientSessionTraits; 153 friend struct ClientSessionTraits;
152 virtual ~ClientSession(); 154 virtual ~ClientSession();
153 155
154 // Creates a proxy for sending clipboard events to the client. 156 // Creates a proxy for sending clipboard events to the client.
155 scoped_ptr<protocol::ClipboardStub> CreateClipboardProxy(); 157 scoped_ptr<protocol::ClipboardStub> CreateClipboardProxy();
156 158
157 void OnRecorderStopped();
158
159 // Creates an audio encoder for the specified configuration. 159 // Creates an audio encoder for the specified configuration.
160 static scoped_ptr<AudioEncoder> CreateAudioEncoder( 160 static scoped_ptr<AudioEncoder> CreateAudioEncoder(
161 const protocol::SessionConfig& config); 161 const protocol::SessionConfig& config);
162 162
163 // Creates a video encoder for the specified configuration. 163 // Creates a video encoder for the specified configuration.
164 static scoped_ptr<VideoEncoder> CreateVideoEncoder( 164 static scoped_ptr<VideoEncoder> CreateVideoEncoder(
165 const protocol::SessionConfig& config); 165 const protocol::SessionConfig& config);
166 166
167 EventHandler* event_handler_; 167 EventHandler* event_handler_;
168 168
169 // The connection to the client. 169 // The connection to the client.
170 scoped_ptr<protocol::ConnectionToClient> connection_; 170 scoped_ptr<protocol::ConnectionToClient> connection_;
171 171
172 // Used to disable callbacks to |connection_| once it is disconnected. 172 // Used to disable callbacks to |connection_| once it is disconnected.
173 base::WeakPtrFactory<protocol::ConnectionToClient> connection_factory_; 173 base::WeakPtrFactory<protocol::ConnectionToClient> connection_factory_;
174 174
175 std::string client_jid_;
176
175 // The desktop environment used by this session. 177 // The desktop environment used by this session.
176 scoped_ptr<DesktopEnvironment> desktop_environment_; 178 scoped_ptr<DesktopEnvironment> desktop_environment_;
177 179
178 std::string client_jid_;
179
180 // Filter used as the final element in the input pipeline. 180 // Filter used as the final element in the input pipeline.
181 protocol::InputFilter host_input_filter_; 181 protocol::InputFilter host_input_filter_;
182 182
183 // Tracker used to release pressed keys and buttons when disconnecting. 183 // Tracker used to release pressed keys and buttons when disconnecting.
184 protocol::InputEventTracker input_tracker_; 184 protocol::InputEventTracker input_tracker_;
185 185
186 // Filter used to disable remote inputs during local input activity. 186 // Filter used to disable remote inputs during local input activity.
187 RemoteInputFilter remote_input_filter_; 187 RemoteInputFilter remote_input_filter_;
188 188
189 // Filter used to clamp mouse events to the current display dimensions. 189 // Filter used to clamp mouse events to the current display dimensions.
(...skipping 19 matching lines...) Expand all
209 209
210 // The maximum duration of this session. 210 // The maximum duration of this session.
211 // There is no maximum if this value is <= 0. 211 // There is no maximum if this value is <= 0.
212 base::TimeDelta max_duration_; 212 base::TimeDelta max_duration_;
213 213
214 // A timer that triggers a disconnect when the maximum session duration 214 // A timer that triggers a disconnect when the maximum session duration
215 // is reached. 215 // is reached.
216 base::OneShotTimer<ClientSession> max_duration_timer_; 216 base::OneShotTimer<ClientSession> max_duration_timer_;
217 217
218 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner_; 218 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner_;
219 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner_;
219 scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner_; 220 scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner_;
220 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner_; 221 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner_;
221 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; 222 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
223 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
222 224
223 // Schedulers for audio and video capture. 225 // Schedulers for audio and video capture.
224 scoped_refptr<AudioScheduler> audio_scheduler_; 226 scoped_refptr<AudioScheduler> audio_scheduler_;
225 scoped_refptr<VideoScheduler> video_scheduler_; 227 scoped_refptr<VideoScheduler> video_scheduler_;
226 228
227 // Number of screen recorders and audio schedulers that are currently being 229 scoped_ptr<EventExecutor> event_executor_;
228 // used or shutdown. Used to delay shutdown if one or more
229 // recorders/schedulers are asynchronously shutting down.
230 int active_recorders_;
231
232 // Task to execute once the session is completely stopped.
233 base::Closure stopped_task_;
234 230
235 DISALLOW_COPY_AND_ASSIGN(ClientSession); 231 DISALLOW_COPY_AND_ASSIGN(ClientSession);
236 }; 232 };
237 233
238 // Destroys |ClienSession| instances on the network thread. 234 // Destroys |ClienSession| instances on the network thread.
239 struct ClientSessionTraits { 235 struct ClientSessionTraits {
240 static void Destruct(const ClientSession* client); 236 static void Destruct(const ClientSession* client);
241 }; 237 };
242 238
243 } // namespace remoting 239 } // namespace remoting
244 240
245 #endif // REMOTING_HOST_CLIENT_SESSION_H_ 241 #endif // REMOTING_HOST_CLIENT_SESSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698