1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_ipc_unixsocket_h
8 #define mozilla_ipc_unixsocket_h
11 #include "nsAutoPtr.h"
13 #include "nsThreadUtils.h"
14 #include "mozilla/ipc/SocketBase.h"
15 #include "mozilla/ipc/UnixSocketWatcher.h"
16 #include "mozilla/RefPtr.h"
17 #include "UnixSocketConnector.h"
22 class UnixSocketConsumerIO
;
24 class UnixSocketConsumer
: public SocketConsumerBase
27 virtual ~UnixSocketConsumer();
33 * Queue data to be sent to the socket on the IO thread. Can only be called on
36 * @param aMessage Data to be sent to socket
38 * @return true if data is queued, false otherwise (i.e. not connected)
40 bool SendSocketData(UnixSocketRawData
* aMessage
);
43 * Convenience function for sending strings to the socket (common in bluetooth
44 * profile usage). Converts to a UnixSocketRawData struct. Can only be called
45 * on originating thread.
47 * @param aMessage String to be sent to socket
49 * @return true if data is queued, false otherwise (i.e. not connected)
51 bool SendSocketData(const nsACString
& aMessage
);
54 * Starts a task on the socket that will try to connect to a socket in a
55 * non-blocking manner.
57 * @param aConnector Connector object for socket type specific functions
58 * @param aAddress Address to connect to.
59 * @param aDelayMs Time delay in milli-seconds.
61 * @return true on connect task started, false otherwise.
63 bool ConnectSocket(UnixSocketConnector
* aConnector
,
68 * Starts a task on the socket that will try to accept a new connection in a
69 * non-blocking manner.
71 * @param aConnector Connector object for socket type specific functions
73 * @return true on listen started, false otherwise
75 bool ListenSocket(UnixSocketConnector
* aConnector
);
78 * Queues the internal representation of socket for deletion. Can be called
84 * Get the current sockaddr for the socket
86 void GetSocketAddr(nsAString
& aAddrStr
);
89 UnixSocketConsumerIO
* mIO
;
93 } // namepsace mozilla
95 #endif // mozilla_ipc_unixsocket_h