mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1036977: Add result handler for Bluetooth Socket interface (under bluetooth2/), r=btian
This commit is contained in:
parent
45a8eef1a9
commit
970da4830d
@ -84,6 +84,36 @@ struct interface_traits<BluetoothSocketInterface>
|
||||
}
|
||||
};
|
||||
|
||||
typedef
|
||||
BluetoothInterfaceRunnable1<BluetoothSocketResultHandler, void, int>
|
||||
BluetoothSocketIntResultRunnable;
|
||||
|
||||
typedef
|
||||
BluetoothInterfaceRunnable1<BluetoothSocketResultHandler, void, bt_status_t>
|
||||
BluetoothSocketErrorRunnable;
|
||||
|
||||
static nsresult
|
||||
DispatchBluetoothSocketResult(BluetoothSocketResultHandler* aRes,
|
||||
void (BluetoothSocketResultHandler::*aMethod)(int),
|
||||
int aArg, bt_status_t aStatus)
|
||||
{
|
||||
MOZ_ASSERT(aRes);
|
||||
|
||||
nsRunnable* runnable;
|
||||
|
||||
if (aStatus == BT_STATUS_SUCCESS) {
|
||||
runnable = new BluetoothSocketIntResultRunnable(aRes, aMethod, aArg);
|
||||
} else {
|
||||
runnable = new BluetoothSocketErrorRunnable(aRes,
|
||||
&BluetoothSocketResultHandler::OnError, aStatus);
|
||||
}
|
||||
nsresult rv = NS_DispatchToMainThread(runnable);
|
||||
if (NS_FAILED(rv)) {
|
||||
BT_WARNING("NS_DispatchToMainThread failed: %X", rv);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
bt_status_t
|
||||
BluetoothSocketInterface::Listen(btsock_type_t aType,
|
||||
const char* aServiceName,
|
||||
|
@ -24,6 +24,22 @@ class BluetoothInterface;
|
||||
// Socket Interface
|
||||
//
|
||||
|
||||
class BluetoothSocketResultHandler
|
||||
{
|
||||
public:
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothSocketResultHandler)
|
||||
|
||||
virtual ~BluetoothSocketResultHandler() { }
|
||||
|
||||
virtual void OnError(bt_status_t aStatus)
|
||||
{
|
||||
BT_WARNING("Received error code %d", (int)aStatus);
|
||||
}
|
||||
|
||||
virtual void Listen(int aSockFd) { }
|
||||
virtual void Connect(int aSockFd) { }
|
||||
};
|
||||
|
||||
class BluetoothSocketInterface
|
||||
{
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user