mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset 17bd0777339a (bug 1164425)
This commit is contained in:
parent
d68a12a808
commit
70b8a9bab5
@ -1913,7 +1913,7 @@ BluetoothDaemonInterface::OnConnectSuccess(enum Channel aChannel)
|
||||
/* Notification channel should not be open; let's close it. */
|
||||
mNtfChannel->Close();
|
||||
}
|
||||
if (NS_FAILED(mListenSocket->Listen(mNtfChannel))) {
|
||||
if (!mListenSocket->Listen(mNtfChannel)) {
|
||||
OnConnectError(NTF_CHANNEL);
|
||||
}
|
||||
break;
|
||||
@ -2136,9 +2136,9 @@ BluetoothDaemonInterface::Init(
|
||||
mListenSocketName.AssignLiteral(BASE_SOCKET_NAME);
|
||||
}
|
||||
|
||||
rv = mListenSocket->Listen(new BluetoothDaemonConnector(mListenSocketName),
|
||||
mCmdChannel);
|
||||
if (NS_FAILED(rv)) {
|
||||
bool success = mListenSocket->Listen(
|
||||
new BluetoothDaemonConnector(mListenSocketName), mCmdChannel);
|
||||
if (!success) {
|
||||
OnConnectError(CMD_CHANNEL);
|
||||
return;
|
||||
}
|
||||
|
@ -312,14 +312,15 @@ NfcService::Start(nsINfcGonkEventListener* aListener)
|
||||
mListenSocketName = BASE_SOCKET_NAME;
|
||||
|
||||
mListenSocket = new NfcListenSocket(this);
|
||||
nsresult rv = mListenSocket->Listen(new NfcConnector(mListenSocketName),
|
||||
|
||||
bool success = mListenSocket->Listen(new NfcConnector(mListenSocketName),
|
||||
mConsumer);
|
||||
if (NS_FAILED(rv)) {
|
||||
if (!success) {
|
||||
mConsumer = nullptr;
|
||||
return rv;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
rv = NS_NewNamedThread("NfcThread", getter_AddRefs(mThread));
|
||||
nsresult rv = NS_NewNamedThread("NfcThread", getter_AddRefs(mThread));
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Can't create Nfc worker thread.");
|
||||
mListenSocket->Close();
|
||||
|
@ -31,6 +31,8 @@ public:
|
||||
UnixSocketConnector* aConnector);
|
||||
~ListenSocketIO();
|
||||
|
||||
void GetSocketAddr(nsAString& aAddrStr) const;
|
||||
|
||||
// Task callback methods
|
||||
//
|
||||
|
||||
@ -112,6 +114,26 @@ ListenSocketIO::~ListenSocketIO()
|
||||
MOZ_ASSERT(IsShutdownOnMainThread());
|
||||
}
|
||||
|
||||
void
|
||||
ListenSocketIO::GetSocketAddr(nsAString& aAddrStr) const
|
||||
{
|
||||
if (!mConnector) {
|
||||
NS_WARNING("No connector to get socket address from!");
|
||||
aAddrStr.Truncate();
|
||||
return;
|
||||
}
|
||||
|
||||
nsCString addressString;
|
||||
nsresult rv = mConnector->ConvertAddressToString(
|
||||
*reinterpret_cast<const struct sockaddr*>(&mAddress), mAddressLength,
|
||||
addressString);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
aAddrStr.Assign(NS_ConvertUTF8toUTF16(addressString));
|
||||
}
|
||||
|
||||
void
|
||||
ListenSocketIO::Listen(ConnectionOrientedSocketIO* aCOSocketIO)
|
||||
{
|
||||
@ -292,32 +314,51 @@ ListenSocket::~ListenSocket()
|
||||
MOZ_ASSERT(!mIO);
|
||||
}
|
||||
|
||||
nsresult
|
||||
bool
|
||||
ListenSocket::Listen(UnixSocketConnector* aConnector,
|
||||
ConnectionOrientedSocket* aCOSocket)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!mIO);
|
||||
MOZ_ASSERT(aConnector);
|
||||
MOZ_ASSERT(aCOSocket);
|
||||
|
||||
mIO = new ListenSocketIO(XRE_GetIOMessageLoop(), this, aConnector);
|
||||
nsAutoPtr<UnixSocketConnector> connector(aConnector);
|
||||
|
||||
if (mIO) {
|
||||
NS_WARNING("Socket already connecting/connected!");
|
||||
return false;
|
||||
}
|
||||
|
||||
mIO = new ListenSocketIO(XRE_GetIOMessageLoop(), this, connector.forget());
|
||||
|
||||
// Prepared I/O object, now start listening.
|
||||
return Listen(aCOSocket);
|
||||
}
|
||||
|
||||
nsresult
|
||||
bool
|
||||
ListenSocket::Listen(ConnectionOrientedSocket* aCOSocket)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aCOSocket);
|
||||
MOZ_ASSERT(mIO);
|
||||
MOZ_ASSERT(aCOSocket);
|
||||
|
||||
SetConnectionStatus(SOCKET_LISTENING);
|
||||
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE, new ListenSocketIO::ListenTask(mIO, aCOSocket->GetIO()));
|
||||
|
||||
return NS_OK;
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
ListenSocket::GetSocketAddr(nsAString& aAddrStr)
|
||||
{
|
||||
aAddrStr.Truncate();
|
||||
if (!mIO || GetConnectionStatus() != SOCKET_CONNECTED) {
|
||||
NS_WARNING("No socket currently open!");
|
||||
return;
|
||||
}
|
||||
mIO->GetSocketAddr(aAddrStr);
|
||||
}
|
||||
|
||||
// |SocketBase|
|
||||
|
@ -32,9 +32,10 @@ public:
|
||||
* @param aConnector Connector object for socket-type-specific functions
|
||||
* @param aCOSocket The connection-oriented socket for handling the
|
||||
* accepted connection.
|
||||
* @return NS_OK on success, or an XPCOM error code otherwise.
|
||||
*
|
||||
* @return true on listen started, false otherwise
|
||||
*/
|
||||
nsresult Listen(UnixSocketConnector* aConnector,
|
||||
bool Listen(UnixSocketConnector* aConnector,
|
||||
ConnectionOrientedSocket* aCOSocket);
|
||||
|
||||
/**
|
||||
@ -44,9 +45,15 @@ public:
|
||||
*
|
||||
* @param aCOSocket The connection-oriented socket for handling the
|
||||
* accepted connection.
|
||||
* @return NS_OK on success, or an XPCOM error code otherwise.
|
||||
*
|
||||
* @return true on listen started, false otherwise
|
||||
*/
|
||||
nsresult Listen(ConnectionOrientedSocket* aCOSocket);
|
||||
bool Listen(ConnectionOrientedSocket* aCOSocket);
|
||||
|
||||
/**
|
||||
* Get the current sockaddr for the socket
|
||||
*/
|
||||
void GetSocketAddr(nsAString& aAddrStr);
|
||||
|
||||
// Methods for |SocketBase|
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user