summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--remoting/client/plugin/pepper_port_allocator.cc50
-rw-r--r--remoting/client/plugin/pepper_port_allocator.h19
-rw-r--r--remoting/protocol/chromium_port_allocator.cc43
-rw-r--r--remoting/protocol/chromium_port_allocator.h8
-rw-r--r--remoting/protocol/port_allocator_base.cc171
-rw-r--r--remoting/protocol/port_allocator_base.h83
-rw-r--r--remoting/protocol/port_allocator_factory.h12
-rw-r--r--remoting/protocol/transport_context.cc4
-rw-r--r--remoting/remoting_srcs.gypi4
-rw-r--r--remoting/test/fake_port_allocator.cc40
-rw-r--r--remoting/test/fake_port_allocator.h6
11 files changed, 332 insertions, 108 deletions
diff --git a/remoting/client/plugin/pepper_port_allocator.cc b/remoting/client/plugin/pepper_port_allocator.cc
index 0b28e5a..f855492 100644
--- a/remoting/client/plugin/pepper_port_allocator.cc
+++ b/remoting/client/plugin/pepper_port_allocator.cc
@@ -29,11 +29,10 @@ namespace {
// URLLoader. Normally the response from URL loader is smaller than 1kB.
const int kReadSize = 1024;
-class PepperPortAllocatorSession
- : public cricket::HttpPortAllocatorSessionBase {
+class PepperPortAllocatorSession : public protocol::PortAllocatorSessionBase {
public:
PepperPortAllocatorSession(
- cricket::HttpPortAllocatorBase* allocator,
+ protocol::PortAllocatorBase* allocator,
const std::string& content_name,
int component,
const std::string& ice_username_fragment,
@@ -44,10 +43,10 @@ class PepperPortAllocatorSession
const pp::InstanceHandle& instance);
~PepperPortAllocatorSession() override;
- // cricket::HttpPortAllocatorBase overrides.
+ // PortAllocatorBase overrides.
void ConfigReady(cricket::PortConfiguration* config) override;
void GetPortConfigurations() override;
- void SendSessionRequest(const std::string& host, int port) override;
+ void SendSessionRequest(const std::string& host) override;
private:
void OnUrlOpened(int32_t result);
@@ -60,7 +59,7 @@ class PepperPortAllocatorSession
scoped_ptr<pp::URLLoader> relay_url_loader_;
std::vector<char> relay_response_body_;
- bool relay_response_received_;
+ bool relay_response_received_ = false;
pp::CompletionCallbackFactory<PepperPortAllocatorSession> callback_factory_;
@@ -68,7 +67,7 @@ class PepperPortAllocatorSession
};
PepperPortAllocatorSession::PepperPortAllocatorSession(
- cricket::HttpPortAllocatorBase* allocator,
+ protocol::PortAllocatorBase* allocator,
const std::string& content_name,
int component,
const std::string& ice_username_fragment,
@@ -77,23 +76,19 @@ PepperPortAllocatorSession::PepperPortAllocatorSession(
const std::vector<std::string>& relay_hosts,
const std::string& relay_token,
const pp::InstanceHandle& instance)
- : HttpPortAllocatorSessionBase(allocator,
- content_name,
- component,
- ice_username_fragment,
- ice_password,
- stun_hosts,
- relay_hosts,
- relay_token,
- std::string()),
+ : PortAllocatorSessionBase(allocator,
+ content_name,
+ component,
+ ice_username_fragment,
+ ice_password,
+ stun_hosts,
+ relay_hosts,
+ relay_token),
instance_(instance),
stun_hosts_(stun_hosts.begin(), stun_hosts.end()),
- relay_response_received_(false),
- callback_factory_(this) {
-}
+ callback_factory_(this) {}
-PepperPortAllocatorSession::~PepperPortAllocatorSession() {
-}
+PepperPortAllocatorSession::~PepperPortAllocatorSession() {}
void PepperPortAllocatorSession::ConfigReady(
cricket::PortConfiguration* config) {
@@ -121,13 +116,10 @@ void PepperPortAllocatorSession::GetPortConfigurations() {
TryCreateRelaySession();
}
-void PepperPortAllocatorSession::SendSessionRequest(
- const std::string& host,
- int port) {
+void PepperPortAllocatorSession::SendSessionRequest(const std::string& host) {
relay_url_loader_.reset(new pp::URLLoader(instance_));
pp::URLRequestInfo request_info(instance_);
- std::string url = "https://" + host + ":" + base::IntToString(port) +
- GetSessionRequestUrl() + "&sn=1";
+ std::string url = "https://" + host + GetSessionRequestUrl() + "&sn=1";
request_info.SetURL(url);
request_info.SetMethod("GET");
std::stringstream headers;
@@ -220,9 +212,7 @@ PepperPortAllocator::PepperPortAllocator(
const pp::InstanceHandle& instance,
scoped_ptr<rtc::NetworkManager> network_manager,
scoped_ptr<rtc::PacketSocketFactory> socket_factory)
- : HttpPortAllocatorBase(network_manager.get(),
- socket_factory.get(),
- std::string()),
+ : PortAllocatorBase(network_manager.get(), socket_factory.get()),
instance_(instance),
network_manager_(std::move(network_manager)),
socket_factory_(std::move(socket_factory)) {}
@@ -245,7 +235,7 @@ PepperPortAllocatorFactory::PepperPortAllocatorFactory(
PepperPortAllocatorFactory::~PepperPortAllocatorFactory() {}
-scoped_ptr<cricket::HttpPortAllocatorBase>
+scoped_ptr<protocol::PortAllocatorBase>
PepperPortAllocatorFactory::CreatePortAllocator() {
return PepperPortAllocator::Create(instance_);
}
diff --git a/remoting/client/plugin/pepper_port_allocator.h b/remoting/client/plugin/pepper_port_allocator.h
index 137a0d8..19fb03d 100644
--- a/remoting/client/plugin/pepper_port_allocator.h
+++ b/remoting/client/plugin/pepper_port_allocator.h
@@ -9,27 +9,20 @@
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "ppapi/cpp/instance_handle.h"
+#include "remoting/protocol/port_allocator_base.h"
#include "remoting/protocol/port_allocator_factory.h"
-#include "third_party/webrtc/p2p/client/httpportallocator.h"
namespace remoting {
-// An implementation of cricket::PortAllocator for libjingle that is
-// used by the client plugin. There are two differences from
-// cricket::HttpPortAllocator:
-// * PepperPortAllocator uses Pepper URLLoader API when creating
-// relay sessions.
-// * PepperPortAllocator resolves STUN DNS names and passes IP
-// addresses to BasicPortAllocator (it uses HostResolverPrivate API
-// for that). This is needed because libjingle's DNS resolution
-// code doesn't work in sandbox.
-class PepperPortAllocator : public cricket::HttpPortAllocatorBase {
+// An implementation of cricket::PortAllocator for libjingle that is used by the
+// client plugin. It uses Pepper URLLoader API when creating relay sessions.
+class PepperPortAllocator : public protocol::PortAllocatorBase {
public:
static scoped_ptr<PepperPortAllocator> Create(
const pp::InstanceHandle& instance);
~PepperPortAllocator() override;
- // cricket::HttpPortAllocatorBase overrides.
+ // PortAllocatorBase overrides.
cricket::PortAllocatorSession* CreateSessionInternal(
const std::string& content_name,
int component,
@@ -55,7 +48,7 @@ class PepperPortAllocatorFactory : public protocol::PortAllocatorFactory {
~PepperPortAllocatorFactory() override;
// PortAllocatorFactory interface.
- scoped_ptr<cricket::HttpPortAllocatorBase> CreatePortAllocator() override;
+ scoped_ptr<protocol::PortAllocatorBase> CreatePortAllocator() override;
private:
pp::InstanceHandle instance_;
diff --git a/remoting/protocol/chromium_port_allocator.cc b/remoting/protocol/chromium_port_allocator.cc
index be00db8..cf656f0 100644
--- a/remoting/protocol/chromium_port_allocator.cc
+++ b/remoting/protocol/chromium_port_allocator.cc
@@ -22,12 +22,11 @@ namespace protocol {
namespace {
-class ChromiumPortAllocatorSession
- : public cricket::HttpPortAllocatorSessionBase,
- public net::URLFetcherDelegate {
+class ChromiumPortAllocatorSession : public PortAllocatorSessionBase,
+ public net::URLFetcherDelegate {
public:
ChromiumPortAllocatorSession(
- cricket::HttpPortAllocatorBase* allocator,
+ PortAllocatorBase* allocator,
const std::string& content_name,
int component,
const std::string& ice_username_fragment,
@@ -38,9 +37,9 @@ class ChromiumPortAllocatorSession
const scoped_refptr<net::URLRequestContextGetter>& url_context);
~ChromiumPortAllocatorSession() override;
- // cricket::HttpPortAllocatorBase overrides.
+ // PortAllocatorBase overrides.
void ConfigReady(cricket::PortConfiguration* config) override;
- void SendSessionRequest(const std::string& host, int port) override;
+ void SendSessionRequest(const std::string& host) override;
// net::URLFetcherDelegate interface.
void OnURLFetchComplete(const net::URLFetcher* url_fetcher) override;
@@ -53,7 +52,7 @@ class ChromiumPortAllocatorSession
};
ChromiumPortAllocatorSession::ChromiumPortAllocatorSession(
- cricket::HttpPortAllocatorBase* allocator,
+ PortAllocatorBase* allocator,
const std::string& content_name,
int component,
const std::string& ice_username_fragment,
@@ -62,15 +61,14 @@ ChromiumPortAllocatorSession::ChromiumPortAllocatorSession(
const std::vector<std::string>& relay_hosts,
const std::string& relay,
const scoped_refptr<net::URLRequestContextGetter>& url_context)
- : HttpPortAllocatorSessionBase(allocator,
- content_name,
- component,
- ice_username_fragment,
- ice_password,
- stun_hosts,
- relay_hosts,
- relay,
- std::string()),
+ : PortAllocatorSessionBase(allocator,
+ content_name,
+ component,
+ ice_username_fragment,
+ ice_password,
+ stun_hosts,
+ relay_hosts,
+ relay),
url_context_(url_context) {}
ChromiumPortAllocatorSession::~ChromiumPortAllocatorSession() {
@@ -94,11 +92,8 @@ void ChromiumPortAllocatorSession::ConfigReady(
cricket::BasicPortAllocatorSession::ConfigReady(config);
}
-void ChromiumPortAllocatorSession::SendSessionRequest(
- const std::string& host,
- int port) {
- GURL url("https://" + host + ":" + base::IntToString(port) +
- GetSessionRequestUrl() + "&sn=1");
+void ChromiumPortAllocatorSession::SendSessionRequest(const std::string& host) {
+ GURL url("https://" + host + GetSessionRequestUrl() + "&sn=1");
scoped_ptr<net::URLFetcher> url_fetcher =
net::URLFetcher::Create(url, net::URLFetcher::GET, this);
url_fetcher->SetRequestContext(url_context_.get());
@@ -146,9 +141,7 @@ ChromiumPortAllocator::ChromiumPortAllocator(
const scoped_refptr<net::URLRequestContextGetter>& url_context,
scoped_ptr<rtc::NetworkManager> network_manager,
scoped_ptr<rtc::PacketSocketFactory> socket_factory)
- : HttpPortAllocatorBase(network_manager.get(),
- socket_factory.get(),
- std::string()),
+ : PortAllocatorBase(network_manager.get(), socket_factory.get()),
url_context_(url_context),
network_manager_(std::move(network_manager)),
socket_factory_(std::move(socket_factory)) {}
@@ -171,7 +164,7 @@ ChromiumPortAllocatorFactory::ChromiumPortAllocatorFactory(
ChromiumPortAllocatorFactory::~ChromiumPortAllocatorFactory() {}
-scoped_ptr<cricket::HttpPortAllocatorBase>
+scoped_ptr<PortAllocatorBase>
ChromiumPortAllocatorFactory::CreatePortAllocator() {
return ChromiumPortAllocator::Create(url_request_context_getter_);
}
diff --git a/remoting/protocol/chromium_port_allocator.h b/remoting/protocol/chromium_port_allocator.h
index b3701f5..63d6e57 100644
--- a/remoting/protocol/chromium_port_allocator.h
+++ b/remoting/protocol/chromium_port_allocator.h
@@ -10,8 +10,8 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "remoting/protocol/port_allocator_base.h"
#include "remoting/protocol/port_allocator_factory.h"
-#include "third_party/webrtc/p2p/client/httpportallocator.h"
namespace net {
class URLRequestContextGetter;
@@ -24,14 +24,14 @@ struct NetworkSettings;
// An implementation of cricket::PortAllocator that uses Chromium's network
// stack.
-class ChromiumPortAllocator : public cricket::HttpPortAllocatorBase {
+class ChromiumPortAllocator : public PortAllocatorBase {
public:
static scoped_ptr<ChromiumPortAllocator> Create(
const scoped_refptr<net::URLRequestContextGetter>& url_context);
~ChromiumPortAllocator() override;
- // cricket::HttpPortAllocatorBase overrides.
+ // PortAllocatorBase overrides.
cricket::PortAllocatorSession* CreateSessionInternal(
const std::string& content_name,
int component,
@@ -58,7 +58,7 @@ class ChromiumPortAllocatorFactory : public PortAllocatorFactory {
~ChromiumPortAllocatorFactory() override;
// PortAllocatorFactory interface.
- scoped_ptr<cricket::HttpPortAllocatorBase> CreatePortAllocator() override;
+ scoped_ptr<PortAllocatorBase> CreatePortAllocator() override;
private:
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
diff --git a/remoting/protocol/port_allocator_base.cc b/remoting/protocol/port_allocator_base.cc
new file mode 100644
index 0000000..a62d528
--- /dev/null
+++ b/remoting/protocol/port_allocator_base.cc
@@ -0,0 +1,171 @@
+// Copyright 2016 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/port_allocator_base.h"
+
+#include <algorithm>
+#include <map>
+
+#include "base/logging.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_split.h"
+#include "net/base/escape.h"
+
+namespace {
+
+typedef std::map<std::string, std::string> StringMap;
+
+// Parses the lines in the result of the HTTP request that are of the form
+// 'a=b' and returns them in a map.
+StringMap ParseMap(const std::string& string) {
+ StringMap map;
+ base::StringPairs pairs;
+ base::SplitStringIntoKeyValuePairs(string, '\r', '=', &pairs);
+
+ for (auto& pair : pairs) {
+ map[pair.first] = pair.second;
+ }
+ return map;
+}
+
+} // namespace
+
+namespace remoting {
+namespace protocol {
+
+const int PortAllocatorBase::kNumRetries = 5;
+
+PortAllocatorBase::PortAllocatorBase(rtc::NetworkManager* network_manager,
+ rtc::PacketSocketFactory* socket_factory)
+ : BasicPortAllocator(network_manager, socket_factory) {}
+
+PortAllocatorBase::~PortAllocatorBase() {}
+
+void PortAllocatorBase::SetStunHosts(
+ const std::vector<rtc::SocketAddress>& hosts) {
+ stun_hosts_ = hosts;
+}
+
+void PortAllocatorBase::SetRelayHosts(const std::vector<std::string>& hosts) {
+ relay_hosts_ = hosts;
+}
+
+void PortAllocatorBase::SetRelayToken(const std::string& relay) {
+ relay_token_ = relay;
+}
+
+PortAllocatorSessionBase::PortAllocatorSessionBase(
+ PortAllocatorBase* allocator,
+ const std::string& content_name,
+ int component,
+ const std::string& ice_ufrag,
+ const std::string& ice_pwd,
+ const std::vector<rtc::SocketAddress>& stun_hosts,
+ const std::vector<std::string>& relay_hosts,
+ const std::string& relay_token)
+ : BasicPortAllocatorSession(allocator,
+ content_name,
+ component,
+ ice_ufrag,
+ ice_pwd),
+ relay_hosts_(relay_hosts),
+ stun_hosts_(stun_hosts),
+ relay_token_(relay_token),
+ attempts_(0) {}
+
+PortAllocatorSessionBase::~PortAllocatorSessionBase() {}
+
+void PortAllocatorSessionBase::GetPortConfigurations() {
+ // Creating relay sessions can take time and is done asynchronously.
+ // Creating stun sessions could also take time and could be done aysnc also,
+ // but for now is done here and added to the initial config. Note any later
+ // configs will have unresolved stun ips and will be discarded by the
+ // AllocationSequence.
+ cricket::ServerAddresses hosts;
+ for (const auto& host : stun_hosts_) {
+ hosts.insert(host);
+ }
+
+ cricket::PortConfiguration* config =
+ new cricket::PortConfiguration(hosts, username(), password());
+ ConfigReady(config);
+ TryCreateRelaySession();
+}
+
+void PortAllocatorSessionBase::TryCreateRelaySession() {
+ if (allocator()->flags() & cricket::PORTALLOCATOR_DISABLE_RELAY)
+ return;
+
+ if (attempts_ == PortAllocatorBase::kNumRetries) {
+ LOG(ERROR) << "PortAllocator: maximum number of requests reached; "
+ << "giving up on relay.";
+ return;
+ }
+
+ if (relay_hosts_.empty()) {
+ LOG(ERROR) << "PortAllocator: no relay hosts configured.";
+ return;
+ }
+
+ if (relay_token_.empty()){
+ LOG(WARNING) << "No relay auth token found.";
+ return;
+ }
+
+ // Choose the next host to try.
+ std::string host = relay_hosts_[attempts_ % relay_hosts_.size()];
+ attempts_++;
+ SendSessionRequest(host);
+}
+
+PortAllocatorBase* PortAllocatorSessionBase::allocator() {
+ return static_cast<PortAllocatorBase*>(
+ BasicPortAllocatorSession::allocator());
+}
+
+std::string PortAllocatorSessionBase::GetSessionRequestUrl() {
+ ASSERT(!username().empty());
+ ASSERT(!password().empty());
+ return "/create_session?username=" +
+ net::EscapeUrlEncodedData(username(), false) + "&password=" +
+ net::EscapeUrlEncodedData(password(), false);
+}
+
+void PortAllocatorSessionBase::ReceiveSessionResponse(
+ const std::string& response) {
+ StringMap map = ParseMap(response);
+
+ if (!username().empty() && map["username"] != username()) {
+ LOG(WARNING) << "Received unexpected username value from relay server.";
+ }
+ if (!password().empty() && map["password"] != password()) {
+ LOG(WARNING) << "Received unexpected password value from relay server.";
+ }
+
+ cricket::ServerAddresses hosts;
+ for (const auto& host : stun_hosts_) {
+ hosts.insert(host);
+ }
+
+ cricket::PortConfiguration* config =
+ new cricket::PortConfiguration(hosts, map["username"], map["password"]);
+
+ std::string relay_ip = map["relay.ip"];
+ std::string relay_port = map["relay.udp_port"];
+ unsigned relay_port_int;
+
+ if (!relay_ip.empty() && !relay_port.empty() &&
+ base::StringToUint(relay_port, &relay_port_int)) {
+ cricket::RelayServerConfig relay_config(cricket::RELAY_GTURN);
+ rtc::SocketAddress address(relay_ip, relay_port_int);
+ relay_config.ports.push_back(
+ cricket::ProtocolAddress(address, cricket::PROTO_UDP));
+ config->AddRelay(relay_config);
+ }
+
+ ConfigReady(config);
+}
+
+} // namespace protocol
+} // namespace remoting
diff --git a/remoting/protocol/port_allocator_base.h b/remoting/protocol/port_allocator_base.h
new file mode 100644
index 0000000..ee3f68c
--- /dev/null
+++ b/remoting/protocol/port_allocator_base.h
@@ -0,0 +1,83 @@
+// Copyright 2016 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_PORT_ALLOCATOR_BASE_H_
+#define REMOTING_PROTOCOL_PORT_ALLOCATOR_BASE_H_
+
+#include <string>
+#include <vector>
+
+#include "third_party/webrtc/p2p/client/basicportallocator.h"
+
+namespace remoting {
+namespace protocol {
+
+class PortAllocatorBase : public cricket::BasicPortAllocator {
+ public:
+ // The number of HTTP requests we should attempt before giving up.
+ static const int kNumRetries;
+
+ PortAllocatorBase(rtc::NetworkManager* network_manager,
+ rtc::PacketSocketFactory* socket_factory);
+ ~PortAllocatorBase() override;
+
+ // CreateSession is defined in cricket::BasicPortAllocator but is
+ // redefined here as pure virtual.
+ cricket::PortAllocatorSession* CreateSessionInternal(
+ const std::string& content_name,
+ int component,
+ const std::string& ice_ufrag,
+ const std::string& ice_pwd) override = 0;
+
+ void SetStunHosts(const std::vector<rtc::SocketAddress>& hosts);
+ void SetRelayHosts(const std::vector<std::string>& hosts);
+ void SetRelayToken(const std::string& relay);
+
+ const std::vector<rtc::SocketAddress>& stun_hosts() const {
+ return stun_hosts_;
+ }
+
+ const std::vector<std::string>& relay_hosts() const { return relay_hosts_; }
+ const std::string& relay_token() const { return relay_token_; }
+
+ private:
+ std::vector<rtc::SocketAddress> stun_hosts_;
+ std::vector<std::string> relay_hosts_;
+ std::string relay_token_;
+};
+
+class PortAllocatorSessionBase : public cricket::BasicPortAllocatorSession {
+ public:
+ PortAllocatorSessionBase(PortAllocatorBase* allocator,
+ const std::string& content_name,
+ int component,
+ const std::string& ice_ufrag,
+ const std::string& ice_pwd,
+ const std::vector<rtc::SocketAddress>& stun_hosts,
+ const std::vector<std::string>& relay_hosts,
+ const std::string& relay);
+ ~PortAllocatorSessionBase() override;
+
+ const std::string& relay_token() const { return relay_token_; }
+
+ virtual void SendSessionRequest(const std::string& host) = 0;
+ virtual void ReceiveSessionResponse(const std::string& response);
+
+ protected:
+ std::string GetSessionRequestUrl();
+ void GetPortConfigurations() override;
+ void TryCreateRelaySession();
+ PortAllocatorBase* allocator() override;
+
+ private:
+ std::vector<std::string> relay_hosts_;
+ std::vector<rtc::SocketAddress> stun_hosts_;
+ std::string relay_token_;
+ int attempts_;
+};
+
+} // namespace protocol
+} // namespace remoting
+
+#endif // REMOTING_PROTOCOL_PORT_ALLOCATOR_BASE_H_
diff --git a/remoting/protocol/port_allocator_factory.h b/remoting/protocol/port_allocator_factory.h
index b08df71..f563cb5 100644
--- a/remoting/protocol/port_allocator_factory.h
+++ b/remoting/protocol/port_allocator_factory.h
@@ -7,20 +7,18 @@
#include "base/memory/scoped_ptr.h"
-namespace cricket {
-class HttpPortAllocatorBase;
-} // namespace cricket
-
namespace remoting {
namespace protocol {
+class PortAllocatorBase;
+
// Factory class used for creating cricket::PortAllocator that is used
-// for ICE negotiation.
+// to allocate ICE candidates.
class PortAllocatorFactory {
public:
- virtual scoped_ptr<cricket::HttpPortAllocatorBase> CreatePortAllocator() = 0;
-
virtual ~PortAllocatorFactory() {}
+
+ virtual scoped_ptr<PortAllocatorBase> CreatePortAllocator() = 0;
};
} // namespace protocol
diff --git a/remoting/protocol/transport_context.cc b/remoting/protocol/transport_context.cc
index 8fa25ad..95f1358 100644
--- a/remoting/protocol/transport_context.cc
+++ b/remoting/protocol/transport_context.cc
@@ -10,8 +10,8 @@
#include "base/location.h"
#include "base/single_thread_task_runner.h"
#include "base/thread_task_runner_handle.h"
+#include "remoting/protocol/port_allocator_base.h"
#include "remoting/protocol/port_allocator_factory.h"
-#include "third_party/webrtc/p2p/client/httpportallocator.h"
#if !defined(OS_NACL)
#include "jingle/glue/thread_wrapper.h"
@@ -108,7 +108,7 @@ void TransportContext::OnJingleInfo(
scoped_ptr<cricket::PortAllocator>
TransportContext::CreatePortAllocatorInternal() {
- scoped_ptr<cricket::HttpPortAllocatorBase> result =
+ scoped_ptr<PortAllocatorBase> result =
port_allocator_factory_->CreatePortAllocator();
if (!relay_token_.empty() && !relay_hosts_.empty()) {
diff --git a/remoting/remoting_srcs.gypi b/remoting/remoting_srcs.gypi
index 656b4e2..8f16e55 100644
--- a/remoting/remoting_srcs.gypi
+++ b/remoting/remoting_srcs.gypi
@@ -167,6 +167,9 @@
'protocol/pairing_registry.h',
'protocol/performance_tracker.cc',
'protocol/performance_tracker.h',
+ 'protocol/port_allocator_base.cc',
+ 'protocol/port_allocator_base.h',
+ 'protocol/port_allocator_factory.h',
'protocol/port_range.cc',
'protocol/port_range.h',
'protocol/pseudotcp_adapter.cc',
@@ -211,7 +214,6 @@
'protocol/chromium_socket_factory.h',
'protocol/ice_connection_to_client.cc',
'protocol/ice_connection_to_client.h',
- 'protocol/port_allocator_factory.h',
'protocol/video_frame_pump.cc',
'protocol/video_frame_pump.h',
'protocol/webrtc_connection_to_client.cc',
diff --git a/remoting/test/fake_port_allocator.cc b/remoting/test/fake_port_allocator.cc
index 04047e6..6fcc33f 100644
--- a/remoting/test/fake_port_allocator.cc
+++ b/remoting/test/fake_port_allocator.cc
@@ -14,11 +14,10 @@ namespace remoting {
namespace {
-class FakePortAllocatorSession
- : public cricket::HttpPortAllocatorSessionBase {
+class FakePortAllocatorSession : public protocol::PortAllocatorSessionBase {
public:
FakePortAllocatorSession(
- cricket::HttpPortAllocatorBase* allocator,
+ protocol::PortAllocatorBase* allocator,
const std::string& content_name,
int component,
const std::string& ice_username_fragment,
@@ -28,16 +27,16 @@ class FakePortAllocatorSession
const std::string& relay);
~FakePortAllocatorSession() override;
- // cricket::HttpPortAllocatorBase overrides.
+ // protocol::PortAllocatorBase overrides.
void ConfigReady(cricket::PortConfiguration* config) override;
- void SendSessionRequest(const std::string& host, int port) override;
+ void SendSessionRequest(const std::string& host) override;
private:
DISALLOW_COPY_AND_ASSIGN(FakePortAllocatorSession);
};
FakePortAllocatorSession::FakePortAllocatorSession(
- cricket::HttpPortAllocatorBase* allocator,
+ protocol::PortAllocatorBase* allocator,
const std::string& content_name,
int component,
const std::string& ice_username_fragment,
@@ -45,19 +44,16 @@ FakePortAllocatorSession::FakePortAllocatorSession(
const std::vector<rtc::SocketAddress>& stun_hosts,
const std::vector<std::string>& relay_hosts,
const std::string& relay)
- : HttpPortAllocatorSessionBase(allocator,
- content_name,
- component,
- ice_username_fragment,
- ice_password,
- stun_hosts,
- relay_hosts,
- relay,
- std::string()) {
-}
+ : PortAllocatorSessionBase(allocator,
+ content_name,
+ component,
+ ice_username_fragment,
+ ice_password,
+ stun_hosts,
+ relay_hosts,
+ relay) {}
-FakePortAllocatorSession::~FakePortAllocatorSession() {
-}
+FakePortAllocatorSession::~FakePortAllocatorSession() {}
void FakePortAllocatorSession::ConfigReady(
cricket::PortConfiguration* config) {
@@ -76,9 +72,7 @@ void FakePortAllocatorSession::ConfigReady(
cricket::BasicPortAllocatorSession::ConfigReady(config);
}
-void FakePortAllocatorSession::SendSessionRequest(
- const std::string& host,
- int port) {
+void FakePortAllocatorSession::SendSessionRequest(const std::string& host) {
ReceiveSessionResponse(std::string());
}
@@ -86,7 +80,7 @@ void FakePortAllocatorSession::SendSessionRequest(
FakePortAllocator::FakePortAllocator(rtc::NetworkManager* network_manager,
FakePacketSocketFactory* socket_factory)
- : HttpPortAllocatorBase(network_manager, socket_factory, std::string()) {}
+ : PortAllocatorBase(network_manager, socket_factory) {}
FakePortAllocator::~FakePortAllocator() {}
cricket::PortAllocatorSession* FakePortAllocator::CreateSessionInternal(
@@ -108,7 +102,7 @@ FakePortAllocatorFactory::FakePortAllocatorFactory(
FakePortAllocatorFactory::~FakePortAllocatorFactory() {}
-scoped_ptr<cricket::HttpPortAllocatorBase>
+scoped_ptr<protocol::PortAllocatorBase>
FakePortAllocatorFactory::CreatePortAllocator() {
return make_scoped_ptr(
new FakePortAllocator(network_manager_.get(), socket_factory_.get()));
diff --git a/remoting/test/fake_port_allocator.h b/remoting/test/fake_port_allocator.h
index dfab4a5..636e7a3 100644
--- a/remoting/test/fake_port_allocator.h
+++ b/remoting/test/fake_port_allocator.h
@@ -10,8 +10,8 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "remoting/protocol/port_allocator_base.h"
#include "remoting/protocol/port_allocator_factory.h"
-#include "third_party/webrtc/p2p/client/httpportallocator.h"
namespace rtc {
class NetworkManager;
@@ -22,7 +22,7 @@ namespace remoting {
class FakeNetworkDispatcher;
class FakePacketSocketFactory;
-class FakePortAllocator : public cricket::HttpPortAllocatorBase {
+class FakePortAllocator : public protocol::PortAllocatorBase {
public:
FakePortAllocator(rtc::NetworkManager* network_manager,
FakePacketSocketFactory* socket_factory);
@@ -48,7 +48,7 @@ class FakePortAllocatorFactory : public protocol::PortAllocatorFactory {
FakePacketSocketFactory* socket_factory() { return socket_factory_.get(); }
// PortAllocatorFactory interface.
- scoped_ptr<cricket::HttpPortAllocatorBase> CreatePortAllocator() override;
+ scoped_ptr<protocol::PortAllocatorBase> CreatePortAllocator() override;
private:
scoped_ptr<rtc::NetworkManager> network_manager_;