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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 #include "remoting/host/host_exit_codes.h" | 54 #include "remoting/host/host_exit_codes.h" |
55 #include "remoting/host/host_main.h" | 55 #include "remoting/host/host_main.h" |
56 #include "remoting/host/host_status_logger.h" | 56 #include "remoting/host/host_status_logger.h" |
57 #include "remoting/host/host_status_sender.h" | 57 #include "remoting/host/host_status_sender.h" |
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/me2me_single_window_desktop_environment.h" | |
64 #include "remoting/host/pairing_registry_delegate.h" | 65 #include "remoting/host/pairing_registry_delegate.h" |
65 #include "remoting/host/policy_hack/policy_watcher.h" | 66 #include "remoting/host/policy_hack/policy_watcher.h" |
66 #include "remoting/host/session_manager_factory.h" | 67 #include "remoting/host/session_manager_factory.h" |
67 #include "remoting/host/signaling_connector.h" | 68 #include "remoting/host/signaling_connector.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" |
(...skipping 46 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 extern const char kWindowIdSwitchName[] = "window-id"; | |
Lambros
2014/08/05 22:47:24
nit: remove 'extern'
ronakvora do not use
2014/08/06 20:56:18
Ah, I had this for when I thought I was going to u
| |
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 // Used to specify which window to stream, if enabled. | |
Lambros
2014/08/05 22:47:24
nit: Blank line before this comment.
ronakvora do not use
2014/08/06 20:56:18
Done.
| |
312 webrtc::WindowId window_id_; | |
313 | |
305 scoped_ptr<OAuthTokenGetter> oauth_token_getter_; | 314 scoped_ptr<OAuthTokenGetter> oauth_token_getter_; |
306 scoped_ptr<XmppSignalStrategy> signal_strategy_; | 315 scoped_ptr<XmppSignalStrategy> signal_strategy_; |
307 scoped_ptr<SignalingConnector> signaling_connector_; | 316 scoped_ptr<SignalingConnector> signaling_connector_; |
308 scoped_ptr<HeartbeatSender> heartbeat_sender_; | 317 scoped_ptr<HeartbeatSender> heartbeat_sender_; |
309 scoped_ptr<HostStatusSender> host_status_sender_; | 318 scoped_ptr<HostStatusSender> host_status_sender_; |
310 scoped_ptr<HostChangeNotificationListener> host_change_notification_listener_; | 319 scoped_ptr<HostChangeNotificationListener> host_change_notification_listener_; |
311 scoped_ptr<HostStatusLogger> host_status_logger_; | 320 scoped_ptr<HostStatusLogger> host_status_logger_; |
312 scoped_ptr<HostEventLogger> host_event_logger_; | 321 scoped_ptr<HostEventLogger> host_event_logger_; |
313 | 322 |
314 scoped_ptr<ChromotingHost> host_; | 323 scoped_ptr<ChromotingHost> host_; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
418 } else { | 427 } else { |
419 base::FilePath default_config_dir = remoting::GetConfigDir(); | 428 base::FilePath default_config_dir = remoting::GetConfigDir(); |
420 host_config_path_ = default_config_dir.Append(kDefaultHostConfigFile); | 429 host_config_path_ = default_config_dir.Append(kDefaultHostConfigFile); |
421 } | 430 } |
422 | 431 |
423 if (host_config_path_ != base::FilePath(kStdinConfigPath) && | 432 if (host_config_path_ != base::FilePath(kStdinConfigPath) && |
424 !base::PathExists(host_config_path_)) { | 433 !base::PathExists(host_config_path_)) { |
425 LOG(ERROR) << "Can't find host config at " << host_config_path_.value(); | 434 LOG(ERROR) << "Can't find host config at " << host_config_path_.value(); |
426 return false; | 435 return false; |
427 } | 436 } |
437 | |
Lambros
2014/08/05 22:47:25
optional: remove this blank line
ronakvora do not use
2014/08/06 20:56:19
Done.
| |
428 #endif // !defined(REMOTING_MULTI_PROCESS) | 438 #endif // !defined(REMOTING_MULTI_PROCESS) |
429 | 439 |
430 // Ignore certificate requests - the host currently has no client certificate | 440 // Ignore certificate requests - the host currently has no client certificate |
431 // support, so ignoring certificate requests allows connecting to servers that | 441 // support, so ignoring certificate requests allows connecting to servers that |
432 // request, but don't require, a certificate (optional client authentication). | 442 // request, but don't require, a certificate (optional client authentication). |
433 net::URLFetcher::SetIgnoreCertificateRequests(true); | 443 net::URLFetcher::SetIgnoreCertificateRequests(true); |
434 | 444 |
435 ServiceUrls* service_urls = ServiceUrls::GetInstance(); | 445 ServiceUrls* service_urls = ServiceUrls::GetInstance(); |
436 bool xmpp_server_valid = net::ParseHostAndPort( | 446 bool xmpp_server_valid = net::ParseHostAndPort( |
437 service_urls->xmpp_server_address(), | 447 service_urls->xmpp_server_address(), |
438 &xmpp_server_config_.host, &xmpp_server_config_.port); | 448 &xmpp_server_config_.host, &xmpp_server_config_.port); |
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 enable_window_capture_ = cmd_line->HasSwitch(kWindowIdSwitchName); |
Wez
2014/08/06 04:10:16
nit: Blank line before this, to keep the window-ca
ronakvora do not use
2014/08/06 20:56:19
Done.
| |
459 if (enable_window_capture_) { | |
460 // CGWindowId is a uint32_t | |
Wez
2014/08/06 04:10:16
This comment doesn't seem relevant?
ronakvora do not use
2014/08/06 20:56:19
i'm not sure how window ids are represented on oth
Wez
2014/08/07 23:14:32
This is cross-platform code; it shouldn't have a c
ronakvora do not use
2014/08/08 17:07:13
Done.
| |
461 uint32_t window_id; | |
462 if (base::StringToUint( | |
463 cmd_line->GetSwitchValueASCII(kWindowIdSwitchName), | |
464 &window_id)) { | |
465 // window_id_ is of type long int, so we should not lose | |
Wez
2014/08/06 04:10:16
Doesn't its type depend upon the platform, since i
ronakvora do not use
2014/08/06 20:56:18
I'm not sure what the best way would be to get the
Wez
2014/08/07 23:14:32
What's important is the effect of truncation in pr
ronakvora do not use
2014/08/08 17:07:13
Got it.
| |
466 // any precision here. | |
467 window_id_ = static_cast<webrtc::WindowId>(window_id); | |
468 } else { | |
469 // Set enable_window_capture_ to false because we failed to get | |
Lambros
2014/08/05 22:47:25
optional: I would prefer to avoid 'we' in comments
ronakvora do not use
2014/08/06 20:56:18
Done.
| |
470 // the window id from the command line. Continue streaming | |
471 // the entire desktop instead. | |
472 LOG(ERROR) << "We wanted to stream a window but could not find its id."; | |
Lambros
2014/08/05 22:47:25
Suggestion:
LOG(ERROR) << "Window " << window_id_
ronakvora do not use
2014/08/06 20:56:18
Done.
| |
473 enable_window_capture_ = false; | |
474 } | |
475 } | |
449 return true; | 476 return true; |
450 } | 477 } |
451 | 478 |
452 void HostProcess::OnConfigUpdated( | 479 void HostProcess::OnConfigUpdated( |
453 const std::string& serialized_config) { | 480 const std::string& serialized_config) { |
454 if (!context_->network_task_runner()->BelongsToCurrentThread()) { | 481 if (!context_->network_task_runner()->BelongsToCurrentThread()) { |
455 context_->network_task_runner()->PostTask(FROM_HERE, | 482 context_->network_task_runner()->PostTask(FROM_HERE, |
456 base::Bind(&HostProcess::OnConfigUpdated, this, serialized_config)); | 483 base::Bind(&HostProcess::OnConfigUpdated, this, serialized_config)); |
457 return; | 484 return; |
458 } | 485 } |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
669 #if defined(OS_WIN) | 696 #if defined(OS_WIN) |
670 IpcDesktopEnvironmentFactory* desktop_environment_factory = | 697 IpcDesktopEnvironmentFactory* desktop_environment_factory = |
671 new IpcDesktopEnvironmentFactory( | 698 new IpcDesktopEnvironmentFactory( |
672 context_->audio_task_runner(), | 699 context_->audio_task_runner(), |
673 context_->network_task_runner(), | 700 context_->network_task_runner(), |
674 context_->video_capture_task_runner(), | 701 context_->video_capture_task_runner(), |
675 context_->network_task_runner(), | 702 context_->network_task_runner(), |
676 daemon_channel_.get()); | 703 daemon_channel_.get()); |
677 desktop_session_connector_ = desktop_environment_factory; | 704 desktop_session_connector_ = desktop_environment_factory; |
678 #else // !defined(OS_WIN) | 705 #else // !defined(OS_WIN) |
679 DesktopEnvironmentFactory* desktop_environment_factory = | 706 DesktopEnvironmentFactory* desktop_environment_factory; |
707 if (enable_window_capture_) { | |
708 desktop_environment_factory = | |
709 new SingleWindowDesktopEnvironmentFactory( | |
710 context_->network_task_runner(), | |
711 context_->input_task_runner(), | |
712 context_->ui_task_runner(), | |
713 window_id_); | |
714 } else { | |
715 desktop_environment_factory = | |
680 new Me2MeDesktopEnvironmentFactory( | 716 new Me2MeDesktopEnvironmentFactory( |
681 context_->network_task_runner(), | 717 context_->network_task_runner(), |
682 context_->input_task_runner(), | 718 context_->input_task_runner(), |
683 context_->ui_task_runner()); | 719 context_->ui_task_runner()); |
720 } | |
684 #endif // !defined(OS_WIN) | 721 #endif // !defined(OS_WIN) |
685 | 722 |
686 desktop_environment_factory_.reset(desktop_environment_factory); | 723 desktop_environment_factory_.reset(desktop_environment_factory); |
687 desktop_environment_factory_->SetEnableGnubbyAuth(enable_gnubby_auth_); | 724 desktop_environment_factory_->SetEnableGnubbyAuth(enable_gnubby_auth_); |
688 | 725 |
689 context_->network_task_runner()->PostTask( | 726 context_->network_task_runner()->PostTask( |
690 FROM_HERE, | 727 FROM_HERE, |
691 base::Bind(&HostProcess::StartOnNetworkThread, this)); | 728 base::Bind(&HostProcess::StartOnNetworkThread, this)); |
692 } | 729 } |
693 | 730 |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1375 return exit_code; | 1412 return exit_code; |
1376 } | 1413 } |
1377 | 1414 |
1378 } // namespace remoting | 1415 } // namespace remoting |
1379 | 1416 |
1380 #if !defined(OS_WIN) | 1417 #if !defined(OS_WIN) |
1381 int main(int argc, char** argv) { | 1418 int main(int argc, char** argv) { |
1382 return remoting::HostMain(argc, argv); | 1419 return remoting::HostMain(argc, argv); |
1383 } | 1420 } |
1384 #endif // !defined(OS_WIN) | 1421 #endif // !defined(OS_WIN) |
OLD | NEW |