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

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: 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
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/remote_input_filter.h" 13 #include "remoting/host/remote_input_filter.h"
14 #include "remoting/protocol/clipboard_echo_filter.h" 14 #include "remoting/protocol/clipboard_echo_filter.h"
15 #include "remoting/protocol/clipboard_filter.h" 15 #include "remoting/protocol/clipboard_filter.h"
16 #include "remoting/protocol/clipboard_stub.h" 16 #include "remoting/protocol/clipboard_stub.h"
17 #include "remoting/protocol/connection_to_client.h" 17 #include "remoting/protocol/connection_to_client.h"
18 #include "remoting/protocol/host_stub.h" 18 #include "remoting/protocol/host_stub.h"
19 #include "remoting/protocol/input_event_tracker.h" 19 #include "remoting/protocol/input_event_tracker.h"
20 #include "remoting/protocol/input_filter.h" 20 #include "remoting/protocol/input_filter.h"
21 #include "remoting/protocol/input_stub.h" 21 #include "remoting/protocol/input_stub.h"
22 #include "remoting/protocol/mouse_input_filter.h" 22 #include "remoting/protocol/mouse_input_filter.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 Encoder;
35 class ScreenRecorder;
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::InputStub, 41 public protocol::InputStub,
33 public protocol::ConnectionToClient::EventHandler, 42 public protocol::ConnectionToClient::EventHandler,
34 public base::NonThreadSafe { 43 public base::NonThreadSafe {
35 public: 44 public:
36 // Callback interface for passing events to the ChromotingHost. 45 // Callback interface for passing events to the ChromotingHost.
(...skipping 23 matching lines...) Expand all
60 virtual void OnSessionRouteChange( 69 virtual void OnSessionRouteChange(
61 ClientSession* client, 70 ClientSession* client,
62 const std::string& channel_name, 71 const std::string& channel_name,
63 const protocol::TransportRoute& route) = 0; 72 const protocol::TransportRoute& route) = 0;
64 73
65 protected: 74 protected:
66 virtual ~EventHandler() {} 75 virtual ~EventHandler() {}
67 }; 76 };
68 77
69 ClientSession(EventHandler* event_handler, 78 ClientSession(EventHandler* event_handler,
79 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner,
80 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner,
81 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
Wez 2012/08/31 18:18:02 Pass the ChromotingHostContext in here, so that Cl
alexeypa (please no reviews) 2012/08/31 23:13:30 I didn't want to pass ChromotingHostContext becaus
Wez 2012/09/06 00:13:22 OK. :)
70 scoped_ptr<protocol::ConnectionToClient> connection, 82 scoped_ptr<protocol::ConnectionToClient> connection,
71 protocol::ClipboardStub* host_clipboard_stub, 83 scoped_ptr<DesktopEnvironment> desktop_environment,
72 protocol::InputStub* host_input_stub,
73 VideoFrameCapturer* capturer,
74 const base::TimeDelta& max_duration); 84 const base::TimeDelta& max_duration);
75 virtual ~ClientSession(); 85 virtual ~ClientSession();
76 86
77 // protocol::InputStub interface. 87 // protocol::InputStub interface.
78 virtual void InjectKeyEvent(const protocol::KeyEvent& event) OVERRIDE; 88 virtual void InjectKeyEvent(const protocol::KeyEvent& event) OVERRIDE;
79 virtual void InjectMouseEvent(const protocol::MouseEvent& event) OVERRIDE; 89 virtual void InjectMouseEvent(const protocol::MouseEvent& event) OVERRIDE;
80 90
81 // protocol::HostStub interface. 91 // protocol::HostStub interface.
82 virtual void NotifyClientDimensions( 92 virtual void NotifyClientDimensions(
83 const protocol::ClientDimensions& dimensions) OVERRIDE; 93 const protocol::ClientDimensions& dimensions) OVERRIDE;
(...skipping 13 matching lines...) Expand all
97 protocol::ConnectionToClient* connection, 107 protocol::ConnectionToClient* connection,
98 const std::string& channel_name, 108 const std::string& channel_name,
99 const protocol::TransportRoute& route) OVERRIDE; 109 const protocol::TransportRoute& route) OVERRIDE;
100 110
101 // Disconnects the session and destroys the transport. Event handler 111 // Disconnects the session and destroys the transport. Event handler
102 // is guaranteed not to be called after this method is called. Can 112 // is guaranteed not to be called after this method is called. Can
103 // be called multiple times. The object should not be used after 113 // be called multiple times. The object should not be used after
104 // this method returns. 114 // this method returns.
105 void Disconnect(); 115 void Disconnect();
106 116
117 void StopAndDelete();
simonmorris 2012/09/04 18:47:21 Add a comment explaining what this does?
alexeypa (please no reviews) 2012/09/05 22:53:29 Done.
118
107 protocol::ConnectionToClient* connection() const { 119 protocol::ConnectionToClient* connection() const {
108 return connection_.get(); 120 return connection_.get();
109 } 121 }
110 122
123 DesktopEnvironment* desktop_environment() const {
124 return desktop_environment_.get();
125 }
126
111 const std::string& client_jid() { return client_jid_; } 127 const std::string& client_jid() { return client_jid_; }
112 128
113 bool is_authenticated() { return is_authenticated_; } 129 bool is_authenticated() { return is_authenticated_; }
114 130
115 // Indicate that local mouse activity has been detected. This causes remote 131 // Indicate that local mouse activity has been detected. This causes remote
116 // inputs to be ignored for a short time so that the local user will always 132 // inputs to be ignored for a short time so that the local user will always
117 // have the upper hand in 'pointer wars'. 133 // have the upper hand in 'pointer wars'.
118 void LocalMouseMoved(const SkIPoint& new_pos); 134 void LocalMouseMoved(const SkIPoint& new_pos);
119 135
120 // Disable handling of input events from this client. If the client has any 136 // Disable handling of input events from this client. If the client has any
121 // keys or mouse buttons pressed then these will be released. 137 // keys or mouse buttons pressed then these will be released.
122 void SetDisableInputs(bool disable_inputs); 138 void SetDisableInputs(bool disable_inputs);
123 139
124 // Creates a proxy for sending clipboard events to the client. 140 // Creates a proxy for sending clipboard events to the client.
125 scoped_ptr<protocol::ClipboardStub> CreateClipboardProxy(); 141 scoped_ptr<protocol::ClipboardStub> CreateClipboardProxy();
126 142
127 private: 143 private:
144 // Creates encoder for the specified configuration.
145 static Encoder* CreateEncoder(const protocol::SessionConfig& config);
146
147 // Creates an audio encoder for the specified configuration.
148 static scoped_ptr<AudioEncoder> CreateAudioEncoder(
149 const protocol::SessionConfig& config);
150
151 void OnRecorderStopped();
152 void StopAudioScheduler();
153 void StopScreenRecorder();
154
128 EventHandler* event_handler_; 155 EventHandler* event_handler_;
129 156
130 // The connection to the client. 157 // The connection to the client.
131 scoped_ptr<protocol::ConnectionToClient> connection_; 158 scoped_ptr<protocol::ConnectionToClient> connection_;
132 159
160 // The desktop environment used by this session.
161 scoped_ptr<DesktopEnvironment> desktop_environment_;
162
133 std::string client_jid_; 163 std::string client_jid_;
134 bool is_authenticated_; 164 bool is_authenticated_;
135 165
136 // The host clipboard and input stubs to which this object delegates. 166 // The host clipboard and input stubs to which this object delegates.
137 // These are the final elements in the clipboard & input pipelines, which 167 // These are the final elements in the clipboard & input pipelines, which
138 // appear in order below. 168 // appear in order below.
139 protocol::ClipboardStub* host_clipboard_stub_; 169 protocol::ClipboardStub* host_clipboard_stub_;
140 protocol::InputStub* host_input_stub_; 170 protocol::InputStub* host_input_stub_;
141 171
142 // Tracker used to release pressed keys and buttons when disconnecting. 172 // Tracker used to release pressed keys and buttons when disconnecting.
(...skipping 29 matching lines...) Expand all
172 VideoFrameCapturer* capturer_; 202 VideoFrameCapturer* capturer_;
173 203
174 // The maximum duration of this session. 204 // The maximum duration of this session.
175 // There is no maximum if this value is <= 0. 205 // There is no maximum if this value is <= 0.
176 base::TimeDelta max_duration_; 206 base::TimeDelta max_duration_;
177 207
178 // A timer that triggers a disconnect when the maximum session duration 208 // A timer that triggers a disconnect when the maximum session duration
179 // is reached. 209 // is reached.
180 base::OneShotTimer<ClientSession> max_duration_timer_; 210 base::OneShotTimer<ClientSession> max_duration_timer_;
181 211
212 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_;
213 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_;
214 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
215
216 // Schedulers for audio and video capture.
217 scoped_refptr<AudioScheduler> audio_scheduler_;
218 scoped_refptr<ScreenRecorder> video_recorder_;
219
220 // Number of screen recorders and audio schedulers that are currently being
221 // used or shutdown. Used to delay shutdown if one or more
222 // recorders/schedulers are asynchronously shutting down.
223 int active_recorders_;
224
182 DISALLOW_COPY_AND_ASSIGN(ClientSession); 225 DISALLOW_COPY_AND_ASSIGN(ClientSession);
183 }; 226 };
184 227
185 } // namespace remoting 228 } // namespace remoting
186 229
187 #endif // REMOTING_HOST_CLIENT_SESSION_H_ 230 #endif // REMOTING_HOST_CLIENT_SESSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698