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 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 const char kVideoSwitchName[] = "video"; | 78 const char kVideoSwitchName[] = "video"; |
| 79 const char kDisableNatTraversalSwitchName[] = "disable-nat-traversal"; | 79 const char kDisableNatTraversalSwitchName[] = "disable-nat-traversal"; |
| 80 const char kMinPortSwitchName[] = "min-port"; | 80 const char kMinPortSwitchName[] = "min-port"; |
| 81 const char kMaxPortSwitchName[] = "max-port"; | 81 const char kMaxPortSwitchName[] = "max-port"; |
| 82 | 82 |
| 83 const char kVideoSwitchValueVerbatim[] = "verbatim"; | 83 const char kVideoSwitchValueVerbatim[] = "verbatim"; |
| 84 const char kVideoSwitchValueZip[] = "zip"; | 84 const char kVideoSwitchValueZip[] = "zip"; |
| 85 const char kVideoSwitchValueVp8[] = "vp8"; | 85 const char kVideoSwitchValueVp8[] = "vp8"; |
| 86 const char kVideoSwitchValueVp8Rtp[] = "vp8rtp"; | 86 const char kVideoSwitchValueVp8Rtp[] = "vp8rtp"; |
| 87 | 87 |
| 88 const int kDefaultMinPortNumber = 12400; | |
| 89 const int kDefaultMaxPortNumber = 12409; | |
|
Wez
2012/03/07 01:56:13
nit: Not part of this CL?
alexeypa (please no reviews)
2012/03/07 19:59:08
Done.
| |
| 90 | |
| 88 } // namespace | 91 } // namespace |
| 89 | 92 |
| 90 namespace remoting { | 93 namespace remoting { |
| 91 | 94 |
| 92 class SimpleHost { | 95 class SimpleHost { |
| 93 public: | 96 public: |
| 94 SimpleHost() | 97 SimpleHost() |
| 95 : message_loop_(MessageLoop::TYPE_UI), | 98 : message_loop_(MessageLoop::TYPE_UI), |
| 96 file_io_thread_("FileIO"), | 99 file_io_thread_("FileIO"), |
| 97 context_(message_loop_.message_loop_proxy()), | 100 context_(NULL, message_loop_.message_loop_proxy()), |
| 98 fake_(false), | 101 fake_(false), |
| 99 is_it2me_(false) { | 102 is_it2me_(false) { |
| 100 context_.Start(); | 103 context_.Start(); |
| 101 file_io_thread_.Start(); | 104 file_io_thread_.Start(); |
| 102 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); | 105 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); |
| 103 } | 106 } |
| 104 | 107 |
| 105 int Run() { | 108 int Run() { |
| 106 FilePath config_path = GetConfigPath(); | 109 FilePath config_path = GetConfigPath(); |
| 107 scoped_refptr<JsonHostConfig> config = new JsonHostConfig( | 110 scoped_refptr<JsonHostConfig> config = new JsonHostConfig( |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 | 213 |
| 211 void StartHost() { | 214 void StartHost() { |
| 212 signal_strategy_.reset( | 215 signal_strategy_.reset( |
| 213 new XmppSignalStrategy(context_.jingle_thread(), xmpp_login_, | 216 new XmppSignalStrategy(context_.jingle_thread(), xmpp_login_, |
| 214 xmpp_auth_token_, xmpp_auth_service_)); | 217 xmpp_auth_token_, xmpp_auth_service_)); |
| 215 signaling_connector_.reset(new SignalingConnector(signal_strategy_.get())); | 218 signaling_connector_.reset(new SignalingConnector(signal_strategy_.get())); |
| 216 | 219 |
| 217 if (fake_) { | 220 if (fake_) { |
| 218 Capturer* capturer = new CapturerFake(); | 221 Capturer* capturer = new CapturerFake(); |
| 219 EventExecutor* event_executor = | 222 EventExecutor* event_executor = |
| 220 EventExecutor::Create(context_.desktop_message_loop(), capturer); | 223 EventExecutor::Create(context_.desktop_message_loop(), NULL, |
| 224 capturer); | |
| 221 desktop_environment_.reset( | 225 desktop_environment_.reset( |
| 222 new DesktopEnvironment(&context_, capturer, event_executor)); | 226 new DesktopEnvironment(&context_, capturer, event_executor)); |
| 223 } else { | 227 } else { |
| 224 desktop_environment_.reset(DesktopEnvironment::Create(&context_)); | 228 desktop_environment_.reset(DesktopEnvironment::Create(&context_)); |
| 225 } | 229 } |
| 226 | 230 |
| 227 host_ = new ChromotingHost(&context_, signal_strategy_.get(), | 231 host_ = new ChromotingHost(&context_, signal_strategy_.get(), |
| 228 desktop_environment_.get(), network_settings_); | 232 desktop_environment_.get(), network_settings_); |
| 229 | 233 |
| 230 ServerLogEntry::Mode mode = | 234 ServerLogEntry::Mode mode = |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 353 std::string min_port_str = | 357 std::string min_port_str = |
| 354 cmd_line->GetSwitchValueASCII(kMinPortSwitchName); | 358 cmd_line->GetSwitchValueASCII(kMinPortSwitchName); |
| 355 int min_port = 0; | 359 int min_port = 0; |
| 356 if (!base::StringToInt(min_port_str, &min_port) || | 360 if (!base::StringToInt(min_port_str, &min_port) || |
| 357 min_port < 0 || min_port > 65535) { | 361 min_port < 0 || min_port > 65535) { |
| 358 LOG(ERROR) << "Invalid min-port value: " << min_port | 362 LOG(ERROR) << "Invalid min-port value: " << min_port |
| 359 << ". Expected integer in range [0, 65535]."; | 363 << ". Expected integer in range [0, 65535]."; |
| 360 return 1; | 364 return 1; |
| 361 } | 365 } |
| 362 simple_host.network_settings()->min_port = min_port; | 366 simple_host.network_settings()->min_port = min_port; |
| 367 } else { | |
| 368 simple_host.network_settings()->min_port = kDefaultMinPortNumber; | |
| 363 } | 369 } |
| 364 | 370 |
| 365 if (cmd_line->HasSwitch(kMaxPortSwitchName)) { | 371 if (cmd_line->HasSwitch(kMaxPortSwitchName)) { |
| 366 std::string max_port_str = | 372 std::string max_port_str = |
| 367 cmd_line->GetSwitchValueASCII(kMaxPortSwitchName); | 373 cmd_line->GetSwitchValueASCII(kMaxPortSwitchName); |
| 368 int max_port = 0; | 374 int max_port = 0; |
| 369 if (!base::StringToInt(max_port_str, &max_port) || | 375 if (!base::StringToInt(max_port_str, &max_port) || |
| 370 max_port < 0 || max_port > 65535) { | 376 max_port < 0 || max_port > 65535) { |
| 371 LOG(ERROR) << "Invalid max-port value: " << max_port | 377 LOG(ERROR) << "Invalid max-port value: " << max_port |
| 372 << ". Expected integer in range [0, 65535]."; | 378 << ". Expected integer in range [0, 65535]."; |
| 373 return 1; | 379 return 1; |
| 374 } | 380 } |
| 375 simple_host.network_settings()->max_port = max_port; | 381 simple_host.network_settings()->max_port = max_port; |
| 382 } else { | |
| 383 simple_host.network_settings()->max_port = kDefaultMaxPortNumber; | |
| 376 } | 384 } |
| 377 | 385 |
| 378 return simple_host.Run(); | 386 return simple_host.Run(); |
| 379 } | 387 } |
| OLD | NEW |