Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(459)

Unified Diff: remoting/protocol/port_allocator_base.h

Issue 1571943002: Simplify PortAllocatorBase and make PortAllocator creation synchronous. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/protocol/port_allocator_base.h
diff --git a/remoting/protocol/port_allocator_base.h b/remoting/protocol/port_allocator_base.h
index ee3f68c3f63bb9bbdd3801a213d651fad202231b..656a07431b02c1461d4a04482dae03f81c556aa6 100644
--- a/remoting/protocol/port_allocator_base.h
+++ b/remoting/protocol/port_allocator_base.h
@@ -8,20 +8,28 @@
#include <string>
#include <vector>
+#include "base/memory/weak_ptr.h"
#include "third_party/webrtc/p2p/client/basicportallocator.h"
namespace remoting {
namespace protocol {
+class TransportContext;
+
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(scoped_ptr<rtc::NetworkManager> network_manager,
+ scoped_ptr<rtc::PacketSocketFactory> socket_factory,
+ scoped_refptr<TransportContext> transport_context);
~PortAllocatorBase() override;
+ scoped_refptr<TransportContext> transport_context() {
+ return transport_context_;
+ }
+
// CreateSession is defined in cricket::BasicPortAllocator but is
// redefined here as pure virtual.
cricket::PortAllocatorSession* CreateSessionInternal(
@@ -30,21 +38,10 @@ class PortAllocatorBase : public cricket::BasicPortAllocator {
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_;
+ scoped_ptr<rtc::NetworkManager> network_manager_;
+ scoped_ptr<rtc::PacketSocketFactory> socket_factory_;
+ scoped_refptr<TransportContext> transport_context_;
};
class PortAllocatorSessionBase : public cricket::BasicPortAllocatorSession {
@@ -53,28 +50,33 @@ class PortAllocatorSessionBase : public cricket::BasicPortAllocatorSession {
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);
+ const std::string& ice_pwd);
~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);
+ void ReceiveSessionResponse(const std::string& response);
protected:
std::string GetSessionRequestUrl();
+
void GetPortConfigurations() override;
+ void OnJingleInfo(std::vector<rtc::SocketAddress> stun_hosts,
+ std::vector<std::string> relay_hosts,
+ std::string relay_token);
void TryCreateRelaySession();
+
PortAllocatorBase* allocator() override;
+ const std::string& relay_token() const { return relay_token_; }
+
private:
- std::vector<std::string> relay_hosts_;
std::vector<rtc::SocketAddress> stun_hosts_;
+ std::vector<std::string> relay_hosts_;
std::string relay_token_;
- int attempts_;
+
+ int attempts_ = 0;
+
+ base::WeakPtrFactory<PortAllocatorSessionBase> weak_factory_;
};
} // namespace protocol

Powered by Google App Engine
This is Rietveld 408576698