mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset 2fd186d1a288 (bug 1164425)
This commit is contained in:
parent
70b8a9bab5
commit
e62550b3f7
@ -217,7 +217,7 @@ RilConsumer::RilConsumer(unsigned long aClientId,
|
|||||||
mAddress = addr_un.sun_path;
|
mAddress = addr_un.sun_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
Connect(new RilConnector(mAddress, mClientId));
|
Connect(new RilConnector(mAddress, mClientId), mAddress.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
@ -288,10 +288,10 @@ void
|
|||||||
RilConsumer::OnDisconnect()
|
RilConsumer::OnDisconnect()
|
||||||
{
|
{
|
||||||
CHROMIUM_LOG("RIL[%lu]: %s\n", mClientId, __FUNCTION__);
|
CHROMIUM_LOG("RIL[%lu]: %s\n", mClientId, __FUNCTION__);
|
||||||
if (mShutdown) {
|
if (!mShutdown) {
|
||||||
return;
|
Connect(new RilConnector(mAddress, mClientId), mAddress.get(),
|
||||||
|
GetSuggestedConnectDelayMs());
|
||||||
}
|
}
|
||||||
Connect(new RilConnector(mAddress, mClientId), GetSuggestedConnectDelayMs());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnectionOrientedSocketIO*
|
ConnectionOrientedSocketIO*
|
||||||
|
@ -37,6 +37,8 @@ public:
|
|||||||
UnixSocketConnector* aConnector);
|
UnixSocketConnector* aConnector);
|
||||||
~StreamSocketIO();
|
~StreamSocketIO();
|
||||||
|
|
||||||
|
void GetSocketAddr(nsAString& aAddrStr) const;
|
||||||
|
|
||||||
StreamSocket* GetStreamSocket();
|
StreamSocket* GetStreamSocket();
|
||||||
DataSocket* GetDataSocket();
|
DataSocket* GetDataSocket();
|
||||||
|
|
||||||
@ -167,6 +169,26 @@ StreamSocketIO::~StreamSocketIO()
|
|||||||
MOZ_ASSERT(IsShutdownOnMainThread());
|
MOZ_ASSERT(IsShutdownOnMainThread());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
StreamSocketIO::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));
|
||||||
|
}
|
||||||
|
|
||||||
StreamSocket*
|
StreamSocket*
|
||||||
StreamSocketIO::GetStreamSocket()
|
StreamSocketIO::GetStreamSocket()
|
||||||
{
|
{
|
||||||
@ -508,17 +530,47 @@ StreamSocket::~StreamSocket()
|
|||||||
MOZ_ASSERT(!mIO);
|
MOZ_ASSERT(!mIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
bool
|
||||||
|
StreamSocket::SendSocketData(const nsACString& aStr)
|
||||||
|
{
|
||||||
|
if (aStr.Length() > MAX_READ_SIZE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SendSocketData(new UnixSocketRawData(aStr.BeginReading(), aStr.Length()));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
StreamSocket::GetSocketAddr(nsAString& aAddrStr)
|
||||||
|
{
|
||||||
|
aAddrStr.Truncate();
|
||||||
|
if (!mIO || GetConnectionStatus() != SOCKET_CONNECTED) {
|
||||||
|
NS_WARNING("No socket currently open!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mIO->GetSocketAddr(aAddrStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
StreamSocket::Connect(UnixSocketConnector* aConnector,
|
StreamSocket::Connect(UnixSocketConnector* aConnector,
|
||||||
|
const char* aAddress,
|
||||||
int aDelayMs)
|
int aDelayMs)
|
||||||
{
|
{
|
||||||
|
MOZ_ASSERT(aConnector);
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
MOZ_ASSERT(!mIO);
|
|
||||||
|
nsAutoPtr<UnixSocketConnector> connector(aConnector);
|
||||||
|
|
||||||
|
if (mIO) {
|
||||||
|
NS_WARNING("Socket already connecting/connected!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
MessageLoop* ioLoop = XRE_GetIOMessageLoop();
|
MessageLoop* ioLoop = XRE_GetIOMessageLoop();
|
||||||
mIO = new StreamSocketIO(ioLoop, this, aConnector);
|
mIO = new StreamSocketIO(ioLoop, this, connector.forget());
|
||||||
SetConnectionStatus(SOCKET_CONNECTING);
|
SetConnectionStatus(SOCKET_CONNECTING);
|
||||||
|
|
||||||
if (aDelayMs > 0) {
|
if (aDelayMs > 0) {
|
||||||
StreamSocketIO::DelayedConnectTask* connectTask =
|
StreamSocketIO::DelayedConnectTask* connectTask =
|
||||||
new StreamSocketIO::DelayedConnectTask(mIO);
|
new StreamSocketIO::DelayedConnectTask(mIO);
|
||||||
@ -527,7 +579,8 @@ StreamSocket::Connect(UnixSocketConnector* aConnector,
|
|||||||
} else {
|
} else {
|
||||||
ioLoop->PostTask(FROM_HERE, new StreamSocketIO::ConnectTask(mIO));
|
ioLoop->PostTask(FROM_HERE, new StreamSocketIO::ConnectTask(mIO));
|
||||||
}
|
}
|
||||||
return NS_OK;
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnectionOrientedSocketIO*
|
ConnectionOrientedSocketIO*
|
||||||
@ -567,13 +620,16 @@ void
|
|||||||
StreamSocket::Close()
|
StreamSocket::Close()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
MOZ_ASSERT(mIO);
|
|
||||||
|
if (!mIO) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
mIO->CancelDelayedConnectTask();
|
mIO->CancelDelayedConnectTask();
|
||||||
|
|
||||||
// From this point on, we consider |mIO| as being deleted. We sever
|
// From this point on, we consider mIO as being deleted.
|
||||||
// the relationship here so any future calls to |Connect| will create
|
// We sever the relationship here so any future calls to listen or connect
|
||||||
// a new I/O object.
|
// will create a new implementation.
|
||||||
mIO->ShutdownOnMainThread();
|
mIO->ShutdownOnMainThread();
|
||||||
|
|
||||||
XRE_GetIOMessageLoop()->PostTask(FROM_HERE, new SocketIOShutdownTask(mIO));
|
XRE_GetIOMessageLoop()->PostTask(FROM_HERE, new SocketIOShutdownTask(mIO));
|
||||||
|
@ -28,15 +28,37 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void ReceiveSocketData(nsAutoPtr<UnixSocketBuffer>& aBuffer) = 0;
|
virtual void ReceiveSocketData(nsAutoPtr<UnixSocketBuffer>& aBuffer) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience function for sending strings to the socket (common in bluetooth
|
||||||
|
* profile usage). Converts to a UnixSocketRawData struct. Can only be called
|
||||||
|
* on originating thread.
|
||||||
|
*
|
||||||
|
* TODO: Move this method into Bluetooth module.
|
||||||
|
*
|
||||||
|
* @param aMessage String to be sent to socket
|
||||||
|
*
|
||||||
|
* @return true if data is queued, false otherwise (i.e. not connected)
|
||||||
|
*/
|
||||||
|
bool SendSocketData(const nsACString& aMessage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts a task on the socket that will try to connect to a socket in a
|
* Starts a task on the socket that will try to connect to a socket in a
|
||||||
* non-blocking manner.
|
* non-blocking manner.
|
||||||
*
|
*
|
||||||
* @param aConnector Connector object for socket type specific functions
|
* @param aConnector Connector object for socket type specific functions
|
||||||
* @param aDelayMs Time delay in milliseconds.
|
* @param aAddress Address to connect to.
|
||||||
* @return NS_OK on success, or an XPCOM error code otherwise.
|
* @param aDelayMs Time delay in milli-seconds.
|
||||||
|
*
|
||||||
|
* @return true on connect task started, false otherwise.
|
||||||
*/
|
*/
|
||||||
nsresult Connect(UnixSocketConnector* aConnector, int aDelayMs = 0);
|
bool Connect(UnixSocketConnector* aConnector,
|
||||||
|
const char* aAddress,
|
||||||
|
int aDelayMs = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current sockaddr for the socket
|
||||||
|
*/
|
||||||
|
void GetSocketAddr(nsAString& aAddrStr);
|
||||||
|
|
||||||
// Methods for |DataSocket|
|
// Methods for |DataSocket|
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user