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

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

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