summaryrefslogtreecommitdiffstats
path: root/remoting/client
diff options
context:
space:
mode:
authorsergeyu <sergeyu@chromium.org>2015-12-16 14:45:00 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-16 22:46:17 +0000
commit86030f38b4a7be9418c50da7e83ff55749438dba (patch)
treea885f9e90179ee8ae6ad27c651bd2ddb704124da /remoting/client
parent3b7c3e37ec089dc5179359a52a7b2311285c7f21 (diff)
downloadchromium_src-86030f38b4a7be9418c50da7e83ff55749438dba.zip
chromium_src-86030f38b4a7be9418c50da7e83ff55749438dba.tar.gz
chromium_src-86030f38b4a7be9418c50da7e83ff55749438dba.tar.bz2
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}
Diffstat (limited to 'remoting/client')
-rw-r--r--remoting/client/chromoting_client.cc8
-rw-r--r--remoting/client/chromoting_client.h4
-rw-r--r--remoting/client/jni/chromoting_jni_instance.cc20
-rw-r--r--remoting/client/plugin/chromoting_instance.cc13
-rw-r--r--remoting/client/plugin/pepper_port_allocator.cc21
-rw-r--r--remoting/client/plugin/pepper_port_allocator.h15
6 files changed, 50 insertions, 31 deletions
diff --git a/remoting/client/chromoting_client.cc b/remoting/client/chromoting_client.cc
index d9e0f37..303150f 100644
--- a/remoting/client/chromoting_client.cc
+++ b/remoting/client/chromoting_client.cc
@@ -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(
diff --git a/remoting/client/chromoting_client.h b/remoting/client/chromoting_client.h
index ce7fbcf..93daab2 100644
--- a/remoting/client/chromoting_client.h
+++ b/remoting/client/chromoting_client.h
@@ -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);
diff --git a/remoting/client/jni/chromoting_jni_instance.cc b/remoting/client/jni/chromoting_jni_instance.cc
index 0d5314e..535ca0f 100644
--- a/remoting/client/jni/chromoting_jni_instance.cc
+++ b/remoting/client/jni/chromoting_jni_instance.cc
@@ -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(
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc
index 13fe342..93918de 100644
--- a/remoting/client/plugin/chromoting_instance.cc
+++ b/remoting/client/plugin/chromoting_instance.cc
@@ -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(
diff --git a/remoting/client/plugin/pepper_port_allocator.cc b/remoting/client/plugin/pepper_port_allocator.cc
index a601480..11fee075 100644
--- a/remoting/client/plugin/pepper_port_allocator.cc
+++ b/remoting/client/plugin/pepper_port_allocator.cc
@@ -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
diff --git a/remoting/client/plugin/pepper_port_allocator.h b/remoting/client/plugin/pepper_port_allocator.h
index c98c242..76d447b 100644
--- a/remoting/client/plugin/pepper_port_allocator.h
+++ b/remoting/client/plugin/pepper_port_allocator.h
@@ -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_