Chromium Code Reviews| 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 file implements a standalone host process for Me2Me. | 5 // This file implements a standalone host process for Me2Me. |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 #include "remoting/host/ipc_constants.h" | 58 #include "remoting/host/ipc_constants.h" |
| 59 #include "remoting/host/ipc_desktop_environment.h" | 59 #include "remoting/host/ipc_desktop_environment.h" |
| 60 #include "remoting/host/ipc_host_event_logger.h" | 60 #include "remoting/host/ipc_host_event_logger.h" |
| 61 #include "remoting/host/json_host_config.h" | 61 #include "remoting/host/json_host_config.h" |
| 62 #include "remoting/host/logging.h" | 62 #include "remoting/host/logging.h" |
| 63 #include "remoting/host/me2me_desktop_environment.h" | 63 #include "remoting/host/me2me_desktop_environment.h" |
| 64 #include "remoting/host/pairing_registry_delegate.h" | 64 #include "remoting/host/pairing_registry_delegate.h" |
| 65 #include "remoting/host/policy_hack/policy_watcher.h" | 65 #include "remoting/host/policy_hack/policy_watcher.h" |
| 66 #include "remoting/host/session_manager_factory.h" | 66 #include "remoting/host/session_manager_factory.h" |
| 67 #include "remoting/host/signaling_connector.h" | 67 #include "remoting/host/signaling_connector.h" |
| 68 #include "remoting/host/single_window_desktop_environment.h" | |
| 68 #include "remoting/host/token_validator_factory_impl.h" | 69 #include "remoting/host/token_validator_factory_impl.h" |
| 69 #include "remoting/host/usage_stats_consent.h" | 70 #include "remoting/host/usage_stats_consent.h" |
| 70 #include "remoting/host/username.h" | 71 #include "remoting/host/username.h" |
| 71 #include "remoting/jingle_glue/network_settings.h" | 72 #include "remoting/jingle_glue/network_settings.h" |
| 72 #include "remoting/jingle_glue/xmpp_signal_strategy.h" | 73 #include "remoting/jingle_glue/xmpp_signal_strategy.h" |
| 73 #include "remoting/protocol/me2me_host_authenticator_factory.h" | 74 #include "remoting/protocol/me2me_host_authenticator_factory.h" |
| 74 #include "remoting/protocol/pairing_registry.h" | 75 #include "remoting/protocol/pairing_registry.h" |
| 75 #include "remoting/protocol/token_validator.h" | 76 #include "remoting/protocol/token_validator.h" |
| 76 | 77 |
| 77 #if defined(OS_POSIX) | 78 #if defined(OS_POSIX) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 // when it is successfully started. | 121 // when it is successfully started. |
| 121 const char kSignalParentSwitchName[] = "signal-parent"; | 122 const char kSignalParentSwitchName[] = "signal-parent"; |
| 122 | 123 |
| 123 // Command line switch used to enable VP9 encoding. | 124 // Command line switch used to enable VP9 encoding. |
| 124 const char kEnableVp9SwitchName[] = "enable-vp9"; | 125 const char kEnableVp9SwitchName[] = "enable-vp9"; |
| 125 | 126 |
| 126 // Value used for --host-config option to indicate that the path must be read | 127 // Value used for --host-config option to indicate that the path must be read |
| 127 // from stdin. | 128 // from stdin. |
| 128 const char kStdinConfigPath[] = "-"; | 129 const char kStdinConfigPath[] = "-"; |
| 129 | 130 |
| 131 const char kWindowIdSwitchName[] = "window-id"; | |
| 132 | |
| 130 } // namespace | 133 } // namespace |
| 131 | 134 |
| 132 namespace remoting { | 135 namespace remoting { |
| 133 | 136 |
| 134 class HostProcess | 137 class HostProcess |
| 135 : public ConfigWatcher::Delegate, | 138 : public ConfigWatcher::Delegate, |
| 136 public HeartbeatSender::Listener, | 139 public HeartbeatSender::Listener, |
| 137 public HostChangeNotificationListener::Listener, | 140 public HostChangeNotificationListener::Listener, |
| 138 public IPC::Listener, | 141 public IPC::Listener, |
| 139 public base::RefCountedThreadSafe<HostProcess> { | 142 public base::RefCountedThreadSafe<HostProcess> { |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 bool allow_relay_; | 298 bool allow_relay_; |
| 296 int min_udp_port_; | 299 int min_udp_port_; |
| 297 int max_udp_port_; | 300 int max_udp_port_; |
| 298 std::string talkgadget_prefix_; | 301 std::string talkgadget_prefix_; |
| 299 bool allow_pairing_; | 302 bool allow_pairing_; |
| 300 | 303 |
| 301 bool curtain_required_; | 304 bool curtain_required_; |
| 302 ThirdPartyAuthConfig third_party_auth_config_; | 305 ThirdPartyAuthConfig third_party_auth_config_; |
| 303 bool enable_gnubby_auth_; | 306 bool enable_gnubby_auth_; |
| 304 | 307 |
| 308 // Boolean to change flow, where ncessary, if we're | |
| 309 // capturing a window instead of the entire desktop. | |
| 310 bool enable_window_capture_; | |
| 311 | |
| 312 // Used to specify which window to stream, if enabled. | |
| 313 webrtc::WindowId window_id_; | |
| 314 | |
| 305 scoped_ptr<OAuthTokenGetter> oauth_token_getter_; | 315 scoped_ptr<OAuthTokenGetter> oauth_token_getter_; |
| 306 scoped_ptr<XmppSignalStrategy> signal_strategy_; | 316 scoped_ptr<XmppSignalStrategy> signal_strategy_; |
| 307 scoped_ptr<SignalingConnector> signaling_connector_; | 317 scoped_ptr<SignalingConnector> signaling_connector_; |
| 308 scoped_ptr<HeartbeatSender> heartbeat_sender_; | 318 scoped_ptr<HeartbeatSender> heartbeat_sender_; |
| 309 scoped_ptr<HostStatusSender> host_status_sender_; | 319 scoped_ptr<HostStatusSender> host_status_sender_; |
| 310 scoped_ptr<HostChangeNotificationListener> host_change_notification_listener_; | 320 scoped_ptr<HostChangeNotificationListener> host_change_notification_listener_; |
| 311 scoped_ptr<HostStatusLogger> host_status_logger_; | 321 scoped_ptr<HostStatusLogger> host_status_logger_; |
| 312 scoped_ptr<HostEventLogger> host_event_logger_; | 322 scoped_ptr<HostEventLogger> host_event_logger_; |
| 313 | 323 |
| 314 scoped_ptr<ChromotingHost> host_; | 324 scoped_ptr<ChromotingHost> host_; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 336 allow_nat_traversal_(true), | 346 allow_nat_traversal_(true), |
| 337 allow_relay_(true), | 347 allow_relay_(true), |
| 338 min_udp_port_(0), | 348 min_udp_port_(0), |
| 339 max_udp_port_(0), | 349 max_udp_port_(0), |
| 340 allow_pairing_(true), | 350 allow_pairing_(true), |
| 341 curtain_required_(false), | 351 curtain_required_(false), |
| 342 enable_gnubby_auth_(false), | 352 enable_gnubby_auth_(false), |
| 343 #if defined(REMOTING_MULTI_PROCESS) | 353 #if defined(REMOTING_MULTI_PROCESS) |
| 344 desktop_session_connector_(NULL), | 354 desktop_session_connector_(NULL), |
| 345 #endif // defined(REMOTING_MULTI_PROCESS) | 355 #endif // defined(REMOTING_MULTI_PROCESS) |
| 346 self_(this), | 356 self_(this), |
|
Sergey Ulanov
2014/08/12 18:18:00
Add initializers for enable_window_capture_ and wi
Sergey Ulanov
2014/08/13 21:27:13
Please address this comment
| |
| 347 exit_code_out_(exit_code_out), | 357 exit_code_out_(exit_code_out), |
| 348 signal_parent_(false) { | 358 signal_parent_(false) { |
| 349 StartOnUiThread(); | 359 StartOnUiThread(); |
| 350 } | 360 } |
| 351 | 361 |
| 352 HostProcess::~HostProcess() { | 362 HostProcess::~HostProcess() { |
| 353 // Verify that UI components have been torn down. | 363 // Verify that UI components have been torn down. |
| 354 DCHECK(!config_watcher_); | 364 DCHECK(!config_watcher_); |
| 355 DCHECK(!daemon_channel_); | 365 DCHECK(!daemon_channel_); |
| 356 DCHECK(!desktop_environment_factory_); | 366 DCHECK(!desktop_environment_factory_); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 439 if (!xmpp_server_valid) { | 449 if (!xmpp_server_valid) { |
| 440 LOG(ERROR) << "Invalid XMPP server: " << | 450 LOG(ERROR) << "Invalid XMPP server: " << |
| 441 service_urls->xmpp_server_address(); | 451 service_urls->xmpp_server_address(); |
| 442 return false; | 452 return false; |
| 443 } | 453 } |
| 444 xmpp_server_config_.use_tls = service_urls->xmpp_server_use_tls(); | 454 xmpp_server_config_.use_tls = service_urls->xmpp_server_use_tls(); |
| 445 directory_bot_jid_ = service_urls->directory_bot_jid(); | 455 directory_bot_jid_ = service_urls->directory_bot_jid(); |
| 446 | 456 |
| 447 signal_parent_ = cmd_line->HasSwitch(kSignalParentSwitchName); | 457 signal_parent_ = cmd_line->HasSwitch(kSignalParentSwitchName); |
| 448 | 458 |
| 459 enable_window_capture_ = cmd_line->HasSwitch(kWindowIdSwitchName); | |
| 460 if (enable_window_capture_) { | |
| 461 // uint32_t is large enough to hold window IDs on all platforms. | |
| 462 uint32_t window_id; | |
| 463 if (base::StringToUint( | |
| 464 cmd_line->GetSwitchValueASCII(kWindowIdSwitchName), | |
| 465 &window_id)) { | |
| 466 window_id_ = static_cast<webrtc::WindowId>(window_id); | |
| 467 } else { | |
| 468 LOG(ERROR) << "Window with window id: " << window_id_ | |
| 469 << " not found. Shutting down host."; | |
| 470 std::exit(EXIT_FAILURE); | |
|
Sergey Ulanov
2014/08/12 18:18:00
Don't need this. Host process should exit with kUs
ronakvora do not use
2014/08/13 18:04:44
Removed.
| |
| 471 return false; | |
| 472 } | |
| 473 } | |
| 449 return true; | 474 return true; |
| 450 } | 475 } |
| 451 | 476 |
| 452 void HostProcess::OnConfigUpdated( | 477 void HostProcess::OnConfigUpdated( |
| 453 const std::string& serialized_config) { | 478 const std::string& serialized_config) { |
| 454 if (!context_->network_task_runner()->BelongsToCurrentThread()) { | 479 if (!context_->network_task_runner()->BelongsToCurrentThread()) { |
| 455 context_->network_task_runner()->PostTask(FROM_HERE, | 480 context_->network_task_runner()->PostTask(FROM_HERE, |
| 456 base::Bind(&HostProcess::OnConfigUpdated, this, serialized_config)); | 481 base::Bind(&HostProcess::OnConfigUpdated, this, serialized_config)); |
| 457 return; | 482 return; |
| 458 } | 483 } |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 669 #if defined(OS_WIN) | 694 #if defined(OS_WIN) |
| 670 IpcDesktopEnvironmentFactory* desktop_environment_factory = | 695 IpcDesktopEnvironmentFactory* desktop_environment_factory = |
| 671 new IpcDesktopEnvironmentFactory( | 696 new IpcDesktopEnvironmentFactory( |
| 672 context_->audio_task_runner(), | 697 context_->audio_task_runner(), |
| 673 context_->network_task_runner(), | 698 context_->network_task_runner(), |
| 674 context_->video_capture_task_runner(), | 699 context_->video_capture_task_runner(), |
| 675 context_->network_task_runner(), | 700 context_->network_task_runner(), |
| 676 daemon_channel_.get()); | 701 daemon_channel_.get()); |
| 677 desktop_session_connector_ = desktop_environment_factory; | 702 desktop_session_connector_ = desktop_environment_factory; |
| 678 #else // !defined(OS_WIN) | 703 #else // !defined(OS_WIN) |
| 679 DesktopEnvironmentFactory* desktop_environment_factory = | 704 DesktopEnvironmentFactory* desktop_environment_factory; |
| 705 if (enable_window_capture_) { | |
| 706 desktop_environment_factory = | |
| 707 new SingleWindowDesktopEnvironmentFactory( | |
| 708 context_->network_task_runner(), | |
| 709 context_->input_task_runner(), | |
| 710 context_->ui_task_runner(), | |
| 711 window_id_); | |
| 712 } else { | |
| 713 desktop_environment_factory = | |
| 680 new Me2MeDesktopEnvironmentFactory( | 714 new Me2MeDesktopEnvironmentFactory( |
| 681 context_->network_task_runner(), | 715 context_->network_task_runner(), |
| 682 context_->input_task_runner(), | 716 context_->input_task_runner(), |
| 683 context_->ui_task_runner()); | 717 context_->ui_task_runner()); |
| 718 } | |
| 684 #endif // !defined(OS_WIN) | 719 #endif // !defined(OS_WIN) |
| 685 | 720 |
| 686 desktop_environment_factory_.reset(desktop_environment_factory); | 721 desktop_environment_factory_.reset(desktop_environment_factory); |
| 687 desktop_environment_factory_->SetEnableGnubbyAuth(enable_gnubby_auth_); | 722 desktop_environment_factory_->SetEnableGnubbyAuth(enable_gnubby_auth_); |
| 688 | 723 |
| 689 context_->network_task_runner()->PostTask( | 724 context_->network_task_runner()->PostTask( |
| 690 FROM_HERE, | 725 FROM_HERE, |
| 691 base::Bind(&HostProcess::StartOnNetworkThread, this)); | 726 base::Bind(&HostProcess::StartOnNetworkThread, this)); |
| 692 } | 727 } |
| 693 | 728 |
| (...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1375 return exit_code; | 1410 return exit_code; |
| 1376 } | 1411 } |
| 1377 | 1412 |
| 1378 } // namespace remoting | 1413 } // namespace remoting |
| 1379 | 1414 |
| 1380 #if !defined(OS_WIN) | 1415 #if !defined(OS_WIN) |
| 1381 int main(int argc, char** argv) { | 1416 int main(int argc, char** argv) { |
| 1382 return remoting::HostMain(argc, argv); | 1417 return remoting::HostMain(argc, argv); |
| 1383 } | 1418 } |
| 1384 #endif // !defined(OS_WIN) | 1419 #endif // !defined(OS_WIN) |
| OLD | NEW |