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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 #include "remoting/host/host_main.h" | 56 #include "remoting/host/host_main.h" |
57 #include "remoting/host/host_status_logger.h" | 57 #include "remoting/host/host_status_logger.h" |
58 #include "remoting/host/input_injector.h" | 58 #include "remoting/host/input_injector.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/logging.h" | 61 #include "remoting/host/logging.h" |
62 #include "remoting/host/me2me_desktop_environment.h" | 62 #include "remoting/host/me2me_desktop_environment.h" |
63 #include "remoting/host/oauth_token_getter_impl.h" | 63 #include "remoting/host/oauth_token_getter_impl.h" |
64 #include "remoting/host/pairing_registry_delegate.h" | 64 #include "remoting/host/pairing_registry_delegate.h" |
65 #include "remoting/host/policy_watcher.h" | 65 #include "remoting/host/policy_watcher.h" |
66 #include "remoting/host/session_manager_factory.h" | |
67 #include "remoting/host/shutdown_watchdog.h" | 66 #include "remoting/host/shutdown_watchdog.h" |
68 #include "remoting/host/signaling_connector.h" | 67 #include "remoting/host/signaling_connector.h" |
69 #include "remoting/host/single_window_desktop_environment.h" | 68 #include "remoting/host/single_window_desktop_environment.h" |
70 #include "remoting/host/switches.h" | 69 #include "remoting/host/switches.h" |
71 #include "remoting/host/third_party_auth_config.h" | 70 #include "remoting/host/third_party_auth_config.h" |
72 #include "remoting/host/token_validator_factory_impl.h" | 71 #include "remoting/host/token_validator_factory_impl.h" |
73 #include "remoting/host/usage_stats_consent.h" | 72 #include "remoting/host/usage_stats_consent.h" |
74 #include "remoting/host/username.h" | 73 #include "remoting/host/username.h" |
75 #include "remoting/host/video_frame_recorder_host_extension.h" | 74 #include "remoting/host/video_frame_recorder_host_extension.h" |
76 #include "remoting/protocol/authenticator.h" | 75 #include "remoting/protocol/authenticator.h" |
77 #include "remoting/protocol/channel_authenticator.h" | 76 #include "remoting/protocol/channel_authenticator.h" |
78 #include "remoting/protocol/chromium_port_allocator_factory.h" | 77 #include "remoting/protocol/chromium_port_allocator.h" |
| 78 #include "remoting/protocol/ice_transport.h" |
79 #include "remoting/protocol/jingle_session_manager.h" | 79 #include "remoting/protocol/jingle_session_manager.h" |
80 #include "remoting/protocol/me2me_host_authenticator_factory.h" | 80 #include "remoting/protocol/me2me_host_authenticator_factory.h" |
81 #include "remoting/protocol/network_settings.h" | 81 #include "remoting/protocol/network_settings.h" |
82 #include "remoting/protocol/pairing_registry.h" | 82 #include "remoting/protocol/pairing_registry.h" |
83 #include "remoting/protocol/port_range.h" | 83 #include "remoting/protocol/port_range.h" |
84 #include "remoting/protocol/token_validator.h" | 84 #include "remoting/protocol/token_validator.h" |
| 85 #include "remoting/protocol/transport_context.h" |
85 #include "remoting/protocol/webrtc_transport.h" | 86 #include "remoting/protocol/webrtc_transport.h" |
86 #include "remoting/signaling/push_notification_subscriber.h" | 87 #include "remoting/signaling/push_notification_subscriber.h" |
87 #include "remoting/signaling/xmpp_signal_strategy.h" | 88 #include "remoting/signaling/xmpp_signal_strategy.h" |
88 #include "third_party/webrtc/base/scoped_ref_ptr.h" | 89 #include "third_party/webrtc/base/scoped_ref_ptr.h" |
89 | 90 |
90 #if defined(OS_POSIX) | 91 #if defined(OS_POSIX) |
91 #include <signal.h> | 92 #include <signal.h> |
92 #include <sys/types.h> | 93 #include <sys/types.h> |
93 #include <unistd.h> | 94 #include <unistd.h> |
94 #include "base/file_descriptor_posix.h" | 95 #include "base/file_descriptor_posix.h" |
(...skipping 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1489 if (!udp_port_range_.is_null()) { | 1490 if (!udp_port_range_.is_null()) { |
1490 network_settings.port_range = udp_port_range_; | 1491 network_settings.port_range = udp_port_range_; |
1491 } else if (!allow_nat_traversal_) { | 1492 } else if (!allow_nat_traversal_) { |
1492 // For legacy reasons we have to restrict the port range to a set of default | 1493 // For legacy reasons we have to restrict the port range to a set of default |
1493 // values when nat traversal is disabled, even if the port range was not | 1494 // values when nat traversal is disabled, even if the port range was not |
1494 // set in policy. | 1495 // set in policy. |
1495 network_settings.port_range.min_port = NetworkSettings::kDefaultMinPort; | 1496 network_settings.port_range.min_port = NetworkSettings::kDefaultMinPort; |
1496 network_settings.port_range.max_port = NetworkSettings::kDefaultMaxPort; | 1497 network_settings.port_range.max_port = NetworkSettings::kDefaultMaxPort; |
1497 } | 1498 } |
1498 | 1499 |
1499 scoped_ptr<protocol::SessionManager> session_manager; | 1500 scoped_refptr<protocol::TransportContext> transport_context = |
| 1501 new protocol::TransportContext( |
| 1502 signal_strategy_.get(), |
| 1503 make_scoped_ptr(new protocol::ChromiumPortAllocatorFactory( |
| 1504 context_->url_request_context_getter())), |
| 1505 network_settings, protocol::TransportRole::SERVER); |
| 1506 scoped_ptr<protocol::TransportFactory> transport_factory; |
1500 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kEnableWebrtc)) { | 1507 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kEnableWebrtc)) { |
1501 #if !defined(NDEBUG) | 1508 #if !defined(NDEBUG) |
1502 network_settings.flags = protocol::NetworkSettings::NAT_TRAVERSAL_OUTGOING; | |
1503 | |
1504 scoped_ptr<protocol::PortAllocatorFactory> port_allocator_factory = | |
1505 protocol::ChromiumPortAllocatorFactory::Create( | |
1506 network_settings, context_->url_request_context_getter()); | |
1507 | |
1508 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); | 1509 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); |
1509 | 1510 |
1510 // The network thread is also used as worker thread for webrtc. | 1511 // The network thread is also used as worker thread for webrtc. |
1511 // | 1512 // |
1512 // TODO(sergeyu): Figure out if we would benefit from using a separate | 1513 // TODO(sergeyu): Figure out if we would benefit from using a separate |
1513 // thread as a worker thread. | 1514 // thread as a worker thread. |
1514 scoped_ptr<protocol::TransportFactory> transport_factory( | 1515 transport_factory.reset(new protocol::WebrtcTransportFactory( |
1515 new protocol::WebrtcTransportFactory( | 1516 jingle_glue::JingleThreadWrapper::current(), transport_context)); |
1516 jingle_glue::JingleThreadWrapper::current(), signal_strategy_.get(), | |
1517 std::move(port_allocator_factory), | |
1518 protocol::TransportRole::SERVER)); | |
1519 | |
1520 session_manager.reset( | |
1521 new protocol::JingleSessionManager(transport_factory.Pass())); | |
1522 #else // !defined(NDEBUG) | 1517 #else // !defined(NDEBUG) |
1523 LOG(ERROR) << "WebRTC is enabled only in debug builds."; | 1518 LOG(ERROR) << "WebRTC is enabled only in debug builds."; |
1524 ShutdownHost(kUsageExitCode); | 1519 ShutdownHost(kUsageExitCode); |
1525 return; | 1520 return; |
1526 #endif // defined(NDEBUG) | 1521 #endif // defined(NDEBUG) |
1527 } else { | 1522 } else { |
1528 session_manager = | 1523 transport_factory.reset( |
1529 CreateHostSessionManager(signal_strategy_.get(), network_settings, | 1524 new protocol::IceTransportFactory(transport_context)); |
1530 context_->url_request_context_getter()); | |
1531 } | 1525 } |
| 1526 scoped_ptr<protocol::SessionManager> session_manager( |
| 1527 new protocol::JingleSessionManager(transport_factory.Pass())); |
1532 | 1528 |
1533 scoped_ptr<protocol::CandidateSessionConfig> protocol_config = | 1529 scoped_ptr<protocol::CandidateSessionConfig> protocol_config = |
1534 protocol::CandidateSessionConfig::CreateDefault(); | 1530 protocol::CandidateSessionConfig::CreateDefault(); |
1535 if (!desktop_environment_factory_->SupportsAudioCapture()) | 1531 if (!desktop_environment_factory_->SupportsAudioCapture()) |
1536 protocol_config->DisableAudioChannel(); | 1532 protocol_config->DisableAudioChannel(); |
1537 if (enable_vp9_) | 1533 if (enable_vp9_) |
1538 protocol_config->set_vp9_experiment_enabled(true); | 1534 protocol_config->set_vp9_experiment_enabled(true); |
1539 #if !defined(NDEBUG) | 1535 #if !defined(NDEBUG) |
1540 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kEnableWebrtc)) { | 1536 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kEnableWebrtc)) { |
1541 protocol_config->set_webrtc_supported(true); | 1537 protocol_config->set_webrtc_supported(true); |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1751 base::TimeDelta::FromSeconds(kShutdownTimeoutSeconds)); | 1747 base::TimeDelta::FromSeconds(kShutdownTimeoutSeconds)); |
1752 new HostProcess(context.Pass(), &exit_code, &shutdown_watchdog); | 1748 new HostProcess(context.Pass(), &exit_code, &shutdown_watchdog); |
1753 | 1749 |
1754 // Run the main (also UI) message loop until the host no longer needs it. | 1750 // Run the main (also UI) message loop until the host no longer needs it. |
1755 message_loop.Run(); | 1751 message_loop.Run(); |
1756 | 1752 |
1757 return exit_code; | 1753 return exit_code; |
1758 } | 1754 } |
1759 | 1755 |
1760 } // namespace remoting | 1756 } // namespace remoting |
OLD | NEW |