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

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
« 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" 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. The caller can safely release its reference to
129 // when fully stopped. 132 // the client session once Stop() returns.
130 void Stop(const base::Closure& stopped_task); 133 void Stop();
131 134
132 protocol::ConnectionToClient* connection() const { 135 protocol::ConnectionToClient* connection() const {
133 return connection_.get(); 136 return connection_.get();
134 } 137 }
135 138
136 const std::string& client_jid() { return client_jid_; } 139 const std::string& client_jid() { return client_jid_; }
137 140
138 bool is_authenticated() { return auth_input_filter_.enabled(); } 141 bool is_authenticated() { return auth_input_filter_.enabled(); }
139 142
140 // Indicate that local mouse activity has been detected. This causes remote 143 // 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 144 // inputs to be ignored for a short time so that the local user will always
142 // have the upper hand in 'pointer wars'. 145 // have the upper hand in 'pointer wars'.
143 void LocalMouseMoved(const SkIPoint& new_pos); 146 void LocalMouseMoved(const SkIPoint& new_pos);
144 147
145 // Disable handling of input events from this client. If the client has any 148 // Disable handling of input events from this client. If the client has any
146 // keys or mouse buttons pressed then these will be released. 149 // keys or mouse buttons pressed then these will be released.
147 void SetDisableInputs(bool disable_inputs); 150 void SetDisableInputs(bool disable_inputs);
148 151
149 private: 152 private:
150 friend class base::DeleteHelper<ClientSession>; 153 friend class base::DeleteHelper<ClientSession>;
151 friend struct ClientSessionTraits; 154 friend struct ClientSessionTraits;
152 virtual ~ClientSession(); 155 virtual ~ClientSession();
153 156
154 // Creates a proxy for sending clipboard events to the client. 157 // Creates a proxy for sending clipboard events to the client.
155 scoped_ptr<protocol::ClipboardStub> CreateClipboardProxy(); 158 scoped_ptr<protocol::ClipboardStub> CreateClipboardProxy();
156 159
157 void OnRecorderStopped();
158
159 // Creates an audio encoder for the specified configuration. 160 // Creates an audio encoder for the specified configuration.
160 static scoped_ptr<AudioEncoder> CreateAudioEncoder( 161 static scoped_ptr<AudioEncoder> CreateAudioEncoder(
161 const protocol::SessionConfig& config); 162 const protocol::SessionConfig& config);
162 163
163 // Creates a video encoder for the specified configuration. 164 // Creates a video encoder for the specified configuration.
164 static scoped_ptr<VideoEncoder> CreateVideoEncoder( 165 static scoped_ptr<VideoEncoder> CreateVideoEncoder(
165 const protocol::SessionConfig& config); 166 const protocol::SessionConfig& config);
166 167
167 EventHandler* event_handler_; 168 EventHandler* event_handler_;
168 169
169 // The connection to the client. 170 // The connection to the client.
170 scoped_ptr<protocol::ConnectionToClient> connection_; 171 scoped_ptr<protocol::ConnectionToClient> connection_;
171 172
172 // Used to disable callbacks to |connection_| once it is disconnected. 173 // Used to disable callbacks to |connection_| once it is disconnected.
173 base::WeakPtrFactory<protocol::ConnectionToClient> connection_factory_; 174 base::WeakPtrFactory<protocol::ConnectionToClient> connection_factory_;
174 175
176 std::string client_jid_;
177
175 // The desktop environment used by this session. 178 // The desktop environment used by this session.
176 scoped_ptr<DesktopEnvironment> desktop_environment_; 179 scoped_ptr<DesktopEnvironment> desktop_environment_;
177 180
178 std::string client_jid_;
179
180 // Filter used as the final element in the input pipeline. 181 // Filter used as the final element in the input pipeline.
181 protocol::InputFilter host_input_filter_; 182 protocol::InputFilter host_input_filter_;
182 183
183 // Tracker used to release pressed keys and buttons when disconnecting. 184 // Tracker used to release pressed keys and buttons when disconnecting.
184 protocol::InputEventTracker input_tracker_; 185 protocol::InputEventTracker input_tracker_;
185 186
186 // Filter used to disable remote inputs during local input activity. 187 // Filter used to disable remote inputs during local input activity.
187 RemoteInputFilter remote_input_filter_; 188 RemoteInputFilter remote_input_filter_;
188 189
189 // Filter used to clamp mouse events to the current display dimensions. 190 // Filter used to clamp mouse events to the current display dimensions.
(...skipping 19 matching lines...) Expand all
209 210
210 // The maximum duration of this session. 211 // The maximum duration of this session.
211 // There is no maximum if this value is <= 0. 212 // There is no maximum if this value is <= 0.
212 base::TimeDelta max_duration_; 213 base::TimeDelta max_duration_;
213 214
214 // A timer that triggers a disconnect when the maximum session duration 215 // A timer that triggers a disconnect when the maximum session duration
215 // is reached. 216 // is reached.
216 base::OneShotTimer<ClientSession> max_duration_timer_; 217 base::OneShotTimer<ClientSession> max_duration_timer_;
217 218
218 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner_; 219 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner_;
220 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner_;
219 scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner_; 221 scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner_;
220 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner_; 222 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner_;
221 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; 223 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
224 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
222 225
223 // Schedulers for audio and video capture. 226 // Schedulers for audio and video capture.
224 scoped_refptr<AudioScheduler> audio_scheduler_; 227 scoped_refptr<AudioScheduler> audio_scheduler_;
225 scoped_refptr<VideoScheduler> video_scheduler_; 228 scoped_refptr<VideoScheduler> video_scheduler_;
226 229
227 // Number of screen recorders and audio schedulers that are currently being 230 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 231
235 DISALLOW_COPY_AND_ASSIGN(ClientSession); 232 DISALLOW_COPY_AND_ASSIGN(ClientSession);
236 }; 233 };
237 234
238 // Destroys |ClienSession| instances on the network thread. 235 // Destroys |ClienSession| instances on the network thread.
239 struct ClientSessionTraits { 236 struct ClientSessionTraits {
240 static void Destruct(const ClientSession* client); 237 static void Destruct(const ClientSession* client);
241 }; 238 };
242 239
243 } // namespace remoting 240 } // namespace remoting
244 241
245 #endif // REMOTING_HOST_CLIENT_SESSION_H_ 242 #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