mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1156352: Remove |UnixSocketRawData| from socket I/O interfaces, r=kmachulis
This commit is contained in:
parent
99ec461b24
commit
0f58b21c4e
@ -86,9 +86,9 @@ public:
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
}
|
||||
|
||||
void Send(UnixSocketRawData* aData)
|
||||
void Send(UnixSocketIOBuffer* aBuffer)
|
||||
{
|
||||
EnqueueData(aData);
|
||||
EnqueueData(aBuffer);
|
||||
AddWatchers(WRITE_WATCHER, false);
|
||||
}
|
||||
|
||||
@ -656,30 +656,25 @@ BluetoothSocket::CloseSocket()
|
||||
NotifyDisconnect();
|
||||
}
|
||||
|
||||
bool
|
||||
BluetoothSocket::SendSocketData(UnixSocketRawData* aData)
|
||||
void
|
||||
BluetoothSocket::SendSocketData(UnixSocketIOBuffer* aBuffer)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
NS_ENSURE_TRUE(mImpl, false);
|
||||
|
||||
MOZ_ASSERT(mImpl);
|
||||
MOZ_ASSERT(!mImpl->IsShutdownOnMainThread());
|
||||
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
new SocketIOSendTask<DroidSocketImpl, UnixSocketRawData>(mImpl, aData));
|
||||
|
||||
return true;
|
||||
new SocketIOSendTask<DroidSocketImpl, UnixSocketIOBuffer>(mImpl, aBuffer));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothSocket::ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage)
|
||||
BluetoothSocket::ReceiveSocketData(nsAutoPtr<UnixSocketBuffer>& aBuffer)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(mObserver);
|
||||
|
||||
nsAutoPtr<mozilla::ipc::UnixSocketBuffer> buffer(aMessage.forget());
|
||||
|
||||
mObserver->ReceiveSocketData(this, buffer);
|
||||
mObserver->ReceiveSocketData(this, aBuffer);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -32,15 +32,15 @@ public:
|
||||
const BluetoothUuid& aServiceUuid,
|
||||
int aChannel);
|
||||
|
||||
void CloseSocket();
|
||||
void CloseSocket() override;
|
||||
|
||||
bool SendSocketData(mozilla::ipc::UnixSocketRawData* aData);
|
||||
void SendSocketData(mozilla::ipc::UnixSocketIOBuffer* aBuffer) override;
|
||||
|
||||
virtual void OnConnectSuccess() override;
|
||||
virtual void OnConnectError() override;
|
||||
virtual void OnDisconnect() override;
|
||||
virtual void ReceiveSocketData(
|
||||
nsAutoPtr<mozilla::ipc::UnixSocketRawData>& aMessage) override;
|
||||
nsAutoPtr<mozilla::ipc::UnixSocketBuffer>& aBuffer) override;
|
||||
|
||||
inline void GetAddress(nsAString& aDeviceAddress)
|
||||
{
|
||||
|
@ -67,7 +67,7 @@ public:
|
||||
*/
|
||||
void Connect();
|
||||
|
||||
void Send(UnixSocketRawData* aData);
|
||||
void Send(UnixSocketIOBuffer* aBuffer);
|
||||
|
||||
// I/O callback methods
|
||||
//
|
||||
@ -301,9 +301,9 @@ BluetoothSocket::BluetoothSocketIO::Connect()
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothSocket::BluetoothSocketIO::Send(UnixSocketRawData* aData)
|
||||
BluetoothSocket::BluetoothSocketIO::Send(UnixSocketIOBuffer* aBuffer)
|
||||
{
|
||||
EnqueueData(aData);
|
||||
EnqueueData(aBuffer);
|
||||
AddWatchers(WRITE_WATCHER, false);
|
||||
}
|
||||
|
||||
@ -607,14 +607,12 @@ BluetoothSocket::Listen(const nsAString& aServiceName,
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothSocket::ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage)
|
||||
BluetoothSocket::ReceiveSocketData(nsAutoPtr<UnixSocketBuffer>& aBuffer)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(mObserver);
|
||||
|
||||
nsAutoPtr<UnixSocketBuffer> buffer(aMessage.forget());
|
||||
|
||||
mObserver->ReceiveSocketData(this, buffer);
|
||||
mObserver->ReceiveSocketData(this, aBuffer);
|
||||
}
|
||||
|
||||
void
|
||||
@ -641,20 +639,16 @@ BluetoothSocket::OnDisconnect()
|
||||
mObserver->OnSocketDisconnect(this);
|
||||
}
|
||||
|
||||
bool
|
||||
BluetoothSocket::SendSocketData(UnixSocketRawData* aData)
|
||||
void
|
||||
BluetoothSocket::SendSocketData(UnixSocketIOBuffer* aBuffer)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (!mIO) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(mIO);
|
||||
MOZ_ASSERT(!mIO->IsShutdownOnMainThread());
|
||||
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
new SocketIOSendTask<BluetoothSocketIO, UnixSocketRawData>(mIO, aData));
|
||||
|
||||
return true;
|
||||
new SocketIOSendTask<BluetoothSocketIO, UnixSocketIOBuffer>(mIO, aBuffer));
|
||||
}
|
||||
|
||||
bool
|
||||
@ -664,14 +658,7 @@ BluetoothSocket::SendSocketData(const nsACString& aStr)
|
||||
return false;
|
||||
}
|
||||
|
||||
nsAutoPtr<UnixSocketRawData> data(
|
||||
new UnixSocketRawData(aStr.BeginReading(), aStr.Length()));
|
||||
|
||||
if (!SendSocketData(data)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
unused << data.forget();
|
||||
SendSocketData(new UnixSocketRawData(aStr.BeginReading(), aStr.Length()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
virtual void OnConnectError() override;
|
||||
virtual void OnDisconnect() override;
|
||||
virtual void ReceiveSocketData(
|
||||
nsAutoPtr<mozilla::ipc::UnixSocketRawData>& aMessage) override;
|
||||
nsAutoPtr<mozilla::ipc::UnixSocketBuffer>& aBuffer) override;
|
||||
|
||||
inline void GetAddress(nsAString& aDeviceAddress)
|
||||
{
|
||||
@ -56,11 +56,9 @@ public:
|
||||
* Queue data to be sent to the socket on the IO thread. Can only be called on
|
||||
* originating thread.
|
||||
*
|
||||
* @param aMessage Data to be sent to socket
|
||||
*
|
||||
* @return true if data is queued, false otherwise (i.e. not connected)
|
||||
* @param aBuffer Data to be sent to socket
|
||||
*/
|
||||
bool SendSocketData(mozilla::ipc::UnixSocketRawData* aMessage);
|
||||
void SendSocketData(mozilla::ipc::UnixSocketIOBuffer* aBuffer) override;
|
||||
|
||||
/**
|
||||
* Convenience function for sending strings to the socket (common in bluetooth
|
||||
@ -101,7 +99,7 @@ public:
|
||||
* Queues the internal representation of socket for deletion. Can be called
|
||||
* from main thread.
|
||||
*/
|
||||
void CloseSocket();
|
||||
void CloseSocket() override;
|
||||
|
||||
/**
|
||||
* Get the current sockaddr for the socket
|
||||
|
@ -810,12 +810,9 @@ KeyStore::StreamSocket::OnDisconnect()
|
||||
}
|
||||
|
||||
void
|
||||
KeyStore::StreamSocket::ReceiveSocketData(
|
||||
nsAutoPtr<UnixSocketRawData>& aMessage)
|
||||
KeyStore::StreamSocket::ReceiveSocketData(nsAutoPtr<UnixSocketBuffer>& aBuffer)
|
||||
{
|
||||
nsAutoPtr<UnixSocketBuffer> buffer(aMessage.forget());
|
||||
|
||||
mKeyStore->ReceiveSocketData(buffer);
|
||||
mKeyStore->ReceiveSocketData(aBuffer);
|
||||
}
|
||||
|
||||
ConnectionOrientedSocketIO*
|
||||
|
@ -147,7 +147,7 @@ private:
|
||||
void OnConnectError() override;
|
||||
void OnDisconnect() override;
|
||||
|
||||
void ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage) override;
|
||||
void ReceiveSocketData(nsAutoPtr<UnixSocketBuffer>& aBuffer) override;
|
||||
|
||||
// ConnectionOrientedSocket
|
||||
//
|
||||
|
@ -188,13 +188,12 @@ NfcConsumer::PostToNfcDaemon(const uint8_t* aData, size_t aSize)
|
||||
}
|
||||
|
||||
void
|
||||
NfcConsumer::ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aBuffer)
|
||||
NfcConsumer::ReceiveSocketData(nsAutoPtr<UnixSocketBuffer>& aBuffer)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (mListener) {
|
||||
nsAutoPtr<mozilla::ipc::UnixSocketBuffer> buffer(aBuffer.forget());
|
||||
mListener->ReceiveSocketData(buffer);
|
||||
mListener->ReceiveSocketData(aBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,8 +72,7 @@ public:
|
||||
ConnectionOrientedSocketIO* GetIO() override;
|
||||
|
||||
private:
|
||||
void ReceiveSocketData(
|
||||
nsAutoPtr<UnixSocketRawData>& aBuffer) override;
|
||||
void ReceiveSocketData(nsAutoPtr<UnixSocketBuffer>& aBuffer) override;
|
||||
|
||||
void OnConnectSuccess() override;
|
||||
void OnConnectError() override;
|
||||
|
@ -369,11 +369,11 @@ RilConsumer::Shutdown()
|
||||
}
|
||||
|
||||
void
|
||||
RilConsumer::ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage)
|
||||
RilConsumer::ReceiveSocketData(nsAutoPtr<UnixSocketBuffer>& aBuffer)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
nsRefPtr<DispatchRILEvent> dre(new DispatchRILEvent(mClientId, aMessage.forget()));
|
||||
nsRefPtr<DispatchRILEvent> dre(new DispatchRILEvent(mClientId, aBuffer.forget()));
|
||||
mDispatcher->PostTask(dre);
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ private:
|
||||
RilConsumer(unsigned long aClientId,
|
||||
mozilla::dom::workers::WorkerCrossThreadDispatcher* aDispatcher);
|
||||
|
||||
void ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage) override;
|
||||
void ReceiveSocketData(nsAutoPtr<UnixSocketBuffer>& aBuffer) override;
|
||||
|
||||
void OnConnectSuccess() override;
|
||||
void OnConnectError() override;
|
||||
|
@ -283,13 +283,13 @@ SocketIOBase::~SocketIOBase()
|
||||
{ }
|
||||
|
||||
void
|
||||
SocketIOBase::EnqueueData(UnixSocketRawData* aData)
|
||||
SocketIOBase::EnqueueData(UnixSocketIOBuffer* aBuffer)
|
||||
{
|
||||
if (!aData->GetSize()) {
|
||||
delete aData; // delete empty data immediately
|
||||
if (!aBuffer->GetSize()) {
|
||||
delete aBuffer; // delete empty data immediately
|
||||
return;
|
||||
}
|
||||
mOutgoingQ.AppendElement(aData);
|
||||
mOutgoingQ.AppendElement(aBuffer);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -323,19 +323,17 @@ public:
|
||||
* Function to be called whenever data is received. This is only called on the
|
||||
* main thread.
|
||||
*
|
||||
* @param aMessage Data received from the socket.
|
||||
* @param aBuffer Data received from the socket.
|
||||
*/
|
||||
virtual void ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage) = 0;
|
||||
virtual void ReceiveSocketData(nsAutoPtr<UnixSocketBuffer>& aBuffer) = 0;
|
||||
|
||||
/**
|
||||
* Queue data to be sent to the socket on the IO thread. Can only be called on
|
||||
* originating thread.
|
||||
*
|
||||
* @param aMessage Data to be sent to socket
|
||||
*
|
||||
* @return true if data is queued, false otherwise (i.e. not connected)
|
||||
* @param aBuffer Data to be sent to socket
|
||||
*/
|
||||
virtual bool SendSocketData(UnixSocketRawData* aMessage) = 0;
|
||||
virtual void SendSocketData(UnixSocketIOBuffer* aBuffer) = 0;
|
||||
};
|
||||
|
||||
//
|
||||
@ -424,9 +422,9 @@ template <typename T>
|
||||
class SocketIOReceiveRunnable final : public SocketIORunnable<T>
|
||||
{
|
||||
public:
|
||||
SocketIOReceiveRunnable(T* aIO, UnixSocketRawData* aData)
|
||||
: SocketIORunnable<T>(aIO)
|
||||
, mData(aData)
|
||||
SocketIOReceiveRunnable(T* aIO, UnixSocketBuffer* aBuffer)
|
||||
: SocketIORunnable<T>(aIO)
|
||||
, mBuffer(aBuffer)
|
||||
{ }
|
||||
|
||||
NS_IMETHOD Run() override
|
||||
@ -445,13 +443,13 @@ public:
|
||||
SocketConsumerBase* consumer = io->GetConsumer();
|
||||
MOZ_ASSERT(consumer);
|
||||
|
||||
consumer->ReceiveSocketData(mData);
|
||||
consumer->ReceiveSocketData(mBuffer);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
nsAutoPtr<UnixSocketRawData> mData;
|
||||
nsAutoPtr<UnixSocketBuffer> mBuffer;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
@ -518,7 +516,7 @@ class SocketIOBase
|
||||
public:
|
||||
virtual ~SocketIOBase();
|
||||
|
||||
void EnqueueData(UnixSocketRawData* aData);
|
||||
void EnqueueData(UnixSocketIOBuffer* aBuffer);
|
||||
bool HasPendingData() const;
|
||||
|
||||
template <typename T>
|
||||
@ -563,7 +561,7 @@ public:
|
||||
MOZ_ASSERT(aIO);
|
||||
|
||||
while (HasPendingData()) {
|
||||
UnixSocketRawData* outgoing = mOutgoingQ.ElementAt(0);
|
||||
UnixSocketIOBuffer* outgoing = mOutgoingQ.ElementAt(0);
|
||||
|
||||
ssize_t res = outgoing->Send(aFd);
|
||||
if (res < 0) {
|
||||
@ -593,7 +591,7 @@ private:
|
||||
/**
|
||||
* Raw data queue. Must be pushed/popped from I/O thread only.
|
||||
*/
|
||||
nsTArray<UnixSocketRawData*> mOutgoingQ;
|
||||
nsTArray<UnixSocketIOBuffer*> mOutgoingQ;
|
||||
};
|
||||
|
||||
//
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "StreamSocket.h"
|
||||
#include <fcntl.h>
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/unused.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "UnixSocketConnector.h"
|
||||
|
||||
@ -73,7 +72,7 @@ public:
|
||||
*/
|
||||
void Connect();
|
||||
|
||||
void Send(UnixSocketRawData* aData);
|
||||
void Send(UnixSocketIOBuffer* aBuffer);
|
||||
|
||||
// I/O callback methods
|
||||
//
|
||||
@ -327,7 +326,7 @@ StreamSocketIO::Connect()
|
||||
}
|
||||
|
||||
void
|
||||
StreamSocketIO::Send(UnixSocketRawData* aData)
|
||||
StreamSocketIO::Send(UnixSocketIOBuffer* aData)
|
||||
{
|
||||
EnqueueData(aData);
|
||||
AddWatchers(WRITE_WATCHER, false);
|
||||
@ -558,20 +557,16 @@ StreamSocket::~StreamSocket()
|
||||
MOZ_ASSERT(!mIO);
|
||||
}
|
||||
|
||||
bool
|
||||
StreamSocket::SendSocketData(UnixSocketRawData* aData)
|
||||
void
|
||||
StreamSocket::SendSocketData(UnixSocketIOBuffer* aBuffer)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (!mIO) {
|
||||
return false;
|
||||
}
|
||||
MOZ_ASSERT(mIO);
|
||||
|
||||
MOZ_ASSERT(!mIO->IsShutdownOnMainThread());
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
new SocketIOSendTask<StreamSocketIO, UnixSocketRawData>(mIO, aData));
|
||||
|
||||
return true;
|
||||
new SocketIOSendTask<StreamSocketIO, UnixSocketIOBuffer>(mIO, aBuffer));
|
||||
}
|
||||
|
||||
bool
|
||||
@ -581,14 +576,7 @@ StreamSocket::SendSocketData(const nsACString& aStr)
|
||||
return false;
|
||||
}
|
||||
|
||||
nsAutoPtr<UnixSocketRawData> data(
|
||||
new UnixSocketRawData(aStr.BeginReading(), aStr.Length()));
|
||||
|
||||
if (!SendSocketData(data)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
unused << data.forget();
|
||||
SendSocketData(new UnixSocketRawData(aStr.BeginReading(), aStr.Length()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -26,17 +26,17 @@ public:
|
||||
* Queue data to be sent to the socket on the IO thread. Can only be called on
|
||||
* originating thread.
|
||||
*
|
||||
* @param aMessage Data to be sent to socket
|
||||
*
|
||||
* @return true if data is queued, false otherwise (i.e. not connected)
|
||||
* @param aBuffer Data to be sent to socket
|
||||
*/
|
||||
bool SendSocketData(UnixSocketRawData* aMessage);
|
||||
void SendSocketData(UnixSocketIOBuffer* aBuffer);
|
||||
|
||||
/**
|
||||
* 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)
|
||||
|
Loading…
Reference in New Issue
Block a user