Chromium Code Reviews| Index: remoting/host/session_manager_factory.cc |
| diff --git a/remoting/host/session_manager_factory.cc b/remoting/host/session_manager_factory.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8c40f669463124620f474d0d64cd055c12a94161 |
| --- /dev/null |
| +++ b/remoting/host/session_manager_factory.cc |
| @@ -0,0 +1,45 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "remoting/host/session_manager_factory.h" |
| + |
| +#include "net/url_request/url_request_context_getter.h" |
| +#include "remoting/host/host_port_allocator.h" |
| +#include "remoting/host/network_settings.h" |
| +#include "remoting/protocol/libjingle_transport_factory.h" |
| +#include "remoting/protocol/jingle_session_manager.h" |
| + |
| +namespace remoting { |
| + |
| +scoped_ptr<protocol::SessionManager> CreateHostSessionManager( |
| + const NetworkSettings& network_settings, |
| + const scoped_refptr<net::URLRequestContextGetter>& |
| + url_request_context_getter) { |
| + // Use Chrome's network stack to allocate ports for peer-to-peer channels. |
| + scoped_ptr<HostPortAllocator> port_allocator( |
| + HostPortAllocator::Create(url_request_context_getter, |
| + network_settings)); |
| + |
| + // Use libjingle for negotiation of peer-to-peer channels over |
| + // HostPortAllocator allocated ports. |
|
Sergey Ulanov
2012/06/14 18:24:30
nit: this comment is confusing here. Move it below
simonmorris
2012/06/15 15:56:49
Done.
|
| + bool incoming_only = network_settings.nat_traversal_mode == |
| + NetworkSettings::NAT_TRAVERSAL_DISABLED; |
| + |
| + scoped_ptr<protocol::TransportFactory> transport_factory( |
| + new protocol::LibjingleTransportFactory( |
| + port_allocator.PassAs<cricket::HttpPortAllocatorBase>(), |
| + incoming_only)); |
| + |
| + // Use the Jingle protocol for channel-negotiation signalling between |
| + // peer TransportFactories. |
| + bool fetch_stun_relay_info = network_settings.nat_traversal_mode == |
| + NetworkSettings::NAT_TRAVERSAL_ENABLED; |
| + |
| + scoped_ptr<protocol::JingleSessionManager> session_manager( |
| + new protocol::JingleSessionManager( |
| + transport_factory.Pass(), fetch_stun_relay_info)); |
| + return session_manager.PassAs<protocol::SessionManager>(); |
| +} |
| + |
| +} // namespace remoting |