Commit 86030f38 authored by sergeyu's avatar sergeyu Committed by Commit bot

Add TransportContext class.

The new TransportContext is now used to store all parameters required
to initialize Transport objects and is applicable both to IceTransport
and WebrtcTransport. It also allowed to reduce amount of boilerplate
code when passing around these parameters.

BUG=547158

Review URL: https://codereview.chromium.org/1521883006

Cr-Commit-Position: refs/heads/master@{#365649}
parent 3b7c3e37
......@@ -18,7 +18,7 @@
#include "remoting/protocol/host_stub.h"
#include "remoting/protocol/negotiating_client_authenticator.h"
#include "remoting/protocol/session_config.h"
#include "remoting/protocol/transport.h"
#include "remoting/protocol/transport_context.h"
namespace remoting {
......@@ -56,7 +56,7 @@ void ChromotingClient::SetConnectionToHostForTests(
void ChromotingClient::Start(
SignalStrategy* signal_strategy,
scoped_ptr<protocol::Authenticator> authenticator,
scoped_ptr<protocol::TransportFactory> transport_factory,
scoped_refptr<protocol::TransportContext> transport_context,
const std::string& host_jid,
const std::string& capabilities) {
DCHECK(task_runner_->BelongsToCurrentThread());
......@@ -68,8 +68,8 @@ void ChromotingClient::Start(
connection_->set_video_stub(video_renderer_->GetVideoStub());
connection_->set_audio_stub(audio_decode_scheduler_.get());
connection_->Connect(signal_strategy, transport_factory.Pass(),
authenticator.Pass(), host_jid, this);
connection_->Connect(signal_strategy, transport_context, authenticator.Pass(),
host_jid, this);
}
void ChromotingClient::SetCapabilities(
......
......@@ -27,7 +27,7 @@ namespace remoting {
namespace protocol {
class CandidateSessionConfig;
class TransportFactory;
class TransportContext;
} // namespace protocol
class AudioDecodeScheduler;
......@@ -62,7 +62,7 @@ class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback,
// must outlive the client.
void Start(SignalStrategy* signal_strategy,
scoped_ptr<protocol::Authenticator> authenticator,
scoped_ptr<protocol::TransportFactory> transport_factory,
scoped_refptr<protocol::TransportContext> transport_context,
const std::string& host_jid,
const std::string& capabilities);
......
......@@ -21,10 +21,10 @@
#include "remoting/protocol/chromium_port_allocator.h"
#include "remoting/protocol/chromium_socket_factory.h"
#include "remoting/protocol/host_stub.h"
#include "remoting/protocol/ice_transport_factory.h"
#include "remoting/protocol/negotiating_client_authenticator.h"
#include "remoting/protocol/network_settings.h"
#include "remoting/protocol/performance_tracker.h"
#include "remoting/protocol/transport_context.h"
#include "remoting/signaling/server_log_entry.h"
#include "ui/events/keycodes/dom/keycode_converter.h"
......@@ -423,17 +423,17 @@ void ChromotingJniInstance::ConnectToHostOnNetworkThread() {
protocol::NetworkSettings::NAT_TRAVERSAL_FULL);
// Use Chrome's network stack to allocate ports for peer-to-peer channels.
scoped_ptr<protocol::ChromiumPortAllocator> port_allocator(
protocol::ChromiumPortAllocator::Create(jni_runtime_->url_requester(),
network_settings));
scoped_ptr<protocol::ChromiumPortAllocatorFactory> port_allocator_factory(
new protocol::ChromiumPortAllocatorFactory(
jni_runtime_->url_requester()));
scoped_ptr<protocol::TransportFactory> transport_factory(
new protocol::IceTransportFactory(
signaling_.get(), port_allocator.Pass(), network_settings,
protocol::TransportRole::CLIENT));
scoped_refptr<protocol::TransportContext> transport_context =
new protocol::TransportContext(
signaling_.get(), port_allocator_factory.Pass(), network_settings,
protocol::TransportRole::CLIENT);
client_->Start(signaling_.get(), authenticator_.Pass(),
transport_factory.Pass(), host_jid_, capabilities_);
client_->Start(signaling_.get(), authenticator_.Pass(), transport_context,
host_jid_, capabilities_);
}
void ChromotingJniInstance::FetchSecret(
......
......@@ -52,7 +52,7 @@
#include "remoting/client/token_fetcher_proxy.h"
#include "remoting/protocol/connection_to_host.h"
#include "remoting/protocol/host_stub.h"
#include "remoting/protocol/ice_transport_factory.h"
#include "remoting/protocol/transport_context.h"
#include "url/gurl.h"
namespace remoting {
......@@ -693,10 +693,11 @@ void ChromotingInstance::HandleConnect(const base::DictionaryValue& data) {
local_jid, base::Bind(&ChromotingInstance::SendOutgoingIq,
weak_factory_.GetWeakPtr())));
// Create TransportFactory.
scoped_ptr<protocol::TransportFactory> transport_factory(
new protocol::IceTransportFactory(
signal_strategy_.get(), PepperPortAllocator::Create(this).Pass(),
// Create TransportContext.
scoped_refptr<protocol::TransportContext> transport_context(
new protocol::TransportContext(
signal_strategy_.get(),
make_scoped_ptr(new PepperPortAllocatorFactory(this)),
protocol::NetworkSettings(
protocol::NetworkSettings::NAT_TRAVERSAL_FULL),
protocol::TransportRole::CLIENT));
......@@ -731,7 +732,7 @@ void ChromotingInstance::HandleConnect(const base::DictionaryValue& data) {
// Kick off the connection.
client_->Start(signal_strategy_.get(), authenticator.Pass(),
transport_factory.Pass(), host_jid, capabilities);
transport_context, host_jid, capabilities);
// Start timer that periodically sends perf stats.
stats_update_timer_.Start(
......
......@@ -225,17 +225,9 @@ PepperPortAllocator::PepperPortAllocator(
instance_(instance),
network_manager_(network_manager.Pass()),
socket_factory_(socket_factory.Pass()) {
// TCP transport is disabled becase PseudoTCP works poorly over
// it. ENABLE_SHARED_UFRAG flag is specified so that the same
// username fragment is shared between all candidates for this
// channel.
set_flags(cricket::PORTALLOCATOR_DISABLE_TCP |
cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG|
cricket::PORTALLOCATOR_ENABLE_IPV6);
}
PepperPortAllocator::~PepperPortAllocator() {
}
PepperPortAllocator::~PepperPortAllocator() {}
cricket::PortAllocatorSession* PepperPortAllocator::CreateSessionInternal(
const std::string& content_name,
......@@ -247,4 +239,15 @@ cricket::PortAllocatorSession* PepperPortAllocator::CreateSessionInternal(
stun_hosts(), relay_hosts(), relay_token(), instance_);
}
PepperPortAllocatorFactory::PepperPortAllocatorFactory(
const pp::InstanceHandle& instance)
: instance_(instance) {}
PepperPortAllocatorFactory::~PepperPortAllocatorFactory() {}
scoped_ptr<cricket::HttpPortAllocatorBase>
PepperPortAllocatorFactory::CreatePortAllocator() {
return PepperPortAllocator::Create(instance_);
}
} // namespace remoting
......@@ -8,6 +8,7 @@
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "ppapi/cpp/instance_handle.h"
#include "remoting/protocol/port_allocator_factory.h"
#include "third_party/webrtc/p2p/client/httpportallocator.h"
namespace remoting {
......@@ -47,6 +48,20 @@ class PepperPortAllocator : public cricket::HttpPortAllocatorBase {
DISALLOW_COPY_AND_ASSIGN(PepperPortAllocator);
};
class PepperPortAllocatorFactory : public protocol::PortAllocatorFactory {
public:
PepperPortAllocatorFactory(const pp::InstanceHandle& instance);
~PepperPortAllocatorFactory() override;
// PortAllocatorFactory interface.
scoped_ptr<cricket::HttpPortAllocatorBase> CreatePortAllocator() override;
private:
pp::InstanceHandle instance_;
DISALLOW_COPY_AND_ASSIGN(PepperPortAllocatorFactory);
};
} // namespace remoting
#endif // REMOTING_CLIENT_PLUGIN_PEPPER_PORT_ALLOCATOR_H_
......@@ -49,11 +49,6 @@ const char kWebRtcSDPMLineIndex[] = "sdpMLineIndex";
const char kVideoLabel[] = "cast_video_label";
const char kStreamLabel[] = "stream_label";
// Default STUN server used to construct
// ChromiumPortAllocator for the PeerConnection.
const char kDefaultStunHost[] = "stun.l.google.com";
const int kDefaultStunPort = 19302;
const char kWorkerThreadName[] = "CastExtensionSessionWorkerThread";
// Interval between each call to PollPeerConnectionStats().
......@@ -491,17 +486,14 @@ bool CastExtensionSession::InitializePeerConnection() {
constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
webrtc::MediaConstraintsInterface::kValueTrue);
rtc::scoped_ptr<protocol::ChromiumPortAllocator> port_allocator(
protocol::ChromiumPortAllocator::Create(url_request_context_getter_,
network_settings_)
.release());
std::vector<rtc::SocketAddress> stun_hosts;
stun_hosts.push_back(rtc::SocketAddress(kDefaultStunHost, kDefaultStunPort));
port_allocator->SetStunHosts(stun_hosts);
scoped_ptr<cricket::PortAllocator> port_allocator =
protocol::ChromiumPortAllocator::Create(url_request_context_getter_);
webrtc::PeerConnectionInterface::RTCConfiguration rtc_config;
peer_connection_ = peer_conn_factory_->CreatePeerConnection(
rtc_config, &constraints, port_allocator.Pass(), nullptr, this);
rtc_config, &constraints,
rtc::scoped_ptr<cricket::PortAllocator>(port_allocator.release()),
nullptr, this);
if (!peer_connection_.get()) {
CleanupPeerConnection();
......
......@@ -9,6 +9,7 @@
#include "base/strings/string_util.h"
#include "base/threading/platform_thread.h"
#include "net/socket/client_socket_factory.h"
#include "net/url_request/url_request_context_getter.h"
#include "policy/policy_constants.h"
#include "remoting/base/auto_thread.h"
#include "remoting/base/logging.h"
......@@ -22,9 +23,12 @@
#include "remoting/host/it2me_desktop_environment.h"
#include "remoting/host/policy_watcher.h"
#include "remoting/host/register_support_host_request.h"
#include "remoting/host/session_manager_factory.h"
#include "remoting/protocol/chromium_port_allocator.h"
#include "remoting/protocol/ice_transport.h"
#include "remoting/protocol/it2me_host_authenticator_factory.h"
#include "remoting/protocol/jingle_session_manager.h"
#include "remoting/protocol/network_settings.h"
#include "remoting/protocol/transport_context.h"
#include "remoting/signaling/server_log_entry.h"
namespace remoting {
......@@ -227,9 +231,16 @@ void It2MeHost::FinishConnect() {
protocol::NetworkSettings::kDefaultMaxPort;
}
scoped_ptr<protocol::SessionManager> session_manager =
CreateHostSessionManager(signal_strategy_.get(), network_settings,
host_context_->url_request_context_getter());
scoped_ptr<protocol::TransportFactory> transport_factory(
new protocol::IceTransportFactory(new protocol::TransportContext(
signal_strategy_.get(),
make_scoped_ptr(new protocol::ChromiumPortAllocatorFactory(
host_context_->url_request_context_getter())),
network_settings, protocol::TransportRole::SERVER)));
scoped_ptr<protocol::SessionManager> session_manager(
new protocol::JingleSessionManager(transport_factory.Pass()));
scoped_ptr<protocol::CandidateSessionConfig> protocol_config =
protocol::CandidateSessionConfig::CreateDefault();
// Disable audio by default.
......
......@@ -63,7 +63,6 @@
#include "remoting/host/oauth_token_getter_impl.h"
#include "remoting/host/pairing_registry_delegate.h"
#include "remoting/host/policy_watcher.h"
#include "remoting/host/session_manager_factory.h"
#include "remoting/host/shutdown_watchdog.h"
#include "remoting/host/signaling_connector.h"
#include "remoting/host/single_window_desktop_environment.h"
......@@ -75,13 +74,15 @@
#include "remoting/host/video_frame_recorder_host_extension.h"
#include "remoting/protocol/authenticator.h"
#include "remoting/protocol/channel_authenticator.h"
#include "remoting/protocol/chromium_port_allocator_factory.h"
#include "remoting/protocol/chromium_port_allocator.h"
#include "remoting/protocol/ice_transport.h"
#include "remoting/protocol/jingle_session_manager.h"
#include "remoting/protocol/me2me_host_authenticator_factory.h"
#include "remoting/protocol/network_settings.h"
#include "remoting/protocol/pairing_registry.h"
#include "remoting/protocol/port_range.h"
#include "remoting/protocol/token_validator.h"
#include "remoting/protocol/transport_context.h"
#include "remoting/protocol/webrtc_transport.h"
#include "remoting/signaling/push_notification_subscriber.h"
#include "remoting/signaling/xmpp_signal_strategy.h"
......@@ -1496,39 +1497,34 @@ void HostProcess::StartHost() {
network_settings.port_range.max_port = NetworkSettings::kDefaultMaxPort;
}
scoped_ptr<protocol::SessionManager> session_manager;
scoped_refptr<protocol::TransportContext> transport_context =
new protocol::TransportContext(
signal_strategy_.get(),
make_scoped_ptr(new protocol::ChromiumPortAllocatorFactory(
context_->url_request_context_getter())),
network_settings, protocol::TransportRole::SERVER);
scoped_ptr<protocol::TransportFactory> transport_factory;
if (base::CommandLine::ForCurrentProcess()->HasSwitch(kEnableWebrtc)) {
#if !defined(NDEBUG)
network_settings.flags = protocol::NetworkSettings::NAT_TRAVERSAL_OUTGOING;
scoped_ptr<protocol::PortAllocatorFactory> port_allocator_factory =
protocol::ChromiumPortAllocatorFactory::Create(
network_settings, context_->url_request_context_getter());
jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop();
// The network thread is also used as worker thread for webrtc.
//
// TODO(sergeyu): Figure out if we would benefit from using a separate
// thread as a worker thread.
scoped_ptr<protocol::TransportFactory> transport_factory(
new protocol::WebrtcTransportFactory(
jingle_glue::JingleThreadWrapper::current(), signal_strategy_.get(),
std::move(port_allocator_factory),
protocol::TransportRole::SERVER));
session_manager.reset(
new protocol::JingleSessionManager(transport_factory.Pass()));
transport_factory.reset(new protocol::WebrtcTransportFactory(
jingle_glue::JingleThreadWrapper::current(), transport_context));
#else // !defined(NDEBUG)
LOG(ERROR) << "WebRTC is enabled only in debug builds.";
ShutdownHost(kUsageExitCode);
return;
#endif // defined(NDEBUG)
} else {
session_manager =
CreateHostSessionManager(signal_strategy_.get(), network_settings,
context_->url_request_context_getter());
transport_factory.reset(
new protocol::IceTransportFactory(transport_context));
}
scoped_ptr<protocol::SessionManager> session_manager(
new protocol::JingleSessionManager(transport_factory.Pass()));
scoped_ptr<protocol::CandidateSessionConfig> protocol_config =
protocol::CandidateSessionConfig::CreateDefault();
......
// 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 "remoting/protocol/chromium_port_allocator.h"
#include "remoting/protocol/chromium_socket_factory.h"
#include "remoting/protocol/ice_transport_factory.h"
#include "remoting/protocol/jingle_session_manager.h"
#include "remoting/protocol/network_settings.h"
#include "remoting/protocol/session_manager.h"
namespace remoting {
scoped_ptr<protocol::SessionManager> CreateHostSessionManager(
SignalStrategy* signal_strategy,
const protocol::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<protocol::ChromiumPortAllocator> port_allocator(
protocol::ChromiumPortAllocator::Create(url_request_context_getter,
network_settings));
scoped_ptr<protocol::TransportFactory> transport_factory(
new protocol::IceTransportFactory(
signal_strategy, port_allocator.Pass(), network_settings,
protocol::TransportRole::SERVER));
scoped_ptr<protocol::JingleSessionManager> session_manager(
new protocol::JingleSessionManager(transport_factory.Pass()));
return session_manager.Pass();
}
} // namespace remoting
// 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.
#ifndef REMOTING_HOST_SESSION_MANAGER_FACTORY_H_
#define REMOTING_HOST_SESSION_MANAGER_FACTORY_H_
#include "base/memory/scoped_ptr.h"
#include "net/url_request/url_request_context_getter.h"
namespace net {
class URLRequestContextGetter;
} // namespace net
namespace remoting {
class SignalStrategy;
namespace protocol {
struct NetworkSettings;
class SessionManager;
} // namespace protocol
scoped_ptr<protocol::SessionManager> CreateHostSessionManager(
SignalStrategy* signal_strategy,
const protocol::NetworkSettings& network_settings,
const scoped_refptr<net::URLRequestContextGetter>&
url_request_context_getter);
} // namespace remoting
#endif // REMOTING_HOST_SESSION_MANAGER_FACTORY_H_
......@@ -12,7 +12,6 @@
#include "net/url_request/url_fetcher_delegate.h"
#include "net/url_request/url_request_context_getter.h"
#include "remoting/protocol/chromium_socket_factory.h"
#include "remoting/protocol/network_settings.h"
#include "url/gurl.h"
namespace remoting {
......@@ -131,35 +130,13 @@ void ChromiumPortAllocatorSession::OnURLFetchComplete(
// static
scoped_ptr<ChromiumPortAllocator> ChromiumPortAllocator::Create(
const scoped_refptr<net::URLRequestContextGetter>& url_context,
const NetworkSettings& network_settings) {
const scoped_refptr<net::URLRequestContextGetter>& url_context) {
scoped_ptr<rtc::NetworkManager> network_manager(
new rtc::BasicNetworkManager());
scoped_ptr<rtc::PacketSocketFactory> socket_factory(
new ChromiumPacketSocketFactory());
scoped_ptr<ChromiumPortAllocator> result(
new ChromiumPortAllocator(url_context, network_manager.Pass(),
socket_factory.Pass()));
// We always use PseudoTcp to provide a reliable channel. It provides poor
// performance when combined with TCP-based transport, so we have to disable
// TCP ports. ENABLE_SHARED_UFRAG flag is specified so that the same username
// fragment is shared between all candidates for this channel.
int flags = cricket::PORTALLOCATOR_DISABLE_TCP |
cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
cricket::PORTALLOCATOR_ENABLE_IPV6;
if (!(network_settings.flags & NetworkSettings::NAT_TRAVERSAL_STUN))
flags |= cricket::PORTALLOCATOR_DISABLE_STUN;
if (!(network_settings.flags & NetworkSettings::NAT_TRAVERSAL_RELAY))
flags |= cricket::PORTALLOCATOR_DISABLE_RELAY;
result->set_flags(flags);
result->SetPortRange(network_settings.port_range.min_port,
network_settings.port_range.max_port);
return result.Pass();
return make_scoped_ptr(new ChromiumPortAllocator(
url_context, network_manager.Pass(), socket_factory.Pass()));
}
ChromiumPortAllocator::ChromiumPortAllocator(
......@@ -173,8 +150,7 @@ ChromiumPortAllocator::ChromiumPortAllocator(
network_manager_(network_manager.Pass()),
socket_factory_(socket_factory.Pass()) {}
ChromiumPortAllocator::~ChromiumPortAllocator() {
}
ChromiumPortAllocator::~ChromiumPortAllocator() {}
cricket::PortAllocatorSession* ChromiumPortAllocator::CreateSessionInternal(
const std::string& content_name,
......@@ -186,5 +162,16 @@ cricket::PortAllocatorSession* ChromiumPortAllocator::CreateSessionInternal(
stun_hosts(), relay_hosts(), relay_token(), url_context_);
}
ChromiumPortAllocatorFactory::ChromiumPortAllocatorFactory(
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter)
: url_request_context_getter_(url_request_context_getter) {}
ChromiumPortAllocatorFactory::~ChromiumPortAllocatorFactory() {}
scoped_ptr<cricket::HttpPortAllocatorBase>
ChromiumPortAllocatorFactory::CreatePortAllocator() {
return ChromiumPortAllocator::Create(url_request_context_getter_);
}
} // namespace protocol
} // namespace remoting
......@@ -9,22 +9,24 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "net/url_request/url_request_context_getter.h"
#include "remoting/protocol/port_allocator_factory.h"
#include "third_party/webrtc/p2p/client/httpportallocator.h"
namespace net {
class URLRequestContextGetter;
} // namespace net
namespace remoting {
namespace protocol {
struct NetworkSettings;
// An implementation of cricket::PortAllocator for libjingle that
// uses Chromium's network stack and configures itself according
// to the specified NetworkSettings.
// An implementation of cricket::PortAllocator that uses Chromium's network
// stack.
class ChromiumPortAllocator : public cricket::HttpPortAllocatorBase {
public:
static scoped_ptr<ChromiumPortAllocator> Create(
const scoped_refptr<net::URLRequestContextGetter>& url_context,
const NetworkSettings& network_settings);
const scoped_refptr<net::URLRequestContextGetter>& url_context);
~ChromiumPortAllocator() override;
......@@ -48,6 +50,21 @@ class ChromiumPortAllocator : public cricket::HttpPortAllocatorBase {
DISALLOW_COPY_AND_ASSIGN(ChromiumPortAllocator);
};
class ChromiumPortAllocatorFactory : public PortAllocatorFactory {
public:
ChromiumPortAllocatorFactory(
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter);
~ChromiumPortAllocatorFactory() override;
// PortAllocatorFactory interface.
scoped_ptr<cricket::HttpPortAllocatorBase> CreatePortAllocator() override;
private:
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
DISALLOW_COPY_AND_ASSIGN(ChromiumPortAllocatorFactory);
};
} // namespace protocol
} // namespace remoting
......
// Copyright 2015 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/protocol/chromium_port_allocator_factory.h"
#include "base/logging.h"
#include "net/url_request/url_request_context_getter.h"
#include "remoting/protocol/chromium_port_allocator.h"
#include "remoting/protocol/network_settings.h"
namespace remoting {
namespace protocol {
ChromiumPortAllocatorFactory::ChromiumPortAllocatorFactory(
const NetworkSettings& network_settings,
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter)
: network_settings_(network_settings),
url_request_context_getter_(url_request_context_getter) {}
ChromiumPortAllocatorFactory::~ChromiumPortAllocatorFactory() {}
scoped_ptr<PortAllocatorFactory> ChromiumPortAllocatorFactory::Create(
const NetworkSettings& network_settings,
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter) {
return scoped_ptr<PortAllocatorFactory>(new ChromiumPortAllocatorFactory(
network_settings, url_request_context_getter));
}
cricket::PortAllocator* ChromiumPortAllocatorFactory::CreatePortAllocator() {
scoped_ptr<ChromiumPortAllocator> port_allocator(
ChromiumPortAllocator::Create(url_request_context_getter_,
network_settings_));
return port_allocator.release();
}
} // namespace protocol
} // namespace remoting
// Copyright 2015 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.
#ifndef REMOTING_PROTOCOL_CHROMIUM_PORT_ALLOCATOR_FACTORY_H_
#define REMOTING_PROTOCOL_CHROMIUM_PORT_ALLOCATOR_FACTORY_H_
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "remoting/protocol/network_settings.h"
#include "remoting/protocol/port_allocator_factory.h"
namespace net {
class URLRequestContextGetter;
} // namespace net
namespace remoting {
namespace protocol {
class ChromiumPortAllocatorFactory : public PortAllocatorFactory {
public:
static scoped_ptr<PortAllocatorFactory> Create(
const NetworkSettings& network_settings,
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter);
// PortAllocatorFactory implementation.
cricket::PortAllocator* CreatePortAllocator() override;
protected:
ChromiumPortAllocatorFactory(
const NetworkSettings& network_settings,
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter);
~ChromiumPortAllocatorFactory() override;
private:
NetworkSettings network_settings_;
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
DISALLOW_COPY_AND_ASSIGN(ChromiumPortAllocatorFactory);
};
} // namespace protocol
} // namespace remoting
#endif // REMOTING_PROTOCOL_CHROMIUM_PORT_ALLOCATOR_FACTORY_H_
......@@ -27,7 +27,7 @@ class ExtensionMessage;
class HostStub;
class InputStub;
class SessionConfig;
class TransportFactory;
class TransportContext;
struct TransportRoute;
class VideoStub;
......@@ -92,7 +92,7 @@ class ConnectionToHost {
// and must outlive the ConnectionToHost.
// Caller must set stubs (see below) before calling Connect.
virtual void Connect(SignalStrategy* signal_strategy,
scoped_ptr<TransportFactory> transport_factory,
scoped_refptr<TransportContext> transport_context,
scoped_ptr<Authenticator> authenticator,
const std::string& host_jid,
HostEventCallback* event_callback) = 0;
......
......@@ -18,8 +18,10 @@
#include "remoting/protocol/client_video_dispatcher.h"
#include "remoting/protocol/clipboard_stub.h"
#include "remoting/protocol/errors.h"
#include "remoting/protocol/ice_transport.h"
#include "remoting/protocol/jingle_session_manager.h"
#include "remoting/protocol/transport.h"
#include "remoting/protocol/transport_context.h"
#include "remoting/protocol/video_stub.h"
namespace remoting {
......@@ -66,7 +68,7 @@ const char* ConnectionToHost::StateToString(State state) {
void ConnectionToHostImpl::Connect(
SignalStrategy* signal_strategy,
scoped_ptr<TransportFactory> transport_factory,
scoped_refptr<TransportContext> transport_context,
scoped_ptr<Authenticator> authenticator,
const std::string& host_jid,
HostEventCallback* event_callback) {
......@@ -91,7 +93,8 @@ void ConnectionToHostImpl::Connect(
signal_strategy_->AddListener(this);
session_manager_.reset(new JingleSessionManager(transport_factory.Pass()));
session_manager_.reset(new JingleSessionManager(
make_scoped_ptr(new IceTransportFactory(transport_context))));
session_manager_->set_protocol_config(candidate_config_->Clone());
session_manager_->Init(signal_strategy_, this);
......
......@@ -54,7 +54,7 @@ class ConnectionToHostImpl : public ConnectionToHost,
void set_video_stub(VideoStub* video_stub) override;
void set_audio_stub(AudioStub* audio_stub) override;
void Connect(SignalStrategy* signal_strategy,
scoped_ptr<TransportFactory> transport_factory,
scoped_refptr<TransportContext> transport_context,
scoped_ptr<Authenticator> authenticator,
const std::string& host_jid,
HostEventCallback* event_callback) override;
......
......@@ -5,6 +5,7 @@
#include "remoting/protocol/fake_connection_to_host.h"
#include "remoting/protocol/authenticator.h"
#include "remoting/protocol/transport_context.h"
namespace remoting {
namespace test {
......@@ -36,7 +37,7 @@ void FakeConnectionToHost::set_audio_stub(protocol::AudioStub* audio_stub) {
void FakeConnectionToHost::Connect(
SignalStrategy* signal_strategy,
scoped_ptr<protocol::TransportFactory> transport_factory,
scoped_refptr<protocol::TransportContext> transport_context,
scoped_ptr<protocol::Authenticator> authenticator,
const std::string& host_jid,
HostEventCallback* event_callback) {
......
......@@ -26,7 +26,7 @@ class FakeConnectionToHost : public protocol::ConnectionToHost {
void set_video_stub(protocol::VideoStub* video_stub) override;
void set_audio_stub(protocol::AudioStub* audio_stub) override;
void Connect(SignalStrategy* signal_strategy,
scoped_ptr<protocol::TransportFactory> transport_factory,
scoped_refptr<protocol::TransportContext> transport_context,
scoped_ptr<protocol::Authenticator> authenticator,
const std::string& host_jid,
HostEventCallback* event_callback) override;
......
......@@ -10,6 +10,7 @@
#include "remoting/protocol/pseudotcp_channel_factory.h"
#include "remoting/protocol/secure_channel_factory.h"
#include "remoting/protocol/stream_channel_factory.h"