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

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

Issue 10915206: [Chromoting] Refactoring DesktopEnvironment and moving screen/audio recorders to ClientSession. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased to enable try jobs. 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 | « no previous file | remoting/host/chromoting_host.cc » ('j') | remoting/host/chromoting_host.cc » ('J')
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_CHROMOTING_HOST_H_ 5 #ifndef REMOTING_HOST_CHROMOTING_HOST_H_
6 #define REMOTING_HOST_CHROMOTING_HOST_H_ 6 #define REMOTING_HOST_CHROMOTING_HOST_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/observer_list.h" 12 #include "base/observer_list.h"
13 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
14 #include "net/base/backoff_entry.h" 14 #include "net/base/backoff_entry.h"
15 #include "remoting/codec/video_encoder.h"
16 #include "remoting/host/client_session.h" 15 #include "remoting/host/client_session.h"
17 #include "remoting/host/desktop_environment.h"
18 #include "remoting/host/host_key_pair.h" 16 #include "remoting/host/host_key_pair.h"
19 #include "remoting/host/host_status_observer.h" 17 #include "remoting/host/host_status_observer.h"
20 #include "remoting/host/mouse_move_observer.h" 18 #include "remoting/host/mouse_move_observer.h"
21 #include "remoting/host/ui_strings.h" 19 #include "remoting/host/ui_strings.h"
22 #include "remoting/protocol/authenticator.h" 20 #include "remoting/protocol/authenticator.h"
23 #include "remoting/protocol/session_manager.h" 21 #include "remoting/protocol/session_manager.h"
24 #include "remoting/protocol/connection_to_client.h" 22 #include "remoting/protocol/connection_to_client.h"
25 23
26 namespace remoting { 24 namespace remoting {
27 25
28 namespace protocol { 26 namespace protocol {
29 class InputStub; 27 class InputStub;
30 class SessionConfig; 28 class SessionConfig;
31 class CandidateSessionConfig; 29 class CandidateSessionConfig;
32 } // namespace protocol 30 } // namespace protocol
33 31
34 class AudioEncoder;
35 class AudioScheduler;
36 class ChromotingHostContext; 32 class ChromotingHostContext;
37 class DesktopEnvironment; 33 class DesktopEnvironmentFactory;
38 class Encoder;
39 class ScreenRecorder;
40 class VideoFrameCapturer;
41 34
42 // A class to implement the functionality of a host process. 35 // A class to implement the functionality of a host process.
43 // 36 //
44 // Here's the work flow of this class: 37 // Here's the work flow of this class:
45 // 1. We should load the saved GAIA ID token or if this is the first 38 // 1. We should load the saved GAIA ID token or if this is the first
46 // time the host process runs we should prompt user for the 39 // time the host process runs we should prompt user for the
47 // credential. We will use this token or credentials to authenicate 40 // credential. We will use this token or credentials to authenicate
48 // and register the host. 41 // and register the host.
49 // 42 //
50 // 2. We listen for incoming connection using libjingle. We will create 43 // 2. We listen for incoming connection using libjingle. We will create
(...skipping 11 matching lines...) Expand all
62 // all pending tasks to complete. After all of that completed we 55 // all pending tasks to complete. After all of that completed we
63 // return to the idle state. We then go to step (2) if there a new 56 // return to the idle state. We then go to step (2) if there a new
64 // incoming connection. 57 // incoming connection.
65 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, 58 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>,
66 public ClientSession::EventHandler, 59 public ClientSession::EventHandler,
67 public protocol::SessionManager::Listener, 60 public protocol::SessionManager::Listener,
68 public MouseMoveObserver { 61 public MouseMoveObserver {
69 public: 62 public:
70 // The caller must ensure that |context|, |signal_strategy| and 63 // The caller must ensure that |context|, |signal_strategy| and
71 // |environment| out-live the host. 64 // |environment| out-live the host.
72 ChromotingHost(ChromotingHostContext* context, 65 ChromotingHost(
73 SignalStrategy* signal_strategy, 66 ChromotingHostContext* context,
74 DesktopEnvironment* environment, 67 SignalStrategy* signal_strategy,
75 scoped_ptr<protocol::SessionManager> session_manager); 68 DesktopEnvironmentFactory* desktop_environment_factory,
69 scoped_ptr<protocol::SessionManager> session_manager);
76 70
77 // Asynchronously start the host process. 71 // Asynchronously start the host process.
78 // 72 //
79 // After this is invoked, the host process will connect to the talk 73 // After this is invoked, the host process will connect to the talk
80 // network and start listening for incoming connections. 74 // network and start listening for incoming connections.
81 // 75 //
82 // This method can only be called once during the lifetime of this object. 76 // This method can only be called once during the lifetime of this object.
83 void Start(const std::string& xmpp_login); 77 void Start(const std::string& xmpp_login);
84 78
85 // Asynchronously shutdown the host process. |shutdown_task| is 79 // Asynchronously shutdown the host process. |shutdown_task| is
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 141
148 const UiStrings& ui_strings() { return ui_strings_; } 142 const UiStrings& ui_strings() { return ui_strings_; }
149 143
150 // Set localized strings. Must be called before host is started. 144 // Set localized strings. Must be called before host is started.
151 void SetUiStrings(const UiStrings& ui_strings); 145 void SetUiStrings(const UiStrings& ui_strings);
152 146
153 private: 147 private:
154 friend class base::RefCountedThreadSafe<ChromotingHost>; 148 friend class base::RefCountedThreadSafe<ChromotingHost>;
155 friend class ChromotingHostTest; 149 friend class ChromotingHostTest;
156 150
157 typedef std::vector<ClientSession*> ClientList; 151 typedef std::vector<scoped_refptr<ClientSession> > ClientList;
158 152
159 enum State { 153 enum State {
160 kInitial, 154 kInitial,
161 kStarted, 155 kStarted,
162 kStopping, 156 kStopping,
163 kStopped, 157 kStopped,
164 }; 158 };
165 159
166 // Creates encoder for the specified configuration.
167 static VideoEncoder* CreateVideoEncoder(
168 const protocol::SessionConfig& config);
169
170 // Creates an audio encoder for the specified configuration.
171 static scoped_ptr<AudioEncoder> CreateAudioEncoder(
172 const protocol::SessionConfig& config);
173
174 virtual ~ChromotingHost(); 160 virtual ~ChromotingHost();
175 161
176 void StopScreenRecorder(); 162 // Called when a client session is stopped completely.
177 void StopAudioScheduler(); 163 void OnClientStopped();
178 void OnRecorderStopped();
179 164
180 // Called from Shutdown() or OnScreenRecorderStopped() to finish shutdown. 165 // Called from Shutdown() to finish shutdown.
181 void ShutdownFinish(); 166 void ShutdownFinish();
182 167
183 // Unless specified otherwise all members of this class must be 168 // Unless specified otherwise all members of this class must be
184 // used on the network thread only. 169 // used on the network thread only.
185 170
186 // Parameters specified when the host was created. 171 // Parameters specified when the host was created.
187 ChromotingHostContext* context_; 172 ChromotingHostContext* context_;
188 DesktopEnvironment* desktop_environment_; 173 DesktopEnvironmentFactory* desktop_environment_factory_;
189 scoped_ptr<protocol::SessionManager> session_manager_; 174 scoped_ptr<protocol::SessionManager> session_manager_;
190 175
191 // Connection objects. 176 // Connection objects.
192 SignalStrategy* signal_strategy_; 177 SignalStrategy* signal_strategy_;
193 178
194 // Must be used on the network thread only. 179 // Must be used on the network thread only.
195 ObserverList<HostStatusObserver> status_observers_; 180 ObserverList<HostStatusObserver> status_observers_;
196 181
197 // The connections to remote clients. 182 // The connections to remote clients.
198 ClientList clients_; 183 ClientList clients_;
199 184
200 // Schedulers for audio and video capture. 185 // The number of allocated |ClientSession| objects. |clients_count_| can be
201 // TODO(sergeyu): Do we need to have one set of schedulers per client? 186 // greater than |clients_.size()| because it also includes the objects that
202 scoped_refptr<ScreenRecorder> recorder_; 187 // are about to be deleted.
203 scoped_refptr<AudioScheduler> audio_scheduler_; 188 int clients_count_;
204
205 // Number of screen recorders and audio schedulers that are currently being
206 // stopped. Used to delay shutdown if one or more recorders/schedulers are
207 // asynchronously shutting down.
208 int stopping_recorders_;
209 189
210 // Tracks the internal state of the host. 190 // Tracks the internal state of the host.
211 State state_; 191 State state_;
212 192
213 // Configuration of the protocol. 193 // Configuration of the protocol.
214 scoped_ptr<protocol::CandidateSessionConfig> protocol_config_; 194 scoped_ptr<protocol::CandidateSessionConfig> protocol_config_;
215 195
216 // Login backoff state. 196 // Login backoff state.
217 net::BackoffEntry login_backoff_; 197 net::BackoffEntry login_backoff_;
218 198
(...skipping 11 matching lines...) Expand all
230 210
231 // The maximum duration of any session. 211 // The maximum duration of any session.
232 base::TimeDelta max_session_duration_; 212 base::TimeDelta max_session_duration_;
233 213
234 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); 214 DISALLOW_COPY_AND_ASSIGN(ChromotingHost);
235 }; 215 };
236 216
237 } // namespace remoting 217 } // namespace remoting
238 218
239 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ 219 #endif // REMOTING_HOST_CHROMOTING_HOST_H_
OLDNEW
« no previous file with comments | « no previous file | remoting/host/chromoting_host.cc » ('j') | remoting/host/chromoting_host.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698