| OLD | NEW |
| 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 23 matching lines...) Expand all Loading... |
| 34 #include "net/socket/ssl_server_socket.h" | 34 #include "net/socket/ssl_server_socket.h" |
| 35 #include "remoting/base/auto_thread_task_runner.h" | 35 #include "remoting/base/auto_thread_task_runner.h" |
| 36 #include "remoting/base/constants.h" | 36 #include "remoting/base/constants.h" |
| 37 #include "remoting/host/audio_capturer.h" | 37 #include "remoting/host/audio_capturer.h" |
| 38 #include "remoting/host/chromoting_host_context.h" | 38 #include "remoting/host/chromoting_host_context.h" |
| 39 #include "remoting/host/chromoting_host.h" | 39 #include "remoting/host/chromoting_host.h" |
| 40 #include "remoting/host/constants.h" | 40 #include "remoting/host/constants.h" |
| 41 #include "remoting/host/desktop_environment.h" | 41 #include "remoting/host/desktop_environment.h" |
| 42 #include "remoting/host/dns_blackhole_checker.h" | 42 #include "remoting/host/dns_blackhole_checker.h" |
| 43 #include "remoting/host/event_executor.h" | 43 #include "remoting/host/event_executor.h" |
| 44 #include "remoting/host/desktop_environment.h" |
| 45 #include "remoting/host/desktop_environment_factory.h" |
| 44 #include "remoting/host/heartbeat_sender.h" | 46 #include "remoting/host/heartbeat_sender.h" |
| 45 #include "remoting/host/host_key_pair.h" | 47 #include "remoting/host/host_key_pair.h" |
| 46 #include "remoting/host/host_secret.h" | 48 #include "remoting/host/host_secret.h" |
| 47 #include "remoting/host/it2me_host_user_interface.h" | 49 #include "remoting/host/it2me_host_user_interface.h" |
| 48 #include "remoting/host/json_host_config.h" | 50 #include "remoting/host/json_host_config.h" |
| 49 #include "remoting/host/log_to_server.h" | 51 #include "remoting/host/log_to_server.h" |
| 50 #include "remoting/host/network_settings.h" | 52 #include "remoting/host/network_settings.h" |
| 51 #include "remoting/host/register_support_host_request.h" | 53 #include "remoting/host/register_support_host_request.h" |
| 52 #include "remoting/host/session_manager_factory.h" | 54 #include "remoting/host/session_manager_factory.h" |
| 53 #include "remoting/host/signaling_connector.h" | 55 #include "remoting/host/signaling_connector.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 const char kMaxPortSwitchName[] = "max-port"; | 89 const char kMaxPortSwitchName[] = "max-port"; |
| 88 | 90 |
| 89 const char kVideoSwitchValueVerbatim[] = "verbatim"; | 91 const char kVideoSwitchValueVerbatim[] = "verbatim"; |
| 90 const char kVideoSwitchValueZip[] = "zip"; | 92 const char kVideoSwitchValueZip[] = "zip"; |
| 91 const char kVideoSwitchValueVp8[] = "vp8"; | 93 const char kVideoSwitchValueVp8[] = "vp8"; |
| 92 | 94 |
| 93 } // namespace | 95 } // namespace |
| 94 | 96 |
| 95 namespace remoting { | 97 namespace remoting { |
| 96 | 98 |
| 99 class FakeDesktopEnvironmentFactory : public DesktopEnvironmentFactory { |
| 100 public: |
| 101 FakeDesktopEnvironmentFactory(); |
| 102 virtual ~FakeDesktopEnvironmentFactory(); |
| 103 |
| 104 virtual scoped_ptr<DesktopEnvironment> Create( |
| 105 ChromotingHostContext* context) OVERRIDE; |
| 106 |
| 107 DISALLOW_COPY_AND_ASSIGN(FakeDesktopEnvironmentFactory); |
| 108 }; |
| 109 |
| 110 FakeDesktopEnvironmentFactory::FakeDesktopEnvironmentFactory() { |
| 111 } |
| 112 |
| 113 FakeDesktopEnvironmentFactory::~FakeDesktopEnvironmentFactory() { |
| 114 } |
| 115 |
| 116 scoped_ptr<DesktopEnvironment> FakeDesktopEnvironmentFactory::Create( |
| 117 ChromotingHostContext* context) { |
| 118 scoped_ptr<VideoFrameCapturer> capturer(new VideoFrameCapturerFake()); |
| 119 scoped_ptr<EventExecutor> event_executor = EventExecutor::Create( |
| 120 context->desktop_task_runner(), |
| 121 context->ui_task_runner()); |
| 122 scoped_ptr<AudioCapturer> audio_capturer(NULL); |
| 123 return scoped_ptr<DesktopEnvironment>(new DesktopEnvironment( |
| 124 audio_capturer.Pass(), |
| 125 event_executor.Pass(), |
| 126 capturer.Pass())); |
| 127 } |
| 128 |
| 97 class SimpleHost : public HeartbeatSender::Listener { | 129 class SimpleHost : public HeartbeatSender::Listener { |
| 98 public: | 130 public: |
| 99 SimpleHost() | 131 SimpleHost() |
| 100 : message_loop_(MessageLoop::TYPE_UI), | 132 : message_loop_(MessageLoop::TYPE_UI), |
| 101 context_(new AutoThreadTaskRunner(message_loop_.message_loop_proxy())), | 133 context_(new AutoThreadTaskRunner(message_loop_.message_loop_proxy())), |
| 102 fake_(false), | 134 fake_(false), |
| 103 is_it2me_(false), | 135 is_it2me_(false), |
| 104 shutting_down_(false), | 136 shutting_down_(false), |
| 105 exit_code_(kSuccessExitCode) { | 137 exit_code_(kSuccessExitCode) { |
| 106 context_.Start(); | 138 context_.Start(); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 signal_strategy_.reset(new XmppSignalStrategy( | 254 signal_strategy_.reset(new XmppSignalStrategy( |
| 223 context_.url_request_context_getter(), | 255 context_.url_request_context_getter(), |
| 224 xmpp_login_, xmpp_auth_token_, xmpp_auth_service_)); | 256 xmpp_login_, xmpp_auth_token_, xmpp_auth_service_)); |
| 225 scoped_ptr<DnsBlackholeChecker> dns_blackhole_checker( | 257 scoped_ptr<DnsBlackholeChecker> dns_blackhole_checker( |
| 226 new DnsBlackholeChecker(&context_, kDefaultHostTalkGadgetPrefix)); | 258 new DnsBlackholeChecker(&context_, kDefaultHostTalkGadgetPrefix)); |
| 227 signaling_connector_.reset(new SignalingConnector( | 259 signaling_connector_.reset(new SignalingConnector( |
| 228 signal_strategy_.get(), &context_, dns_blackhole_checker.Pass(), | 260 signal_strategy_.get(), &context_, dns_blackhole_checker.Pass(), |
| 229 base::Bind(&SimpleHost::OnAuthFailed, base::Unretained(this)))); | 261 base::Bind(&SimpleHost::OnAuthFailed, base::Unretained(this)))); |
| 230 | 262 |
| 231 if (fake_) { | 263 if (fake_) { |
| 232 scoped_ptr<VideoFrameCapturer> capturer(new VideoFrameCapturerFake()); | 264 desktop_environment_factory_.reset(new FakeDesktopEnvironmentFactory()); |
| 233 scoped_ptr<EventExecutor> event_executor = EventExecutor::Create( | |
| 234 context_.desktop_task_runner(), | |
| 235 context_.ui_task_runner()); | |
| 236 scoped_ptr<AudioCapturer> audio_capturer(NULL); | |
| 237 desktop_environment_ = DesktopEnvironment::CreateFake( | |
| 238 &context_, | |
| 239 capturer.Pass(), | |
| 240 event_executor.Pass(), | |
| 241 audio_capturer.Pass()); | |
| 242 } else { | 265 } else { |
| 243 desktop_environment_ = DesktopEnvironment::Create(&context_); | 266 desktop_environment_factory_.reset(new DesktopEnvironmentFactory()); |
| 244 } | 267 } |
| 245 | 268 |
| 246 host_ = new ChromotingHost( | 269 host_ = new ChromotingHost( |
| 247 &context_, signal_strategy_.get(), desktop_environment_.get(), | 270 &context_, signal_strategy_.get(), desktop_environment_factory_.get(), |
| 248 CreateHostSessionManager(network_settings_, | 271 CreateHostSessionManager(network_settings_, |
| 249 context_.url_request_context_getter())); | 272 context_.url_request_context_getter())); |
| 250 | 273 |
| 251 ServerLogEntry::Mode mode = | 274 ServerLogEntry::Mode mode = |
| 252 is_it2me_ ? ServerLogEntry::IT2ME : ServerLogEntry::ME2ME; | 275 is_it2me_ ? ServerLogEntry::IT2ME : ServerLogEntry::ME2ME; |
| 253 log_to_server_.reset(new LogToServer(host_, mode, signal_strategy_.get())); | 276 log_to_server_.reset(new LogToServer(host_, mode, signal_strategy_.get())); |
| 254 | 277 |
| 255 if (is_it2me_) { | 278 if (is_it2me_) { |
| 256 it2me_host_user_interface_.reset(new It2MeHostUserInterface(&context_)); | 279 it2me_host_user_interface_.reset(new It2MeHostUserInterface(&context_)); |
| 257 it2me_host_user_interface_->Start( | 280 it2me_host_user_interface_->Start( |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 NetworkSettings network_settings_; | 347 NetworkSettings network_settings_; |
| 325 scoped_ptr<CandidateSessionConfig> protocol_config_; | 348 scoped_ptr<CandidateSessionConfig> protocol_config_; |
| 326 | 349 |
| 327 std::string host_id_; | 350 std::string host_id_; |
| 328 HostKeyPair key_pair_; | 351 HostKeyPair key_pair_; |
| 329 protocol::SharedSecretHash host_secret_hash_; | 352 protocol::SharedSecretHash host_secret_hash_; |
| 330 std::string xmpp_login_; | 353 std::string xmpp_login_; |
| 331 std::string xmpp_auth_token_; | 354 std::string xmpp_auth_token_; |
| 332 std::string xmpp_auth_service_; | 355 std::string xmpp_auth_service_; |
| 333 | 356 |
| 357 scoped_ptr<DesktopEnvironmentFactory> desktop_environment_factory_; |
| 334 scoped_ptr<XmppSignalStrategy> signal_strategy_; | 358 scoped_ptr<XmppSignalStrategy> signal_strategy_; |
| 335 scoped_ptr<DnsBlackholeChecker> dns_blackhole_checker_; | 359 scoped_ptr<DnsBlackholeChecker> dns_blackhole_checker_; |
| 336 scoped_ptr<SignalingConnector> signaling_connector_; | 360 scoped_ptr<SignalingConnector> signaling_connector_; |
| 337 scoped_ptr<DesktopEnvironment> desktop_environment_; | |
| 338 scoped_ptr<LogToServer> log_to_server_; | 361 scoped_ptr<LogToServer> log_to_server_; |
| 339 scoped_ptr<It2MeHostUserInterface> it2me_host_user_interface_; | 362 scoped_ptr<It2MeHostUserInterface> it2me_host_user_interface_; |
| 340 scoped_ptr<RegisterSupportHostRequest> register_request_; | 363 scoped_ptr<RegisterSupportHostRequest> register_request_; |
| 341 scoped_ptr<HeartbeatSender> heartbeat_sender_; | 364 scoped_ptr<HeartbeatSender> heartbeat_sender_; |
| 342 | 365 |
| 343 scoped_refptr<ChromotingHost> host_; | 366 scoped_refptr<ChromotingHost> host_; |
| 344 | 367 |
| 345 bool shutting_down_; | 368 bool shutting_down_; |
| 346 int exit_code_; | 369 int exit_code_; |
| 347 }; | 370 }; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 max_port < 0 || max_port > 65535) { | 461 max_port < 0 || max_port > 65535) { |
| 439 LOG(ERROR) << "Invalid max-port value: " << max_port | 462 LOG(ERROR) << "Invalid max-port value: " << max_port |
| 440 << ". Expected integer in range [0, 65535]."; | 463 << ". Expected integer in range [0, 65535]."; |
| 441 return 1; | 464 return 1; |
| 442 } | 465 } |
| 443 simple_host.network_settings()->max_port = max_port; | 466 simple_host.network_settings()->max_port = max_port; |
| 444 } | 467 } |
| 445 | 468 |
| 446 return simple_host.Run(); | 469 return simple_host.Run(); |
| 447 } | 470 } |
| OLD | NEW |