mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1164425: Cleanup interfaces of |BluetoothDaemonConnection|, r=shuang
Bluetooth never actively opens a connection to the daemon, so this patch removes the connect functionality.
This commit is contained in:
parent
6a46c5c7cf
commit
63fb13df1f
@ -212,8 +212,6 @@ public:
|
||||
// Task callback methods
|
||||
//
|
||||
|
||||
void Connect(const char* aSocketName);
|
||||
|
||||
void Send(UnixSocketIOBuffer* aBuffer);
|
||||
|
||||
void OnSocketCanReceiveWithoutBlocking() override;
|
||||
@ -268,50 +266,6 @@ BluetoothDaemonConnectionIO::BluetoothDaemonConnectionIO(
|
||||
MOZ_ASSERT(mConsumer);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDaemonConnectionIO::Connect(const char* aSocketName)
|
||||
{
|
||||
static const size_t sNameOffset = 1;
|
||||
|
||||
MOZ_ASSERT(aSocketName);
|
||||
|
||||
// Create socket address
|
||||
|
||||
struct sockaddr_un addr;
|
||||
size_t namesiz = strlen(aSocketName) + 1;
|
||||
|
||||
if((sNameOffset + namesiz) > sizeof(addr.sun_path)) {
|
||||
CHROMIUM_LOG("Address too long for socket struct!");
|
||||
return;
|
||||
}
|
||||
memset(addr.sun_path, '\0', sNameOffset); // abstract socket
|
||||
memcpy(addr.sun_path + sNameOffset, aSocketName, namesiz);
|
||||
addr.sun_family = AF_UNIX;
|
||||
|
||||
socklen_t socklen = offsetof(struct sockaddr_un, sun_path) + 1 + namesiz;
|
||||
|
||||
// Create socket
|
||||
|
||||
int fd = socket(AF_UNIX, SOCK_SEQPACKET, 0);
|
||||
if (fd < 0) {
|
||||
OnError("socket", errno);
|
||||
return;
|
||||
}
|
||||
if (TEMP_FAILURE_RETRY(fcntl(fd, F_SETFL, O_NONBLOCK)) < 0) {
|
||||
OnError("fcntl", errno);
|
||||
ScopedClose cleanupFd(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
SetFd(fd);
|
||||
|
||||
// Connect socket to address; calls OnConnected()
|
||||
// on success, or OnError() otherwise
|
||||
nsresult rv = UnixSocketWatcher::Connect(
|
||||
reinterpret_cast<struct sockaddr*>(&addr), socklen);
|
||||
NS_WARN_IF(NS_FAILED(rv));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDaemonConnectionIO::Send(UnixSocketIOBuffer* aBuffer)
|
||||
{
|
||||
@ -473,27 +427,6 @@ BluetoothDaemonConnectionIO::ShutdownOnIOThread()
|
||||
mShuttingDownOnIOThread = true;
|
||||
}
|
||||
|
||||
//
|
||||
// I/O helper tasks
|
||||
//
|
||||
|
||||
class BluetoothDaemonConnectTask final
|
||||
: public SocketIOTask<BluetoothDaemonConnectionIO>
|
||||
{
|
||||
public:
|
||||
BluetoothDaemonConnectTask(BluetoothDaemonConnectionIO* aIO)
|
||||
: SocketIOTask<BluetoothDaemonConnectionIO>(aIO)
|
||||
{ }
|
||||
|
||||
void Run() override
|
||||
{
|
||||
if (IsCanceled()) {
|
||||
return;
|
||||
}
|
||||
GetIO()->Connect(sBluetoothdSocketName);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// BluetoothDaemonConnection
|
||||
//
|
||||
@ -505,26 +438,6 @@ BluetoothDaemonConnection::BluetoothDaemonConnection()
|
||||
BluetoothDaemonConnection::~BluetoothDaemonConnection()
|
||||
{ }
|
||||
|
||||
nsresult
|
||||
BluetoothDaemonConnection::ConnectSocket(BluetoothDaemonPDUConsumer* aConsumer)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (mIO) {
|
||||
CHROMIUM_LOG("Bluetooth daemon already connecting/connected!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
SetConnectionStatus(SOCKET_CONNECTING);
|
||||
|
||||
MessageLoop* ioLoop = XRE_GetIOMessageLoop();
|
||||
mIO = new BluetoothDaemonConnectionIO(
|
||||
ioLoop, -1, UnixSocketWatcher::SOCKET_IS_CONNECTING, this, aConsumer);
|
||||
ioLoop->PostTask(FROM_HERE, new BluetoothDaemonConnectTask(mIO));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
ConnectionOrientedSocketIO*
|
||||
BluetoothDaemonConnection::PrepareAccept(BluetoothDaemonPDUConsumer* aConsumer)
|
||||
{
|
||||
|
@ -116,8 +116,6 @@ public:
|
||||
BluetoothDaemonConnection();
|
||||
virtual ~BluetoothDaemonConnection();
|
||||
|
||||
nsresult ConnectSocket(BluetoothDaemonPDUConsumer* aConsumer);
|
||||
|
||||
// Methods for |ConnectionOrientedSocket|
|
||||
//
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user