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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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/token_validator_factory_impl.h" | 68 #include "remoting/host/token_validator_factory_impl.h" |
69 #include "remoting/host/usage_stats_consent.h" | 69 #include "remoting/host/usage_stats_consent.h" |
70 #include "remoting/host/username.h" | 70 #include "remoting/host/username.h" |
| 71 #include "remoting/host/video_frame_recorder_host_extension.h" |
71 #include "remoting/protocol/me2me_host_authenticator_factory.h" | 72 #include "remoting/protocol/me2me_host_authenticator_factory.h" |
72 #include "remoting/protocol/network_settings.h" | 73 #include "remoting/protocol/network_settings.h" |
73 #include "remoting/protocol/pairing_registry.h" | 74 #include "remoting/protocol/pairing_registry.h" |
74 #include "remoting/protocol/token_validator.h" | 75 #include "remoting/protocol/token_validator.h" |
75 #include "remoting/signaling/xmpp_signal_strategy.h" | 76 #include "remoting/signaling/xmpp_signal_strategy.h" |
76 | 77 |
77 #if defined(OS_POSIX) | 78 #if defined(OS_POSIX) |
78 #include <signal.h> | 79 #include <signal.h> |
79 #include <sys/types.h> | 80 #include <sys/types.h> |
80 #include <unistd.h> | 81 #include <unistd.h> |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 const char kAuthSocknameSwitchName[] = "ssh-auth-sockname"; | 119 const char kAuthSocknameSwitchName[] = "ssh-auth-sockname"; |
119 #endif // defined(OS_LINUX) | 120 #endif // defined(OS_LINUX) |
120 | 121 |
121 // The command line switch used by the parent to request the host to signal it | 122 // The command line switch used by the parent to request the host to signal it |
122 // when it is successfully started. | 123 // when it is successfully started. |
123 const char kSignalParentSwitchName[] = "signal-parent"; | 124 const char kSignalParentSwitchName[] = "signal-parent"; |
124 | 125 |
125 // Command line switch used to enable VP9 encoding. | 126 // Command line switch used to enable VP9 encoding. |
126 const char kEnableVp9SwitchName[] = "enable-vp9"; | 127 const char kEnableVp9SwitchName[] = "enable-vp9"; |
127 | 128 |
| 129 // Command line switch used to enable and configure the frame-recorder. |
| 130 const char kFrameRecorderBufferKbName[] = "frame-recorder-buffer-kb"; |
| 131 |
128 // Value used for --host-config option to indicate that the path must be read | 132 // Value used for --host-config option to indicate that the path must be read |
129 // from stdin. | 133 // from stdin. |
130 const char kStdinConfigPath[] = "-"; | 134 const char kStdinConfigPath[] = "-"; |
131 | 135 |
132 } // namespace | 136 } // namespace |
133 | 137 |
134 namespace remoting { | 138 namespace remoting { |
135 | 139 |
136 class HostProcess | 140 class HostProcess |
137 : public ConfigWatcher::Delegate, | 141 : public ConfigWatcher::Delegate, |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 scoped_ptr<ConfigWatcher> config_watcher_; | 286 scoped_ptr<ConfigWatcher> config_watcher_; |
283 | 287 |
284 std::string host_id_; | 288 std::string host_id_; |
285 protocol::SharedSecretHash host_secret_hash_; | 289 protocol::SharedSecretHash host_secret_hash_; |
286 scoped_refptr<RsaKeyPair> key_pair_; | 290 scoped_refptr<RsaKeyPair> key_pair_; |
287 std::string oauth_refresh_token_; | 291 std::string oauth_refresh_token_; |
288 std::string serialized_config_; | 292 std::string serialized_config_; |
289 std::string host_owner_; | 293 std::string host_owner_; |
290 bool use_service_account_; | 294 bool use_service_account_; |
291 bool enable_vp9_; | 295 bool enable_vp9_; |
| 296 int64_t frame_recorder_buffer_size_; |
292 | 297 |
293 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_; | 298 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_; |
294 std::string host_domain_; | 299 std::string host_domain_; |
295 bool host_username_match_required_; | 300 bool host_username_match_required_; |
296 bool allow_nat_traversal_; | 301 bool allow_nat_traversal_; |
297 bool allow_relay_; | 302 bool allow_relay_; |
298 int min_udp_port_; | 303 int min_udp_port_; |
299 int max_udp_port_; | 304 int max_udp_port_; |
300 std::string talkgadget_prefix_; | 305 std::string talkgadget_prefix_; |
301 bool allow_pairing_; | 306 bool allow_pairing_; |
(...skipping 25 matching lines...) Expand all Loading... |
327 | 332 |
328 scoped_ptr<PairingRegistry::Delegate> pairing_registry_delegate_; | 333 scoped_ptr<PairingRegistry::Delegate> pairing_registry_delegate_; |
329 }; | 334 }; |
330 | 335 |
331 HostProcess::HostProcess(scoped_ptr<ChromotingHostContext> context, | 336 HostProcess::HostProcess(scoped_ptr<ChromotingHostContext> context, |
332 int* exit_code_out) | 337 int* exit_code_out) |
333 : context_(context.Pass()), | 338 : context_(context.Pass()), |
334 state_(HOST_INITIALIZING), | 339 state_(HOST_INITIALIZING), |
335 use_service_account_(false), | 340 use_service_account_(false), |
336 enable_vp9_(false), | 341 enable_vp9_(false), |
| 342 frame_recorder_buffer_size_(0), |
337 host_username_match_required_(false), | 343 host_username_match_required_(false), |
338 allow_nat_traversal_(true), | 344 allow_nat_traversal_(true), |
339 allow_relay_(true), | 345 allow_relay_(true), |
340 min_udp_port_(0), | 346 min_udp_port_(0), |
341 max_udp_port_(0), | 347 max_udp_port_(0), |
342 allow_pairing_(true), | 348 allow_pairing_(true), |
343 curtain_required_(false), | 349 curtain_required_(false), |
344 enable_gnubby_auth_(false), | 350 enable_gnubby_auth_(false), |
345 #if defined(REMOTING_MULTI_PROCESS) | 351 #if defined(REMOTING_MULTI_PROCESS) |
346 desktop_session_connector_(NULL), | 352 desktop_session_connector_(NULL), |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 use_service_account_ = false; | 826 use_service_account_ = false; |
821 } | 827 } |
822 | 828 |
823 // Allow offering of VP9 encoding to be overridden by the command-line. | 829 // Allow offering of VP9 encoding to be overridden by the command-line. |
824 if (CommandLine::ForCurrentProcess()->HasSwitch(kEnableVp9SwitchName)) { | 830 if (CommandLine::ForCurrentProcess()->HasSwitch(kEnableVp9SwitchName)) { |
825 enable_vp9_ = true; | 831 enable_vp9_ = true; |
826 } else { | 832 } else { |
827 config->GetBoolean(kEnableVp9ConfigPath, &enable_vp9_); | 833 config->GetBoolean(kEnableVp9ConfigPath, &enable_vp9_); |
828 } | 834 } |
829 | 835 |
| 836 // Allow the command-line to override the size of the frame recorder buffer. |
| 837 std::string frame_recorder_buffer_kb; |
| 838 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 839 kFrameRecorderBufferKbName)) { |
| 840 frame_recorder_buffer_kb = |
| 841 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 842 kFrameRecorderBufferKbName); |
| 843 } else { |
| 844 config->GetString(kFrameRecorderBufferKbConfigPath, |
| 845 &frame_recorder_buffer_kb); |
| 846 } |
| 847 if (!frame_recorder_buffer_kb.empty()) { |
| 848 int buffer_kb = 0; |
| 849 if (base::StringToInt(frame_recorder_buffer_kb, &buffer_kb)) { |
| 850 frame_recorder_buffer_size_ = 1024LL * buffer_kb; |
| 851 } |
| 852 } |
| 853 |
830 return true; | 854 return true; |
831 } | 855 } |
832 | 856 |
833 void HostProcess::OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies) { | 857 void HostProcess::OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies) { |
834 if (!context_->network_task_runner()->BelongsToCurrentThread()) { | 858 if (!context_->network_task_runner()->BelongsToCurrentThread()) { |
835 context_->network_task_runner()->PostTask(FROM_HERE, base::Bind( | 859 context_->network_task_runner()->PostTask(FROM_HERE, base::Bind( |
836 &HostProcess::OnPolicyUpdate, this, base::Passed(&policies))); | 860 &HostProcess::OnPolicyUpdate, this, base::Passed(&policies))); |
837 return; | 861 return; |
838 } | 862 } |
839 | 863 |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1200 context_->network_task_runner(), | 1224 context_->network_task_runner(), |
1201 context_->ui_task_runner())); | 1225 context_->ui_task_runner())); |
1202 | 1226 |
1203 if (enable_vp9_) { | 1227 if (enable_vp9_) { |
1204 scoped_ptr<protocol::CandidateSessionConfig> config = | 1228 scoped_ptr<protocol::CandidateSessionConfig> config = |
1205 host_->protocol_config()->Clone(); | 1229 host_->protocol_config()->Clone(); |
1206 config->EnableVideoCodec(protocol::ChannelConfig::CODEC_VP9); | 1230 config->EnableVideoCodec(protocol::ChannelConfig::CODEC_VP9); |
1207 host_->set_protocol_config(config.Pass()); | 1231 host_->set_protocol_config(config.Pass()); |
1208 } | 1232 } |
1209 | 1233 |
| 1234 if (frame_recorder_buffer_size_ > 0) { |
| 1235 scoped_ptr<VideoFrameRecorderHostExtension> frame_recorder_extension( |
| 1236 new VideoFrameRecorderHostExtension()); |
| 1237 frame_recorder_extension->SetMaxContentBytes(frame_recorder_buffer_size_); |
| 1238 host_->AddExtension(frame_recorder_extension.PassAs<HostExtension>()); |
| 1239 } |
| 1240 |
1210 // TODO(simonmorris): Get the maximum session duration from a policy. | 1241 // TODO(simonmorris): Get the maximum session duration from a policy. |
1211 #if defined(OS_LINUX) | 1242 #if defined(OS_LINUX) |
1212 host_->SetMaximumSessionDuration(base::TimeDelta::FromHours(20)); | 1243 host_->SetMaximumSessionDuration(base::TimeDelta::FromHours(20)); |
1213 #endif | 1244 #endif |
1214 | 1245 |
1215 heartbeat_sender_.reset(new HeartbeatSender( | 1246 heartbeat_sender_.reset(new HeartbeatSender( |
1216 this, host_id_, signal_strategy_.get(), key_pair_, | 1247 this, host_id_, signal_strategy_.get(), key_pair_, |
1217 directory_bot_jid_)); | 1248 directory_bot_jid_)); |
1218 | 1249 |
1219 host_status_sender_.reset(new HostStatusSender( | 1250 host_status_sender_.reset(new HostStatusSender( |
1220 host_id_, signal_strategy_.get(), key_pair_, directory_bot_jid_)); | 1251 host_id_, signal_strategy_.get(), key_pair_, directory_bot_jid_)); |
1221 | 1252 |
1222 host_change_notification_listener_.reset(new HostChangeNotificationListener( | 1253 host_change_notification_listener_.reset(new HostChangeNotificationListener( |
1223 this, host_id_, signal_strategy_.get(), directory_bot_jid_)); | 1254 this, host_id_, signal_strategy_.get(), directory_bot_jid_)); |
1224 | 1255 |
1225 host_status_logger_.reset( | 1256 host_status_logger_.reset( |
1226 new HostStatusLogger(host_->AsWeakPtr(), ServerLogEntry::ME2ME, | 1257 new HostStatusLogger(host_->AsWeakPtr(), ServerLogEntry::ME2ME, |
1227 signal_strategy_.get(), directory_bot_jid_)); | 1258 signal_strategy_.get(), directory_bot_jid_)); |
1228 | 1259 |
1229 // Set up repoting the host status notifications. | 1260 // Set up reporting the host status notifications. |
1230 #if defined(REMOTING_MULTI_PROCESS) | 1261 #if defined(REMOTING_MULTI_PROCESS) |
1231 host_event_logger_.reset( | 1262 host_event_logger_.reset( |
1232 new IpcHostEventLogger(host_->AsWeakPtr(), daemon_channel_.get())); | 1263 new IpcHostEventLogger(host_->AsWeakPtr(), daemon_channel_.get())); |
1233 #else // !defined(REMOTING_MULTI_PROCESS) | 1264 #else // !defined(REMOTING_MULTI_PROCESS) |
1234 host_event_logger_ = | 1265 host_event_logger_ = |
1235 HostEventLogger::Create(host_->AsWeakPtr(), kApplicationName); | 1266 HostEventLogger::Create(host_->AsWeakPtr(), kApplicationName); |
1236 #endif // !defined(REMOTING_MULTI_PROCESS) | 1267 #endif // !defined(REMOTING_MULTI_PROCESS) |
1237 | 1268 |
1238 host_->SetEnableCurtaining(curtain_required_); | 1269 host_->SetEnableCurtaining(curtain_required_); |
1239 host_->Start(host_owner_); | 1270 host_->Start(host_owner_); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1371 int exit_code = kSuccessExitCode; | 1402 int exit_code = kSuccessExitCode; |
1372 new HostProcess(context.Pass(), &exit_code); | 1403 new HostProcess(context.Pass(), &exit_code); |
1373 | 1404 |
1374 // Run the main (also UI) message loop until the host no longer needs it. | 1405 // Run the main (also UI) message loop until the host no longer needs it. |
1375 message_loop.Run(); | 1406 message_loop.Run(); |
1376 | 1407 |
1377 return exit_code; | 1408 return exit_code; |
1378 } | 1409 } |
1379 | 1410 |
1380 } // namespace remoting | 1411 } // namespace remoting |
OLD | NEW |