mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 1061174 - Part 1 - imported patch test_udpsocket-debug.patch. r=khuey
This commit is contained in:
parent
9724ca2e3a
commit
7b1d4f7c79
@ -20,6 +20,10 @@
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_ISUPPORTS(UDPSocket::ListenerProxy,
|
||||
nsIUDPSocketListener,
|
||||
nsIUDPSocketInternal)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(UDPSocket)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(UDPSocket, DOMEventTargetHelper)
|
||||
@ -175,6 +179,11 @@ UDPSocket::CloseWithReason(nsresult aReason)
|
||||
|
||||
mReadyState = SocketReadyState::Closed;
|
||||
|
||||
if (mListenerProxy) {
|
||||
mListenerProxy->Disconnect();
|
||||
mListenerProxy = nullptr;
|
||||
}
|
||||
|
||||
if (mSocket) {
|
||||
mSocket->Close();
|
||||
mSocket = nullptr;
|
||||
@ -430,7 +439,9 @@ UDPSocket::InitLocal(const nsAString& aLocalAddress,
|
||||
}
|
||||
mLocalPort.SetValue(localPort);
|
||||
|
||||
rv = mSocket->AsyncListen(this);
|
||||
mListenerProxy = new ListenerProxy(this);
|
||||
|
||||
rv = mSocket->AsyncListen(mListenerProxy);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
@ -458,7 +469,14 @@ UDPSocket::InitRemote(const nsAString& aLocalAddress,
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = sock->Bind(this, NS_ConvertUTF16toUTF8(aLocalAddress), aLocalPort, mAddressReuse, mLoopback);
|
||||
mListenerProxy = new ListenerProxy(this);
|
||||
|
||||
rv = sock->Bind(mListenerProxy,
|
||||
NS_ConvertUTF16toUTF8(aLocalAddress),
|
||||
aLocalPort,
|
||||
mAddressReuse,
|
||||
mLoopback);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -128,6 +128,30 @@ public:
|
||||
ErrorResult& aRv);
|
||||
|
||||
private:
|
||||
class ListenerProxy : public nsIUDPSocketListener
|
||||
, public nsIUDPSocketInternal
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_FORWARD_SAFE_NSIUDPSOCKETLISTENER(mSocket)
|
||||
NS_FORWARD_SAFE_NSIUDPSOCKETINTERNAL(mSocket)
|
||||
|
||||
explicit ListenerProxy(UDPSocket* aSocket)
|
||||
: mSocket(aSocket)
|
||||
{
|
||||
}
|
||||
|
||||
void Disconnect()
|
||||
{
|
||||
mSocket = nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
virtual ~ListenerProxy() {}
|
||||
|
||||
UDPSocket* mSocket;
|
||||
};
|
||||
|
||||
UDPSocket(nsPIDOMWindow* aOwner,
|
||||
const nsCString& aRemoteAddress,
|
||||
const Nullable<uint16_t>& aRemotePort);
|
||||
@ -176,6 +200,7 @@ private:
|
||||
|
||||
nsCOMPtr<nsIUDPSocket> mSocket;
|
||||
nsCOMPtr<nsIUDPSocketChild> mSocketChild;
|
||||
nsRefPtr<ListenerProxy> mListenerProxy;
|
||||
|
||||
struct MulticastCommand {
|
||||
enum CommandType { Join, Leave };
|
||||
|
Loading…
Reference in New Issue
Block a user