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

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

Issue 10916161: Revert 155219 - [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/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
29 namespace remoting { 25 namespace remoting {
30 26
31 class AudioEncoder;
32 class AudioScheduler;
33 class DesktopEnvironment;
34 class ScreenRecorder;
35 class VideoEncoder;
36 class VideoFrameCapturer; 27 class VideoFrameCapturer;
37 28
38 // 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
39 // per-client state. 30 // per-client state.
40 class ClientSession : public protocol::HostStub, 31 class ClientSession : public protocol::HostStub,
41 public protocol::ConnectionToClient::EventHandler, 32 public protocol::ConnectionToClient::EventHandler,
42 public base::NonThreadSafe { 33 public base::NonThreadSafe {
43 public: 34 public:
44 // Callback interface for passing events to the ChromotingHost. 35 // Callback interface for passing events to the ChromotingHost.
45 class EventHandler { 36 class EventHandler {
(...skipping 22 matching lines...) Expand all
68 virtual void OnSessionRouteChange( 59 virtual void OnSessionRouteChange(
69 ClientSession* client, 60 ClientSession* client,
70 const std::string& channel_name, 61 const std::string& channel_name,
71 const protocol::TransportRoute& route) = 0; 62 const protocol::TransportRoute& route) = 0;
72 63
73 protected: 64 protected:
74 virtual ~EventHandler() {} 65 virtual ~EventHandler() {}
75 }; 66 };
76 67
77 ClientSession(EventHandler* event_handler, 68 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,
81 scoped_ptr<protocol::ConnectionToClient> connection, 69 scoped_ptr<protocol::ConnectionToClient> connection,
82 scoped_ptr<DesktopEnvironment> desktop_environment, 70 protocol::ClipboardStub* host_clipboard_stub,
71 protocol::InputStub* host_input_stub,
72 VideoFrameCapturer* capturer,
83 const base::TimeDelta& max_duration); 73 const base::TimeDelta& max_duration);
74 virtual ~ClientSession();
84 75
85 // protocol::HostStub interface. 76 // protocol::HostStub interface.
86 virtual void NotifyClientDimensions( 77 virtual void NotifyClientDimensions(
87 const protocol::ClientDimensions& dimensions) OVERRIDE; 78 const protocol::ClientDimensions& dimensions) OVERRIDE;
88 virtual void ControlVideo( 79 virtual void ControlVideo(
89 const protocol::VideoControl& video_control) OVERRIDE; 80 const protocol::VideoControl& video_control) OVERRIDE;
90 81
91 // protocol::ConnectionToClient::EventHandler interface. 82 // protocol::ConnectionToClient::EventHandler interface.
92 virtual void OnConnectionAuthenticated( 83 virtual void OnConnectionAuthenticated(
93 protocol::ConnectionToClient* connection) OVERRIDE; 84 protocol::ConnectionToClient* connection) OVERRIDE;
94 virtual void OnConnectionChannelsConnected( 85 virtual void OnConnectionChannelsConnected(
95 protocol::ConnectionToClient* connection) OVERRIDE; 86 protocol::ConnectionToClient* connection) OVERRIDE;
96 virtual void OnConnectionClosed(protocol::ConnectionToClient* connection, 87 virtual void OnConnectionClosed(protocol::ConnectionToClient* connection,
97 protocol::ErrorCode error) OVERRIDE; 88 protocol::ErrorCode error) OVERRIDE;
98 virtual void OnSequenceNumberUpdated( 89 virtual void OnSequenceNumberUpdated(
99 protocol::ConnectionToClient* connection, int64 sequence_number) OVERRIDE; 90 protocol::ConnectionToClient* connection, int64 sequence_number) OVERRIDE;
100 virtual void OnRouteChange( 91 virtual void OnRouteChange(
101 protocol::ConnectionToClient* connection, 92 protocol::ConnectionToClient* connection,
102 const std::string& channel_name, 93 const std::string& channel_name,
103 const protocol::TransportRoute& route) OVERRIDE; 94 const protocol::TransportRoute& route) OVERRIDE;
104 95
105 // Disconnects the session and destroys the transport. Event handler 96 // Disconnects the session and destroys the transport. Event handler
106 // is guaranteed not to be called after this method is called. Can 97 // is guaranteed not to be called after this method is called. Can
107 // be called multiple times. The object should not be used after 98 // be called multiple times. The object should not be used after
108 // this method returns. 99 // this method returns.
109 void Disconnect(); 100 void Disconnect();
110 101
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
115 protocol::ConnectionToClient* connection() const { 102 protocol::ConnectionToClient* connection() const {
116 return connection_.get(); 103 return connection_.get();
117 } 104 }
118 105
119 DesktopEnvironment* desktop_environment() const {
120 return desktop_environment_.get();
121 }
122
123 const std::string& client_jid() { return client_jid_; } 106 const std::string& client_jid() { return client_jid_; }
124 107
125 bool is_authenticated() { return auth_input_filter_.enabled(); } 108 bool is_authenticated() { return auth_input_filter_.enabled(); }
126 109
127 // Indicate that local mouse activity has been detected. This causes remote 110 // Indicate that local mouse activity has been detected. This causes remote
128 // 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
129 // have the upper hand in 'pointer wars'. 112 // have the upper hand in 'pointer wars'.
130 void LocalMouseMoved(const SkIPoint& new_pos); 113 void LocalMouseMoved(const SkIPoint& new_pos);
131 114
132 // 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
133 // keys or mouse buttons pressed then these will be released. 116 // keys or mouse buttons pressed then these will be released.
134 void SetDisableInputs(bool disable_inputs); 117 void SetDisableInputs(bool disable_inputs);
135 118
136 private:
137 virtual ~ClientSession();
138
139 // Creates a proxy for sending clipboard events to the client. 119 // Creates a proxy for sending clipboard events to the client.
140 scoped_ptr<protocol::ClipboardStub> CreateClipboardProxy(); 120 scoped_ptr<protocol::ClipboardStub> CreateClipboardProxy();
141 121
142 void OnRecorderStopped(); 122 private:
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
152 EventHandler* event_handler_; 123 EventHandler* event_handler_;
153 124
154 // The connection to the client. 125 // The connection to the client.
155 scoped_ptr<protocol::ConnectionToClient> connection_; 126 scoped_ptr<protocol::ConnectionToClient> connection_;
156 127
157 // The desktop environment used by this session.
158 scoped_ptr<DesktopEnvironment> desktop_environment_;
159
160 std::string client_jid_; 128 std::string client_jid_;
161 129
162 // The host clipboard and input stubs to which this object delegates. 130 // The host clipboard and input stubs to which this object delegates.
163 // These are the final elements in the clipboard & input pipelines, which 131 // These are the final elements in the clipboard & input pipelines, which
164 // appear in order below. 132 // appear in order below.
165 protocol::ClipboardStub* host_clipboard_stub_; 133 protocol::ClipboardStub* host_clipboard_stub_;
166 protocol::InputStub* host_input_stub_; 134 protocol::InputStub* host_input_stub_;
167 135
168 // Tracker used to release pressed keys and buttons when disconnecting. 136 // Tracker used to release pressed keys and buttons when disconnecting.
169 protocol::InputEventTracker input_tracker_; 137 protocol::InputEventTracker input_tracker_;
(...skipping 14 matching lines...) Expand all
184 152
185 // Filters used to disable input & clipboard when we're not authenticated. 153 // Filters used to disable input & clipboard when we're not authenticated.
186 protocol::InputFilter auth_input_filter_; 154 protocol::InputFilter auth_input_filter_;
187 protocol::ClipboardFilter auth_clipboard_filter_; 155 protocol::ClipboardFilter auth_clipboard_filter_;
188 156
189 // Factory for weak pointers to the client clipboard stub. 157 // Factory for weak pointers to the client clipboard stub.
190 // 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
191 // it. 159 // it.
192 base::WeakPtrFactory<protocol::ClipboardStub> client_clipboard_factory_; 160 base::WeakPtrFactory<protocol::ClipboardStub> client_clipboard_factory_;
193 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
194 // The maximum duration of this session. 168 // The maximum duration of this session.
195 // There is no maximum if this value is <= 0. 169 // There is no maximum if this value is <= 0.
196 base::TimeDelta max_duration_; 170 base::TimeDelta max_duration_;
197 171
198 // A timer that triggers a disconnect when the maximum session duration 172 // A timer that triggers a disconnect when the maximum session duration
199 // is reached. 173 // is reached.
200 base::OneShotTimer<ClientSession> max_duration_timer_; 174 base::OneShotTimer<ClientSession> max_duration_timer_;
201 175
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
215 DISALLOW_COPY_AND_ASSIGN(ClientSession); 176 DISALLOW_COPY_AND_ASSIGN(ClientSession);
216 }; 177 };
217 178
218 } // namespace remoting 179 } // namespace remoting
219 180
220 #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