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

Side by Side Diff: remoting/host/simple_host_process.cc

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 // This is an application of a minimal host process in a Chromoting 5 // This is an application of a minimal host process in a Chromoting
6 // system. It serves the purpose of gluing different pieces together 6 // system. It serves the purpose of gluing different pieces together
7 // to make a functional host process for testing. 7 // to make a functional host process for testing.
8 // 8 //
9 // It peforms the following functionality: 9 // It peforms the following functionality:
10 // 1. Connect to the GTalk network and register the machine as a host. 10 // 1. Connect to the GTalk network and register the machine as a host.
(...skipping 21 matching lines...) Expand all
32 #include "crypto/nss_util.h" 32 #include "crypto/nss_util.h"
33 #include "net/base/network_change_notifier.h" 33 #include "net/base/network_change_notifier.h"
34 #include "net/socket/ssl_server_socket.h" 34 #include "net/socket/ssl_server_socket.h"
35 #include "remoting/base/constants.h" 35 #include "remoting/base/constants.h"
36 #include "remoting/host/audio_capturer.h" 36 #include "remoting/host/audio_capturer.h"
37 #include "remoting/host/chromoting_host_context.h" 37 #include "remoting/host/chromoting_host_context.h"
38 #include "remoting/host/chromoting_host.h" 38 #include "remoting/host/chromoting_host.h"
39 #include "remoting/host/constants.h" 39 #include "remoting/host/constants.h"
40 #include "remoting/host/desktop_environment.h" 40 #include "remoting/host/desktop_environment.h"
41 #include "remoting/host/event_executor.h" 41 #include "remoting/host/event_executor.h"
42 #include "remoting/host/desktop_environment.h"
43 #include "remoting/host/desktop_environment_factory.h"
42 #include "remoting/host/heartbeat_sender.h" 44 #include "remoting/host/heartbeat_sender.h"
43 #include "remoting/host/host_key_pair.h" 45 #include "remoting/host/host_key_pair.h"
44 #include "remoting/host/host_secret.h" 46 #include "remoting/host/host_secret.h"
45 #include "remoting/host/it2me_host_user_interface.h" 47 #include "remoting/host/it2me_host_user_interface.h"
46 #include "remoting/host/json_host_config.h" 48 #include "remoting/host/json_host_config.h"
47 #include "remoting/host/log_to_server.h" 49 #include "remoting/host/log_to_server.h"
48 #include "remoting/host/network_settings.h" 50 #include "remoting/host/network_settings.h"
49 #include "remoting/host/register_support_host_request.h" 51 #include "remoting/host/register_support_host_request.h"
50 #include "remoting/host/session_manager_factory.h" 52 #include "remoting/host/session_manager_factory.h"
51 #include "remoting/host/signaling_connector.h" 53 #include "remoting/host/signaling_connector.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 const char kMaxPortSwitchName[] = "max-port"; 87 const char kMaxPortSwitchName[] = "max-port";
86 88
87 const char kVideoSwitchValueVerbatim[] = "verbatim"; 89 const char kVideoSwitchValueVerbatim[] = "verbatim";
88 const char kVideoSwitchValueZip[] = "zip"; 90 const char kVideoSwitchValueZip[] = "zip";
89 const char kVideoSwitchValueVp8[] = "vp8"; 91 const char kVideoSwitchValueVp8[] = "vp8";
90 92
91 } // namespace 93 } // namespace
92 94
93 namespace remoting { 95 namespace remoting {
94 96
97 class FakeDesktopEnvironmentFactory : public DesktopEnvironmentFactory {
98 public:
99 FakeDesktopEnvironmentFactory();
100 virtual ~FakeDesktopEnvironmentFactory();
101
102 virtual scoped_ptr<DesktopEnvironment> Create(
103 ChromotingHostContext* context) OVERRIDE;
104
105 DISALLOW_COPY_AND_ASSIGN(FakeDesktopEnvironmentFactory);
106 };
107
108 FakeDesktopEnvironmentFactory::FakeDesktopEnvironmentFactory() {
109 }
110
111 FakeDesktopEnvironmentFactory::~FakeDesktopEnvironmentFactory() {
112 }
113
114 scoped_ptr<DesktopEnvironment> FakeDesktopEnvironmentFactory::Create(
115 ChromotingHostContext* context) {
116 scoped_ptr<VideoFrameCapturer> capturer(new VideoFrameCapturerFake());
117 scoped_ptr<EventExecutor> event_executor = EventExecutor::Create(
118 context->desktop_task_runner(),
119 context->ui_task_runner());
120 scoped_ptr<AudioCapturer> audio_capturer(NULL);
121 return scoped_ptr<DesktopEnvironment>(new DesktopEnvironment(
122 audio_capturer.Pass(),
123 event_executor.Pass(),
124 capturer.Pass()));
125 }
126
95 class SimpleHost : public HeartbeatSender::Listener { 127 class SimpleHost : public HeartbeatSender::Listener {
96 public: 128 public:
97 SimpleHost() 129 SimpleHost()
98 : message_loop_(MessageLoop::TYPE_UI), 130 : message_loop_(MessageLoop::TYPE_UI),
99 context_(message_loop_.message_loop_proxy()), 131 context_(message_loop_.message_loop_proxy()),
100 fake_(false), 132 fake_(false),
101 is_it2me_(false), 133 is_it2me_(false),
102 shutting_down_(false), 134 shutting_down_(false),
103 exit_code_(kSuccessExitCode) { 135 exit_code_(kSuccessExitCode) {
104 context_.Start(); 136 context_.Start();
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 250
219 void StartHost() { 251 void StartHost() {
220 signal_strategy_.reset(new XmppSignalStrategy( 252 signal_strategy_.reset(new XmppSignalStrategy(
221 context_.url_request_context_getter(), 253 context_.url_request_context_getter(),
222 xmpp_login_, xmpp_auth_token_, xmpp_auth_service_)); 254 xmpp_login_, xmpp_auth_token_, xmpp_auth_service_));
223 signaling_connector_.reset(new SignalingConnector( 255 signaling_connector_.reset(new SignalingConnector(
224 signal_strategy_.get(), 256 signal_strategy_.get(),
225 base::Bind(&SimpleHost::OnAuthFailed, base::Unretained(this)))); 257 base::Bind(&SimpleHost::OnAuthFailed, base::Unretained(this))));
226 258
227 if (fake_) { 259 if (fake_) {
228 scoped_ptr<VideoFrameCapturer> capturer(new VideoFrameCapturerFake()); 260 desktop_environment_factory_.reset(new FakeDesktopEnvironmentFactory());
229 scoped_ptr<EventExecutor> event_executor = EventExecutor::Create(
230 context_.desktop_task_runner(),
231 context_.ui_task_runner());
232 scoped_ptr<AudioCapturer> audio_capturer(NULL);
233 desktop_environment_ = DesktopEnvironment::CreateFake(
234 &context_,
235 capturer.Pass(),
236 event_executor.Pass(),
237 audio_capturer.Pass());
238 } else { 261 } else {
239 desktop_environment_ = DesktopEnvironment::Create(&context_); 262 desktop_environment_factory_.reset(new DesktopEnvironmentFactory());
240 } 263 }
241 264
242 host_ = new ChromotingHost( 265 host_ = new ChromotingHost(
243 &context_, signal_strategy_.get(), desktop_environment_.get(), 266 &context_, signal_strategy_.get(), desktop_environment_factory_.get(),
244 CreateHostSessionManager(network_settings_, 267 CreateHostSessionManager(network_settings_,
245 context_.url_request_context_getter())); 268 context_.url_request_context_getter()));
246 269
247 ServerLogEntry::Mode mode = 270 ServerLogEntry::Mode mode =
248 is_it2me_ ? ServerLogEntry::IT2ME : ServerLogEntry::ME2ME; 271 is_it2me_ ? ServerLogEntry::IT2ME : ServerLogEntry::ME2ME;
249 log_to_server_.reset(new LogToServer(host_, mode, signal_strategy_.get())); 272 log_to_server_.reset(new LogToServer(host_, mode, signal_strategy_.get()));
250 273
251 if (is_it2me_) { 274 if (is_it2me_) {
252 it2me_host_user_interface_.reset(new It2MeHostUserInterface(&context_)); 275 it2me_host_user_interface_.reset(new It2MeHostUserInterface(&context_));
253 it2me_host_user_interface_->Start( 276 it2me_host_user_interface_->Start(
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 NetworkSettings network_settings_; 342 NetworkSettings network_settings_;
320 scoped_ptr<CandidateSessionConfig> protocol_config_; 343 scoped_ptr<CandidateSessionConfig> protocol_config_;
321 344
322 std::string host_id_; 345 std::string host_id_;
323 HostKeyPair key_pair_; 346 HostKeyPair key_pair_;
324 protocol::SharedSecretHash host_secret_hash_; 347 protocol::SharedSecretHash host_secret_hash_;
325 std::string xmpp_login_; 348 std::string xmpp_login_;
326 std::string xmpp_auth_token_; 349 std::string xmpp_auth_token_;
327 std::string xmpp_auth_service_; 350 std::string xmpp_auth_service_;
328 351
352 scoped_ptr<DesktopEnvironmentFactory> desktop_environment_factory_;
329 scoped_ptr<XmppSignalStrategy> signal_strategy_; 353 scoped_ptr<XmppSignalStrategy> signal_strategy_;
330 scoped_ptr<SignalingConnector> signaling_connector_; 354 scoped_ptr<SignalingConnector> signaling_connector_;
331 scoped_ptr<DesktopEnvironment> desktop_environment_;
332 scoped_ptr<LogToServer> log_to_server_; 355 scoped_ptr<LogToServer> log_to_server_;
333 scoped_ptr<It2MeHostUserInterface> it2me_host_user_interface_; 356 scoped_ptr<It2MeHostUserInterface> it2me_host_user_interface_;
334 scoped_ptr<RegisterSupportHostRequest> register_request_; 357 scoped_ptr<RegisterSupportHostRequest> register_request_;
335 scoped_ptr<HeartbeatSender> heartbeat_sender_; 358 scoped_ptr<HeartbeatSender> heartbeat_sender_;
336 359
337 scoped_refptr<ChromotingHost> host_; 360 scoped_refptr<ChromotingHost> host_;
338 361
339 bool shutting_down_; 362 bool shutting_down_;
340 int exit_code_; 363 int exit_code_;
341 }; 364 };
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 max_port < 0 || max_port > 65535) { 455 max_port < 0 || max_port > 65535) {
433 LOG(ERROR) << "Invalid max-port value: " << max_port 456 LOG(ERROR) << "Invalid max-port value: " << max_port
434 << ". Expected integer in range [0, 65535]."; 457 << ". Expected integer in range [0, 65535].";
435 return 1; 458 return 1;
436 } 459 }
437 simple_host.network_settings()->max_port = max_port; 460 simple_host.network_settings()->max_port = max_port;
438 } 461 }
439 462
440 return simple_host.Run(); 463 return simple_host.Run();
441 } 464 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698