Files
palemoon27/ipc/unixsocket/UnixSocketConnector.h
T
roytam1 04e8424ea3 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1109592 - Cleanup unused variables and fields from NFC's IPC code. r=allstars.chh (4772c44e7)
- Bug 1109592 - Move |NfcConnector| to a more public place. r=allstars.chh (da26d99ba)
- Bug 1109592 - Add |NfcListenSocket|. r=allstars.chh (721edbb6f)
- Bug 1161020: Implement new socket-connector interface for NFC, r=allstars.chh (848533b8c)
- Bug 1161020: Remove old interface and implementation from socket-connector classes, r=kmachulis (722d7082c)
- Bug 1164417: Add |UnixSocketConnector::Duplicate|, r=kmachulis (43ccdc20b)
- Bug 1137330 - Set opcode as 'PutFinal' instead of 'Put' for file header packet if file size is 0, r=shuang (4448f4d2f)
- Bug 1159179 - Patch 1/3: [PBAP] Add OBEX related functions, r=shuang (7c297c5e2)
- Bug 1159179 - Patch 2/3: [PBAP] Revise profile disconnection when BT stops, r=shuang (f67fefe7d)
- Bug 1159179 - Patch 3/3: [PBAP] Implement PBAP manger, r=shuang (1b8d75174)
- Bug 1162902 - Implement PBAP SetPhoneBook function, r=shuang (a1bd282e4)
- Bug 1158876: Rename |SocketConsumerBase| to |DataSocket|, r=kmachulis (3df8eb5bf)
- Bug 1158876: Move management of socket I/O buffers into socket I/O classes, r=kmachulis (f834e3803)
- Bug 1158876: Move |DataSocket::ReceiveSocketData| into sub classes, r=kmachulis (0d4ea7708)
- Bug 1159209: Remove template parameters from |SocketIOEventRunnable|, r=kmachulis (15644b5c2)
- Bug 1159209: Remove template parameters from |SocketIORequestClosingRunnable|, r=kmachulis (5dc4851d3)
- Bug 1136729: Make destructor of |SocketBase| protected, r=qdot (3df9d9088)
- Bug 1159209: Remove template parameters from |SocketIODeleteInstanceRunnable|, r=kmachulis (b203f4ac2)
- Bug 1159209: Remove template parameters from |SocketIOShutdownTask|, r=kmachulis (25e340c57)
- Bug 1156352: Refactor |UnixSocketIOBuffer|, r=kmachulis (d361f8a5a)
- Bug 1158818: Only store Bluetooth result runnable after command has been sent successfully, r=shuang (a81e4ed81)
- Bug 1159709: Inherit |BluetoothDaemonConnection| from |DataSocket|, r=kmachulis (3f6de0126)
- Bug 1159709: Integrate |ConnectionOrientedSocket| into socket I/O class hierarchy, r=kmachulis (4de49e482)
- Bug 1159709: Cleanup inherited methods of |StreamSocket|, r=kmachulis (15d587cc0)
- Bug 1159709: Cleanup inherited methods of |ListenSocket|, r=kmachulis (443baf020)
- Bug 1159709: Cleanup inherited methods of BlueZ's |BluetoothSocket|, r=kmachulis (1b683a700)
- Bug 1164425: Rename |SocketBase::CloseSocket| to |SocketBase::Close|, r=kmachulis (b0e1fece4)
- Bug 1164425: Cleanup interfaces of |BluetoothDaemonConnection|, r=shuang (1a9d0339f)
- Bug 1164417: Store PDU consumer in |BluetoothDaemonConnection|, r=kmachulis (18f34692f)
- Bug 1162524: Move |accept| out of |UnixSocketWatcher|, r=kmachulis (4ced7ee1d)
- Bug 1162585: Set socket flags after socket has been created, r=kmachulis (1131301f4)
- Bug 1161020: Use new socket-connector interface in socket classes, r=kmachulis (0aae9f6e7)
- Bug 1164425: Cleanup interfaces of |StreamSocket|, r=kmachulis (9f8c20fd9)
2021-02-10 10:13:21 +08:00

95 lines
3.4 KiB
C++

/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_ipc_unixsocketconnector_h
#define mozilla_ipc_unixsocketconnector_h
#include <sys/socket.h>
#include "mozilla/ipc/UnixSocketWatcher.h"
#include "nsString.h"
namespace mozilla {
namespace ipc {
/**
* |UnixSocketConnector| defines the socket creation and connection/listening
* functions for |UnixSocketConsumer|, et al. Due to the fact that socket setup
* can vary between protocols (Unix sockets, TCP sockets, Bluetooth sockets, etc),
* this allows the user to create whatever connection mechanism they need while
* still depending on libevent for non-blocking communication handling.
*/
class UnixSocketConnector
{
public:
virtual ~UnixSocketConnector();
/**
* Converts an address to a human-readable string.
*
* @param aAddress A socket address
* @param aAddressLength The number of valid bytes in |aAddress|
* @param[out] aAddressString The resulting string
* @return NS_OK on success, or an XPCOM error code otherwise.
*/
virtual nsresult ConvertAddressToString(const struct sockaddr& aAddress,
socklen_t aAddressLength,
nsACString& aAddressString) = 0;
/**
* Creates a listening socket. I/O thread only.
*
* @param[out] aAddress The listening socket's address
* @param[out] aAddressLength The number of valid bytes in |aAddress|
* @param[out] aListenFd The socket's file descriptor
* @return NS_OK on success, or an XPCOM error code otherwise.
*/
virtual nsresult CreateListenSocket(struct sockaddr* aAddress,
socklen_t* aAddressLength,
int& aListenFd) = 0;
/**
* Accepts a stream socket from a listening socket. I/O thread only.
*
* @param aListenFd The listening socket
* @param[out] aAddress Returns the stream socket's address
* @param[out] aAddressLength Returns the number of valid bytes in |aAddress|
* @param[out] aStreamFd The stream socket's file descriptor
* @return NS_OK on success, or an XPCOM error code otherwise.
*/
virtual nsresult AcceptStreamSocket(int aListenFd,
struct sockaddr* aAddress,
socklen_t* aAddressLen,
int& aStreamFd) = 0;
/**
* Creates a stream socket. I/O thread only.
*
* @param[in|out] aAddress The stream socket's address
* @param[in|out] aAddressLength The number of valid bytes in |aAddress|
* @param[out] aStreamFd The socket's file descriptor
* @return NS_OK on success, or an XPCOM error code otherwise.
*/
virtual nsresult CreateStreamSocket(struct sockaddr* aAddress,
socklen_t* aAddressLength,
int& aStreamFd) = 0;
/**
* Copies the instance of |UnixSocketConnector|. I/O thread only.
*
* @param[in] aConnector Returns a new instance of the connector class
* @return NS_OK on success, or an XPCOM error code otherwise
*/
virtual nsresult Duplicate(UnixSocketConnector*& aConnector) = 0;
protected:
UnixSocketConnector();
};
}
}
#endif