From 72bcc878802cd709b6ac4eff03ee2487c285873d Mon Sep 17 00:00:00 2001 From: "Byron Campen [:bwc]" Date: Tue, 17 Sep 2019 18:19:19 +0000 Subject: [PATCH] Bug 1569183: Simplify how NrSockets specify whether they're proxied or not. r=mjf Differential Revision: https://phabricator.services.mozilla.com/D46032 --HG-- extra : moz-landing-system : lando --- media/mtransport/nr_socket_prsock.h | 6 ------ media/mtransport/nr_socket_tcp.cpp | 4 +++- media/mtransport/nr_socket_tcp.h | 5 ----- media/mtransport/nricectx.cpp | 4 ---- media/mtransport/test/dummysocket.h | 2 -- media/mtransport/test_nr_socket.cpp | 11 ----------- media/mtransport/test_nr_socket.h | 1 - 7 files changed, 3 insertions(+), 30 deletions(-) diff --git a/media/mtransport/nr_socket_prsock.h b/media/mtransport/nr_socket_prsock.h index 2cf24149f2fd..30c7d33f6b60 100644 --- a/media/mtransport/nr_socket_prsock.h +++ b/media/mtransport/nr_socket_prsock.h @@ -123,8 +123,6 @@ class NrSocketBase { virtual int listen(int backlog) = 0; virtual int accept(nr_transport_addr* addrp, nr_socket** sockp) = 0; - virtual bool IsProxied() const = 0; - // Implementations of the async_event APIs virtual int async_wait(int how, NR_async_cb cb, void* cb_arg, char* function, int line); @@ -187,8 +185,6 @@ class NrSocket : public NrSocketBase, public nsASocketHandler { virtual int listen(int backlog) override; virtual int accept(nr_transport_addr* addrp, nr_socket** sockp) override; - virtual bool IsProxied() const override { return false; } - protected: virtual ~NrSocket() { if (fd_) PR_Close(fd_); @@ -267,8 +263,6 @@ class NrUdpSocketIpc : public NrSocketIpc { virtual int listen(int backlog) override; virtual int accept(nr_transport_addr* addrp, nr_socket** sockp) override; - virtual bool IsProxied() const override { return false; } - private: virtual ~NrUdpSocketIpc(); diff --git a/media/mtransport/nr_socket_tcp.cpp b/media/mtransport/nr_socket_tcp.cpp index 2abd39068778..9e57999906c5 100644 --- a/media/mtransport/nr_socket_tcp.cpp +++ b/media/mtransport/nr_socket_tcp.cpp @@ -248,7 +248,9 @@ void NrTcpSocket::OnClose(nsresult aReason) { void NrTcpSocket::OnConnected(const nsCString& aProxyType) { r_log(LOG_GENERIC, LOG_DEBUG, "NrTcpSocket::OnConnected %p\n", this); - mProxyType = aProxyType; + if (aProxyType != "" && aProxyType != "direct") { + my_addr_.is_proxied = true; + } DoCallbacks(); } diff --git a/media/mtransport/nr_socket_tcp.h b/media/mtransport/nr_socket_tcp.h index bb206bcde55c..5da54fd504ee 100644 --- a/media/mtransport/nr_socket_tcp.h +++ b/media/mtransport/nr_socket_tcp.h @@ -86,10 +86,6 @@ class NrTcpSocket : public NrSocketBase, public WebrtcTCPSocketCallback { int listen(int aBacklog) override; int accept(nr_transport_addr* aAddr, nr_socket** aSocket) override; - bool IsProxied() const override { - return mProxyType != "" && mProxyType != "direct"; - } - // WebrtcTCPSocketCallback void OnClose(nsresult aReason) override; void OnConnected(const nsCString& aProxyType) override; @@ -109,7 +105,6 @@ class NrTcpSocket : public NrSocketBase, public WebrtcTCPSocketCallback { bool mClosed; size_t mReadOffset; - nsCString mProxyType; std::list mReadQueue; std::shared_ptr mConfig; diff --git a/media/mtransport/nricectx.cpp b/media/mtransport/nricectx.cpp index d36b68408528..6dbc4e8180bd 100644 --- a/media/mtransport/nricectx.cpp +++ b/media/mtransport/nricectx.cpp @@ -1095,10 +1095,6 @@ int nr_socket_local_create(void* obj, nr_transport_addr* addr, if (r) { ABORT(r); } - // TODO(bug 1569183): This will start out false, and may become true once the - // socket class figures out whether a proxy needs to be used (this may be as - // late as when it establishes a connection). - addr->is_proxied = sock->IsProxied(); r = nr_socket_create_int(static_cast(sock), sock->vtbl(), sockp); if (r) ABORT(r); diff --git a/media/mtransport/test/dummysocket.h b/media/mtransport/test/dummysocket.h index f4c70b7072ed..882bbd86e4a2 100644 --- a/media/mtransport/test/dummysocket.h +++ b/media/mtransport/test/dummysocket.h @@ -91,8 +91,6 @@ class DummySocket : public NrSocketBase { return 0; } - virtual bool IsProxied() const override { return false; } - virtual int write(const void* msg, size_t len, size_t* written) override { size_t to_write = std::min(len, writable_); diff --git a/media/mtransport/test_nr_socket.cpp b/media/mtransport/test_nr_socket.cpp index e8a7db0cd526..821d3f8dd0f9 100644 --- a/media/mtransport/test_nr_socket.cpp +++ b/media/mtransport/test_nr_socket.cpp @@ -282,17 +282,6 @@ int TestNrSocket::accept(nr_transport_addr* addrp, nr_socket** sockp) { return 0; } -bool TestNrSocket::IsProxied() const { - if (internal_socket_->my_addr().protocol == IPPROTO_UDP || - port_mappings_.empty()) { - // UDP and the no-nat case - return internal_socket_->IsProxied(); - } - // This is TCP only - MOZ_ASSERT(port_mappings_.size() == 1); - return port_mappings_.front()->external_socket_->IsProxied(); -} - void TestNrSocket::process_delayed_cb(NR_SOCKET s, int how, void* cb_arg) { DeferredPacket* op = static_cast(cb_arg); op->socket_->timer_handle_ = nullptr; diff --git a/media/mtransport/test_nr_socket.h b/media/mtransport/test_nr_socket.h index 49de1eb20e8d..bb8fb86273c0 100644 --- a/media/mtransport/test_nr_socket.h +++ b/media/mtransport/test_nr_socket.h @@ -225,7 +225,6 @@ class TestNrSocket : public NrSocketBase { int listen(int backlog) override; int accept(nr_transport_addr* addrp, nr_socket** sockp) override; - bool IsProxied() const override; int async_wait(int how, NR_async_cb cb, void* cb_arg, char* function, int line) override; int cancel(int how) override;