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 124 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 // Set enable_window_capture_ to false because the window id from the | |
| 469 // command line was not found. Continue streaming the entire desktop | |
| 470 // instead. | |
|
Wez
2014/08/08 22:12:13
This comment is out of date.
ronakvora do not use
2014/08/08 22:28:26
Done.
| |
| 471 LOG(ERROR) << "Window with window id: " << window_id_ | |
| 472 << " not found. Shutting down host."; | |
| 473 enable_window_capture_ = false; | |
|
Wez
2014/08/08 22:12:14
No need to set this flag in this case, since you'r
ronakvora do not use
2014/08/08 22:28:26
Isn't the meaningful exit code to return false?
Wez
2014/08/11 06:40:36
That's the function return code - what will the pr
Sergey Ulanov
2014/08/12 18:18:00
Host should exit with kUsageExitCode after returni
ronakvora do not use
2014/08/13 18:04:43
Got it. removed.
| |
| 474 return false; | |
| 475 } | |
| 476 } | |
| 449 return true; | 477 return true; |
| 450 } | 478 } |
| 451 | 479 |
| 452 void HostProcess::OnConfigUpdated( | 480 void HostProcess::OnConfigUpdated( |
| 453 const std::string& serialized_config) { | 481 const std::string& serialized_config) { |
| 454 if (!context_->network_task_runner()->BelongsToCurrentThread()) { | 482 if (!context_->network_task_runner()->BelongsToCurrentThread()) { |
| 455 context_->network_task_runner()->PostTask(FROM_HERE, | 483 context_->network_task_runner()->PostTask(FROM_HERE, |
| 456 base::Bind(&HostProcess::OnConfigUpdated, this, serialized_config)); | 484 base::Bind(&HostProcess::OnConfigUpdated, this, serialized_config)); |
| 457 return; | 485 return; |
| 458 } | 486 } |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 669 #if defined(OS_WIN) | 697 #if defined(OS_WIN) |
| 670 IpcDesktopEnvironmentFactory* desktop_environment_factory = | 698 IpcDesktopEnvironmentFactory* desktop_environment_factory = |
| 671 new IpcDesktopEnvironmentFactory( | 699 new IpcDesktopEnvironmentFactory( |
| 672 context_->audio_task_runner(), | 700 context_->audio_task_runner(), |
| 673 context_->network_task_runner(), | 701 context_->network_task_runner(), |
| 674 context_->video_capture_task_runner(), | 702 context_->video_capture_task_runner(), |
| 675 context_->network_task_runner(), | 703 context_->network_task_runner(), |
| 676 daemon_channel_.get()); | 704 daemon_channel_.get()); |
| 677 desktop_session_connector_ = desktop_environment_factory; | 705 desktop_session_connector_ = desktop_environment_factory; |
| 678 #else // !defined(OS_WIN) | 706 #else // !defined(OS_WIN) |
| 679 DesktopEnvironmentFactory* desktop_environment_factory = | 707 DesktopEnvironmentFactory* desktop_environment_factory; |
| 708 if (enable_window_capture_) { | |
| 709 desktop_environment_factory = | |
| 710 new SingleWindowDesktopEnvironmentFactory( | |
| 711 context_->network_task_runner(), | |
| 712 context_->input_task_runner(), | |
| 713 context_->ui_task_runner(), | |
| 714 window_id_); | |
| 715 } else { | |
| 716 desktop_environment_factory = | |
| 680 new Me2MeDesktopEnvironmentFactory( | 717 new Me2MeDesktopEnvironmentFactory( |
| 681 context_->network_task_runner(), | 718 context_->network_task_runner(), |
| 682 context_->input_task_runner(), | 719 context_->input_task_runner(), |
| 683 context_->ui_task_runner()); | 720 context_->ui_task_runner()); |
| 721 } | |
| 684 #endif // !defined(OS_WIN) | 722 #endif // !defined(OS_WIN) |
| 685 | 723 |
| 686 desktop_environment_factory_.reset(desktop_environment_factory); | 724 desktop_environment_factory_.reset(desktop_environment_factory); |
| 687 desktop_environment_factory_->SetEnableGnubbyAuth(enable_gnubby_auth_); | 725 desktop_environment_factory_->SetEnableGnubbyAuth(enable_gnubby_auth_); |
| 688 | 726 |
| 689 context_->network_task_runner()->PostTask( | 727 context_->network_task_runner()->PostTask( |
| 690 FROM_HERE, | 728 FROM_HERE, |
| 691 base::Bind(&HostProcess::StartOnNetworkThread, this)); | 729 base::Bind(&HostProcess::StartOnNetworkThread, this)); |
| 692 } | 730 } |
| 693 | 731 |
| (...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1375 return exit_code; | 1413 return exit_code; |
| 1376 } | 1414 } |
| 1377 | 1415 |
| 1378 } // namespace remoting | 1416 } // namespace remoting |
| 1379 | 1417 |
| 1380 #if !defined(OS_WIN) | 1418 #if !defined(OS_WIN) |
| 1381 int main(int argc, char** argv) { | 1419 int main(int argc, char** argv) { |
| 1382 return remoting::HostMain(argc, argv); | 1420 return remoting::HostMain(argc, argv); |
| 1383 } | 1421 } |
| 1384 #endif // !defined(OS_WIN) | 1422 #endif // !defined(OS_WIN) |
| OLD | NEW |