2011-12-07 14:58:56 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim: set sw=4 ts=8 et ft=cpp: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2011-12-07 14:58:56 +04:00
|
|
|
|
2013-10-29 12:12:45 +04:00
|
|
|
#include "mozilla/ipc/Ril.h"
|
|
|
|
|
2011-12-07 14:58:56 +04:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/un.h>
|
2013-02-04 14:56:12 +04:00
|
|
|
#include <netdb.h> // For gethostbyname.
|
2011-12-07 14:58:56 +04:00
|
|
|
|
2013-12-17 22:26:45 +04:00
|
|
|
#undef CHROMIUM_LOG
|
2011-12-07 14:58:56 +04:00
|
|
|
#if defined(MOZ_WIDGET_GONK)
|
|
|
|
#include <android/log.h>
|
2013-12-17 22:26:45 +04:00
|
|
|
#define CHROMIUM_LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gonk", args)
|
2011-12-07 14:58:56 +04:00
|
|
|
#else
|
2013-12-17 22:26:45 +04:00
|
|
|
#define CHROMIUM_LOG(args...) printf(args);
|
2011-12-07 14:58:56 +04:00
|
|
|
#endif
|
|
|
|
|
2013-02-01 16:28:22 +04:00
|
|
|
#include "jsfriendapi.h"
|
2014-01-30 22:26:54 +04:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2013-10-29 12:12:45 +04:00
|
|
|
#include "nsTArray.h"
|
2013-02-01 16:28:22 +04:00
|
|
|
#include "nsThreadUtils.h" // For NS_IsMainThread.
|
2011-12-13 00:39:17 +04:00
|
|
|
|
2013-02-01 16:28:22 +04:00
|
|
|
USING_WORKERS_NAMESPACE
|
|
|
|
using namespace mozilla::ipc;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
const char* RIL_SOCKET_NAME = "/dev/socket/rilproxy";
|
2011-12-07 14:58:56 +04:00
|
|
|
|
2011-12-09 11:12:32 +04:00
|
|
|
// Network port to connect to for adb forwarded sockets when doing
|
|
|
|
// desktop development.
|
|
|
|
const uint32_t RIL_TEST_PORT = 6200;
|
|
|
|
|
2013-10-29 12:12:45 +04:00
|
|
|
nsTArray<nsRefPtr<mozilla::ipc::RilConsumer> > sRilConsumers;
|
|
|
|
|
|
|
|
class ConnectWorkerToRIL : public WorkerTask
|
2011-12-07 14:58:56 +04:00
|
|
|
{
|
2012-04-01 12:57:21 +04:00
|
|
|
public:
|
2013-10-29 12:12:45 +04:00
|
|
|
ConnectWorkerToRIL()
|
2013-02-01 16:28:22 +04:00
|
|
|
{ }
|
2012-04-01 12:57:21 +04:00
|
|
|
|
2013-02-01 16:28:22 +04:00
|
|
|
virtual bool RunTask(JSContext *aCx);
|
2013-10-29 12:12:45 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
class SendRilSocketDataTask : public nsRunnable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SendRilSocketDataTask(unsigned long aClientId,
|
|
|
|
UnixSocketRawData *aRawData)
|
|
|
|
: mRawData(aRawData)
|
|
|
|
, mClientId(aClientId)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
NS_IMETHOD Run()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
if (sRilConsumers.Length() <= mClientId ||
|
|
|
|
!sRilConsumers[mClientId] ||
|
|
|
|
sRilConsumers[mClientId]->GetConnectionStatus() != SOCKET_CONNECTED) {
|
|
|
|
// Probably shuting down.
|
|
|
|
delete mRawData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
sRilConsumers[mClientId]->SendSocketData(mRawData);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
UnixSocketRawData *mRawData;
|
|
|
|
unsigned long mClientId;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool
|
|
|
|
PostToRIL(JSContext *aCx,
|
|
|
|
unsigned aArgc,
|
2014-03-24 16:50:10 +04:00
|
|
|
JS::Value *aVp)
|
2013-10-29 12:12:45 +04:00
|
|
|
{
|
2014-03-24 16:50:10 +04:00
|
|
|
JS::CallArgs args = JS::CallArgsFromVp(aArgc, aVp);
|
2013-10-29 12:12:45 +04:00
|
|
|
NS_ASSERTION(!NS_IsMainThread(), "Expecting to be on the worker thread");
|
|
|
|
|
2014-03-24 16:50:10 +04:00
|
|
|
if (args.length() != 2) {
|
2013-10-29 12:12:45 +04:00
|
|
|
JS_ReportError(aCx, "Expecting two arguments with the RIL message");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-03-24 16:50:10 +04:00
|
|
|
int clientId = args[0].toInt32();
|
|
|
|
JS::Value v = args[1];
|
2013-10-29 12:12:45 +04:00
|
|
|
|
2014-10-07 21:44:07 +04:00
|
|
|
UnixSocketRawData* raw = nullptr;
|
|
|
|
|
2014-04-28 06:41:01 +04:00
|
|
|
if (v.isString()) {
|
2014-10-07 21:44:07 +04:00
|
|
|
JSAutoByteString abs;
|
2014-04-02 18:28:03 +04:00
|
|
|
JS::Rooted<JSString*> str(aCx, v.toString());
|
2013-10-29 12:12:45 +04:00
|
|
|
if (!abs.encodeUtf8(aCx, str)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-10-07 21:44:07 +04:00
|
|
|
raw = new UnixSocketRawData(abs.ptr(), abs.length());
|
2014-04-28 07:27:54 +04:00
|
|
|
} else if (!v.isPrimitive()) {
|
2014-04-28 06:58:52 +04:00
|
|
|
JSObject *obj = v.toObjectOrNull();
|
2013-10-29 12:12:45 +04:00
|
|
|
if (!JS_IsTypedArrayObject(obj)) {
|
|
|
|
JS_ReportError(aCx, "Object passed in wasn't a typed array");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t type = JS_GetArrayBufferViewType(obj);
|
2014-06-06 20:36:00 +04:00
|
|
|
if (type != js::Scalar::Int8 &&
|
|
|
|
type != js::Scalar::Uint8 &&
|
|
|
|
type != js::Scalar::Uint8Clamped) {
|
2013-10-29 12:12:45 +04:00
|
|
|
JS_ReportError(aCx, "Typed array data is not octets");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-10-07 21:44:07 +04:00
|
|
|
JS::AutoCheckCannotGC nogc;
|
|
|
|
size_t size = JS_GetTypedArrayByteLength(obj);
|
|
|
|
void *data = JS_GetArrayBufferViewData(obj, nogc);
|
|
|
|
raw = new UnixSocketRawData(data, size);
|
2013-10-29 12:12:45 +04:00
|
|
|
} else {
|
|
|
|
JS_ReportError(aCx,
|
|
|
|
"Incorrect argument. Expecting a string or a typed array");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-10-07 21:44:07 +04:00
|
|
|
if (!raw) {
|
|
|
|
JS_ReportError(aCx, "Unable to post to RIL");
|
|
|
|
return false;
|
|
|
|
}
|
2013-10-29 12:12:45 +04:00
|
|
|
|
|
|
|
nsRefPtr<SendRilSocketDataTask> task =
|
|
|
|
new SendRilSocketDataTask(clientId, raw);
|
|
|
|
NS_DispatchToMainThread(task);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ConnectWorkerToRIL::RunTask(JSContext *aCx)
|
|
|
|
{
|
|
|
|
// Set up the postRILMessage on the function for worker -> RIL thread
|
|
|
|
// communication.
|
|
|
|
NS_ASSERTION(!NS_IsMainThread(), "Expecting to be on the worker thread");
|
|
|
|
NS_ASSERTION(!JS_IsRunning(aCx), "Are we being called somehow?");
|
2014-01-17 22:10:17 +04:00
|
|
|
JS::Rooted<JSObject*> workerGlobal(aCx, JS::CurrentGlobalOrNull(aCx));
|
2013-10-29 12:12:45 +04:00
|
|
|
|
2014-02-17 15:35:01 +04:00
|
|
|
// Check whether |postRILMessage| has been defined. No one but this class
|
|
|
|
// should ever define |postRILMessage| in a RIL worker, so we call to
|
|
|
|
// |JS_LookupProperty| instead of |JS_GetProperty| here.
|
|
|
|
JS::Rooted<JS::Value> val(aCx);
|
|
|
|
if (!JS_LookupProperty(aCx, workerGlobal, "postRILMessage", &val)) {
|
|
|
|
JS_ReportPendingException(aCx);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// |JS_LookupProperty| could still return JS_TRUE with an "undefined"
|
|
|
|
// |postRILMessage|, so we have to make sure that with an additional call
|
|
|
|
// to |JS_TypeOfValue|.
|
|
|
|
if (JSTYPE_FUNCTION == JS_TypeOfValue(aCx, val)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-10-29 12:12:45 +04:00
|
|
|
return !!JS_DefineFunction(aCx, workerGlobal,
|
2013-11-05 18:16:39 +04:00
|
|
|
"postRILMessage", PostToRIL, 2, 0);
|
2013-10-29 12:12:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
class DispatchRILEvent : public WorkerTask
|
|
|
|
{
|
|
|
|
public:
|
2014-02-17 15:35:01 +04:00
|
|
|
DispatchRILEvent(unsigned long aClient,
|
|
|
|
UnixSocketRawData* aMessage)
|
|
|
|
: mClientId(aClient)
|
|
|
|
, mMessage(aMessage)
|
2013-10-29 12:12:45 +04:00
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual bool RunTask(JSContext *aCx);
|
2012-04-01 12:57:21 +04:00
|
|
|
|
|
|
|
private:
|
2014-02-17 15:35:01 +04:00
|
|
|
unsigned long mClientId;
|
2013-10-29 12:12:45 +04:00
|
|
|
nsAutoPtr<UnixSocketRawData> mMessage;
|
2011-12-09 11:12:32 +04:00
|
|
|
};
|
2012-09-26 08:07:39 +04:00
|
|
|
|
2013-02-01 16:28:22 +04:00
|
|
|
bool
|
|
|
|
DispatchRILEvent::RunTask(JSContext *aCx)
|
|
|
|
{
|
2014-02-11 14:59:16 +04:00
|
|
|
JS::Rooted<JSObject*> obj(aCx, JS::CurrentGlobalOrNull(aCx));
|
2011-12-07 14:58:56 +04:00
|
|
|
|
2014-09-08 13:44:01 +04:00
|
|
|
JS::Rooted<JSObject*> array(aCx,
|
|
|
|
JS_NewUint8Array(aCx, mMessage->GetSize()));
|
2013-02-01 16:28:22 +04:00
|
|
|
if (!array) {
|
|
|
|
return false;
|
2012-10-01 09:03:43 +04:00
|
|
|
}
|
2014-10-07 21:44:07 +04:00
|
|
|
{
|
|
|
|
JS::AutoCheckCannotGC nogc;
|
|
|
|
memcpy(JS_GetArrayBufferViewData(array, nogc),
|
|
|
|
mMessage->GetData(), mMessage->GetSize());
|
|
|
|
}
|
2014-02-17 15:35:01 +04:00
|
|
|
|
|
|
|
JS::AutoValueArray<2> args(aCx);
|
|
|
|
args[0].setNumber((uint32_t)mClientId);
|
|
|
|
args[1].setObject(*array);
|
|
|
|
|
2014-02-11 14:59:16 +04:00
|
|
|
JS::Rooted<JS::Value> rval(aCx);
|
2014-02-17 15:35:01 +04:00
|
|
|
return JS_CallFunctionName(aCx, obj, "onRILMessage", args, &rval);
|
2011-12-07 14:58:56 +04:00
|
|
|
}
|
|
|
|
|
2013-02-01 16:28:22 +04:00
|
|
|
class RilConnector : public mozilla::ipc::UnixSocketConnector
|
2011-12-07 14:58:56 +04:00
|
|
|
{
|
2013-02-01 16:28:22 +04:00
|
|
|
public:
|
2013-02-04 17:26:43 +04:00
|
|
|
RilConnector(unsigned long aClientId) : mClientId(aClientId)
|
|
|
|
{}
|
|
|
|
|
2013-02-01 16:28:22 +04:00
|
|
|
virtual ~RilConnector()
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual int Create();
|
2013-03-19 21:23:47 +04:00
|
|
|
virtual bool CreateAddr(bool aIsServer,
|
2013-02-01 16:28:22 +04:00
|
|
|
socklen_t& aAddrSize,
|
2013-03-19 21:23:47 +04:00
|
|
|
sockaddr_any& aAddr,
|
2013-02-01 16:28:22 +04:00
|
|
|
const char* aAddress);
|
|
|
|
virtual bool SetUp(int aFd);
|
2013-10-25 06:00:22 +04:00
|
|
|
virtual bool SetUpListenSocket(int aFd);
|
2013-03-19 21:23:47 +04:00
|
|
|
virtual void GetSocketAddr(const sockaddr_any& aAddr,
|
2013-02-01 16:28:22 +04:00
|
|
|
nsAString& aAddrStr);
|
2013-02-04 17:26:43 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
unsigned long mClientId;
|
2013-02-01 16:28:22 +04:00
|
|
|
};
|
2011-12-07 14:58:56 +04:00
|
|
|
|
2013-02-01 16:28:22 +04:00
|
|
|
int
|
|
|
|
RilConnector::Create()
|
2011-12-07 14:58:56 +04:00
|
|
|
{
|
2013-02-01 16:28:22 +04:00
|
|
|
MOZ_ASSERT(!NS_IsMainThread());
|
|
|
|
|
|
|
|
int fd = -1;
|
2012-10-01 09:03:43 +04:00
|
|
|
|
2011-12-07 14:58:56 +04:00
|
|
|
#if defined(MOZ_WIDGET_GONK)
|
2013-02-01 16:28:22 +04:00
|
|
|
fd = socket(AF_LOCAL, SOCK_STREAM, 0);
|
2011-12-07 14:58:56 +04:00
|
|
|
#else
|
2013-03-19 21:23:47 +04:00
|
|
|
// If we can't hit a local loopback, fail later in connect.
|
|
|
|
fd = socket(AF_INET, SOCK_STREAM, 0);
|
2011-12-07 14:58:56 +04:00
|
|
|
#endif
|
|
|
|
|
2013-02-01 16:28:22 +04:00
|
|
|
if (fd < 0) {
|
|
|
|
NS_WARNING("Could not open ril socket!");
|
|
|
|
return -1;
|
2011-12-07 14:58:56 +04:00
|
|
|
}
|
|
|
|
|
2013-02-01 16:28:22 +04:00
|
|
|
if (!SetUp(fd)) {
|
|
|
|
NS_WARNING("Could not set up socket!");
|
2012-12-11 17:56:36 +04:00
|
|
|
}
|
2013-02-01 16:28:22 +04:00
|
|
|
return fd;
|
|
|
|
}
|
|
|
|
|
2013-03-19 21:23:47 +04:00
|
|
|
bool
|
2013-02-01 16:28:22 +04:00
|
|
|
RilConnector::CreateAddr(bool aIsServer,
|
|
|
|
socklen_t& aAddrSize,
|
2013-03-19 21:23:47 +04:00
|
|
|
sockaddr_any& aAddr,
|
2013-02-01 16:28:22 +04:00
|
|
|
const char* aAddress)
|
|
|
|
{
|
|
|
|
// We never open ril socket as server.
|
|
|
|
MOZ_ASSERT(!aIsServer);
|
2013-03-19 21:23:47 +04:00
|
|
|
uint32_t af;
|
2012-04-11 21:05:35 +04:00
|
|
|
#if defined(MOZ_WIDGET_GONK)
|
2013-03-19 21:23:47 +04:00
|
|
|
af = AF_LOCAL;
|
2013-02-01 16:28:22 +04:00
|
|
|
#else
|
2013-03-19 21:23:47 +04:00
|
|
|
af = AF_INET;
|
2013-03-16 08:35:25 +04:00
|
|
|
#endif
|
2013-03-19 21:23:47 +04:00
|
|
|
switch (af) {
|
|
|
|
case AF_LOCAL:
|
|
|
|
aAddr.un.sun_family = af;
|
|
|
|
if(strlen(aAddress) > sizeof(aAddr.un.sun_path)) {
|
|
|
|
NS_WARNING("Address too long for socket struct!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
strcpy((char*)&aAddr.un.sun_path, aAddress);
|
|
|
|
aAddrSize = strlen(aAddress) + offsetof(struct sockaddr_un, sun_path) + 1;
|
|
|
|
break;
|
|
|
|
case AF_INET:
|
|
|
|
aAddr.in.sin_family = af;
|
|
|
|
aAddr.in.sin_port = htons(RIL_TEST_PORT + mClientId);
|
2014-01-10 15:40:57 +04:00
|
|
|
aAddr.in.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
2013-03-19 21:23:47 +04:00
|
|
|
aAddrSize = sizeof(sockaddr_in);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_WARNING("Socket type not handled by connector!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2011-12-07 14:58:56 +04:00
|
|
|
}
|
|
|
|
|
2013-02-01 16:28:22 +04:00
|
|
|
bool
|
|
|
|
RilConnector::SetUp(int aFd)
|
2011-12-07 14:58:56 +04:00
|
|
|
{
|
2013-02-01 16:28:22 +04:00
|
|
|
// Nothing to do here.
|
|
|
|
return true;
|
2011-12-07 14:58:56 +04:00
|
|
|
}
|
|
|
|
|
2013-10-25 06:00:22 +04:00
|
|
|
bool
|
|
|
|
RilConnector::SetUpListenSocket(int aFd)
|
|
|
|
{
|
|
|
|
// Nothing to do here.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-12-07 14:58:56 +04:00
|
|
|
void
|
2013-03-19 21:23:47 +04:00
|
|
|
RilConnector::GetSocketAddr(const sockaddr_any& aAddr,
|
2013-02-01 16:28:22 +04:00
|
|
|
nsAString& aAddrStr)
|
2011-12-07 14:58:56 +04:00
|
|
|
{
|
2013-06-29 05:38:30 +04:00
|
|
|
MOZ_CRASH("This should never be called!");
|
2011-12-07 14:58:56 +04:00
|
|
|
}
|
|
|
|
|
2013-02-01 16:28:22 +04:00
|
|
|
} // anonymous namespace
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace ipc {
|
2011-12-07 14:58:56 +04:00
|
|
|
|
2013-02-04 17:26:43 +04:00
|
|
|
RilConsumer::RilConsumer(unsigned long aClientId,
|
|
|
|
WorkerCrossThreadDispatcher* aDispatcher)
|
2013-02-01 16:28:22 +04:00
|
|
|
: mDispatcher(aDispatcher)
|
2013-02-04 17:26:43 +04:00
|
|
|
, mClientId(aClientId)
|
2013-02-01 16:28:22 +04:00
|
|
|
, mShutdown(false)
|
2011-12-07 14:58:56 +04:00
|
|
|
{
|
2013-02-04 17:26:43 +04:00
|
|
|
// Only append client id after RIL_SOCKET_NAME when it's not connected to
|
|
|
|
// the first(0) rilproxy for compatibility.
|
|
|
|
if (!aClientId) {
|
|
|
|
mAddress = RIL_SOCKET_NAME;
|
|
|
|
} else {
|
|
|
|
struct sockaddr_un addr_un;
|
|
|
|
snprintf(addr_un.sun_path, sizeof addr_un.sun_path, "%s%lu",
|
|
|
|
RIL_SOCKET_NAME, aClientId);
|
|
|
|
mAddress = addr_un.sun_path;
|
|
|
|
}
|
|
|
|
|
|
|
|
ConnectSocket(new RilConnector(mClientId), mAddress.get());
|
2011-12-07 14:58:56 +04:00
|
|
|
}
|
|
|
|
|
2013-10-29 12:12:45 +04:00
|
|
|
nsresult
|
|
|
|
RilConsumer::Register(unsigned int aClientId,
|
|
|
|
WorkerCrossThreadDispatcher* aDispatcher)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
sRilConsumers.EnsureLengthAtLeast(aClientId + 1);
|
|
|
|
|
|
|
|
if (sRilConsumers[aClientId]) {
|
|
|
|
NS_WARNING("RilConsumer already registered");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRefPtr<ConnectWorkerToRIL> connection = new ConnectWorkerToRIL();
|
|
|
|
if (!aDispatcher->PostTask(connection)) {
|
|
|
|
NS_WARNING("Failed to connect worker to ril");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now that we're set up, connect ourselves to the RIL thread.
|
|
|
|
sRilConsumers[aClientId] = new RilConsumer(aClientId, aDispatcher);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-02-01 16:28:22 +04:00
|
|
|
void
|
|
|
|
RilConsumer::Shutdown()
|
2011-12-07 14:58:56 +04:00
|
|
|
{
|
2013-10-29 12:12:45 +04:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
for (unsigned long i = 0; i < sRilConsumers.Length(); i++) {
|
|
|
|
nsRefPtr<RilConsumer>& instance = sRilConsumers[i];
|
|
|
|
if (!instance) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
instance->mShutdown = true;
|
|
|
|
instance->CloseSocket();
|
|
|
|
instance = nullptr;
|
|
|
|
}
|
2011-12-07 14:58:56 +04:00
|
|
|
}
|
|
|
|
|
2013-02-01 16:28:22 +04:00
|
|
|
void
|
|
|
|
RilConsumer::ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage)
|
2011-12-07 14:58:56 +04:00
|
|
|
{
|
2013-02-01 16:28:22 +04:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2011-12-07 14:58:56 +04:00
|
|
|
|
2014-02-17 15:35:01 +04:00
|
|
|
nsRefPtr<DispatchRILEvent> dre(new DispatchRILEvent(mClientId, aMessage.forget()));
|
2013-02-01 16:28:22 +04:00
|
|
|
mDispatcher->PostTask(dre);
|
2011-12-07 14:58:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-02-01 16:28:22 +04:00
|
|
|
RilConsumer::OnConnectSuccess()
|
2011-12-07 14:58:56 +04:00
|
|
|
{
|
2013-02-01 16:28:22 +04:00
|
|
|
// Nothing to do here.
|
2013-12-17 22:26:45 +04:00
|
|
|
CHROMIUM_LOG("RIL[%lu]: %s\n", mClientId, __FUNCTION__);
|
2013-02-01 16:28:22 +04:00
|
|
|
}
|
2011-12-07 14:58:56 +04:00
|
|
|
|
2013-02-01 16:28:22 +04:00
|
|
|
void
|
|
|
|
RilConsumer::OnConnectError()
|
|
|
|
{
|
2013-12-17 22:26:45 +04:00
|
|
|
CHROMIUM_LOG("RIL[%lu]: %s\n", mClientId, __FUNCTION__);
|
2013-02-01 16:28:22 +04:00
|
|
|
CloseSocket();
|
|
|
|
}
|
2011-12-07 14:58:56 +04:00
|
|
|
|
2013-02-01 16:28:22 +04:00
|
|
|
void
|
|
|
|
RilConsumer::OnDisconnect()
|
|
|
|
{
|
2013-12-17 22:26:45 +04:00
|
|
|
CHROMIUM_LOG("RIL[%lu]: %s\n", mClientId, __FUNCTION__);
|
2013-02-01 16:28:22 +04:00
|
|
|
if (!mShutdown) {
|
2014-02-14 11:03:15 +04:00
|
|
|
ConnectSocket(new RilConnector(mClientId), mAddress.get(),
|
|
|
|
GetSuggestedConnectDelayMs());
|
2011-12-07 14:58:56 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace ipc
|
|
|
|
} // namespace mozilla
|