mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 714459 - 'Rename RadioManager / nsIRadioWorker'. r=mrbkap.
--HG-- rename : dom/system/b2g/RadioManager.cpp => dom/system/b2g/SystemWorkerManager.cpp rename : dom/system/b2g/RadioManager.h => dom/system/b2g/SystemWorkerManager.h rename : dom/system/b2g/nsIRadioWorker.idl => dom/system/b2g/nsIWorkerHolder.idl extra : transplant_source : 2%ED%03%8F%C0%98%06%25%8EnIb%8BI%B0O%EB%BF%E0%A2
This commit is contained in:
parent
c375cc74c4
commit
6d6badf6c0
@ -7,7 +7,6 @@ DOM_SRCDIRS = \
|
||||
dom/src/offline \
|
||||
dom/src/geolocation \
|
||||
dom/src/notification \
|
||||
dom/telephony \
|
||||
dom/workers \
|
||||
content/xbl/src \
|
||||
content/xul/document/src \
|
||||
@ -22,5 +21,13 @@ DOM_SRCDIRS = \
|
||||
layout/xul/base/src/tree/src \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_B2G_RIL
|
||||
DOM_SRCDIRS += \
|
||||
dom/system/b2g \
|
||||
dom/telephony \
|
||||
dom/wifi \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
LOCAL_INCLUDES += $(DOM_SRCDIRS:%=-I$(topsrcdir)/%)
|
||||
DEFINES += -D_IMPL_NS_LAYOUT
|
||||
|
@ -37,10 +37,11 @@
|
||||
|
||||
#include "mozilla/dom/sms/SmsMessage.h"
|
||||
#include "SmsService.h"
|
||||
#include "RadioManager.h"
|
||||
#include "SystemWorkerManager.h"
|
||||
#include "jsapi.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
|
||||
using mozilla::dom::telephony::RadioManager;
|
||||
using mozilla::dom::telephony::SystemWorkerManager;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -49,8 +50,14 @@ namespace sms {
|
||||
NS_IMPL_ISUPPORTS1(SmsService, nsISmsService)
|
||||
|
||||
SmsService::SmsService()
|
||||
: mRIL(RadioManager::GetTelephone())
|
||||
{
|
||||
nsIInterfaceRequestor* ireq = SystemWorkerManager::GetInterfaceRequestor();
|
||||
NS_WARN_IF_FALSE(ireq, "The SystemWorkerManager has not been created!");
|
||||
|
||||
if (ireq) {
|
||||
mRIL = do_GetInterface(ireq);
|
||||
NS_WARN_IF_FALSE(mRIL, "This shouldn't fail!");
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -61,9 +61,9 @@ ifneq (,$(filter android,$(MOZ_WIDGET_TOOLKIT)))
|
||||
DIRS = android
|
||||
endif
|
||||
|
||||
ifdef MOZ_B2G_RIL #{
|
||||
ifdef MOZ_B2G_RIL
|
||||
DIRS += b2g
|
||||
endif #}
|
||||
endif
|
||||
|
||||
CPPSRCS = \
|
||||
nsDeviceMotion.cpp \
|
||||
|
@ -51,7 +51,7 @@ FORCE_STATIC_LIB = 1
|
||||
include $(topsrcdir)/dom/dom-config.mk
|
||||
|
||||
CPPSRCS = \
|
||||
RadioManager.cpp \
|
||||
SystemWorkerManager.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
|
||||
@ -60,7 +60,7 @@ endif
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsIAudioManager.idl \
|
||||
nsIRadioWorker.idl \
|
||||
nsIWorkerHolder.idl \
|
||||
$(NULL)
|
||||
|
||||
LOCAL_INCLUDES = \
|
||||
|
@ -37,48 +37,38 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "RadioManager.h"
|
||||
#include "nsIRadioWorker.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "SystemWorkerManager.h"
|
||||
|
||||
#include "nsIObserverService.h"
|
||||
#include "mozilla/dom/workers/Workers.h"
|
||||
#include "jstypedarray.h"
|
||||
|
||||
#include "nsTelephonyWorker.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsITelephone.h"
|
||||
#include "nsWifiWorker.h"
|
||||
#include "nsIWifi.h"
|
||||
#include "nsIWorkerHolder.h"
|
||||
#include "nsIXPConnect.h"
|
||||
|
||||
#include "jstypedarray.h"
|
||||
#include "mozilla/dom/workers/Workers.h"
|
||||
#include "mozilla/ipc/Ril.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsTelephonyWorker.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsWifiWorker.h"
|
||||
|
||||
#if defined(MOZ_WIDGET_GONK)
|
||||
#include <android/log.h>
|
||||
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gonk", args)
|
||||
#elif defined(__GNUC__)
|
||||
#define LOG(args...) printf(args);
|
||||
#else
|
||||
#define LOG(args) printf args
|
||||
#endif
|
||||
|
||||
USING_TELEPHONY_NAMESPACE
|
||||
USING_WORKERS_NAMESPACE
|
||||
using namespace mozilla::ipc;
|
||||
|
||||
static NS_DEFINE_CID(kTelephonyWorkerCID, NS_TELEPHONYWORKER_CID);
|
||||
static NS_DEFINE_CID(kWifiWorkerCID, NS_WIFIWORKER_CID);
|
||||
|
||||
// Topic we listen to for shutdown.
|
||||
#define PROFILE_BEFORE_CHANGE_TOPIC "profile-before-change"
|
||||
|
||||
USING_TELEPHONY_NAMESPACE
|
||||
|
||||
namespace {
|
||||
|
||||
// Doesn't carry a reference, we're owned by services.
|
||||
RadioManager* gInstance = nsnull;
|
||||
NS_DEFINE_CID(kTelephonyWorkerCID, NS_TELEPHONYWORKER_CID);
|
||||
NS_DEFINE_CID(kWifiWorkerCID, NS_WIFIWORKER_CID);
|
||||
|
||||
class ConnectWorkerToRIL : public WorkerTask {
|
||||
// Doesn't carry a reference, we're owned by services.
|
||||
SystemWorkerManager *gInstance = nsnull;
|
||||
|
||||
class ConnectWorkerToRIL : public WorkerTask
|
||||
{
|
||||
public:
|
||||
virtual bool RunTask(JSContext *aCx);
|
||||
};
|
||||
@ -158,7 +148,8 @@ ConnectWorkerToRIL::RunTask(JSContext *aCx)
|
||||
|
||||
class RILReceiver : public RilConsumer
|
||||
{
|
||||
class DispatchRILEvent : public WorkerTask {
|
||||
class DispatchRILEvent : public WorkerTask
|
||||
{
|
||||
public:
|
||||
DispatchRILEvent(RilRawData *aMessage)
|
||||
: mMessage(aMessage)
|
||||
@ -203,14 +194,14 @@ RILReceiver::DispatchRILEvent::RunTask(JSContext *aCx)
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
RadioManager::RadioManager()
|
||||
SystemWorkerManager::SystemWorkerManager()
|
||||
: mShutdown(false)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
NS_ASSERTION(!gInstance, "There should only be one instance!");
|
||||
}
|
||||
|
||||
RadioManager::~RadioManager()
|
||||
SystemWorkerManager::~SystemWorkerManager()
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
NS_ASSERTION(!gInstance || gInstance == this,
|
||||
@ -219,23 +210,15 @@ RadioManager::~RadioManager()
|
||||
}
|
||||
|
||||
nsresult
|
||||
RadioManager::Init()
|
||||
SystemWorkerManager::Init()
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "We can only initialize on the main thread");
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs =
|
||||
do_GetService(NS_OBSERVERSERVICE_CONTRACTID);
|
||||
if (!obs) {
|
||||
NS_WARNING("Failed to get observer service!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult rv = obs->AddObserver(this, PROFILE_BEFORE_CHANGE_TOPIC, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ASSERTION(!mShutdown, "Already shutdown!");
|
||||
|
||||
JSContext *cx;
|
||||
rv = nsContentUtils::ThreadJSContextStack()->GetSafeJSContext(&cx);
|
||||
nsresult rv = nsContentUtils::ThreadJSContextStack()->GetSafeJSContext(&cx);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCxPusher pusher;
|
||||
if (!cx || !pusher.Push(cx, false)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -247,32 +230,50 @@ RadioManager::Init()
|
||||
rv = InitWifi(cx);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs =
|
||||
do_GetService(NS_OBSERVERSERVICE_CONTRACTID);
|
||||
if (!obs) {
|
||||
NS_WARNING("Failed to get observer service!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
rv = obs->AddObserver(this, WORKERS_SHUTDOWN_TOPIC, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
RadioManager::Shutdown()
|
||||
SystemWorkerManager::Shutdown()
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
StopRil();
|
||||
mTelephone = nsnull;
|
||||
mWifi = nsnull;
|
||||
|
||||
mShutdown = true;
|
||||
|
||||
StopRil();
|
||||
|
||||
mTelephoneWorker = nsnull;
|
||||
mWifiWorker = nsnull;
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs =
|
||||
do_GetService(NS_OBSERVERSERVICE_CONTRACTID);
|
||||
if (obs) {
|
||||
obs->RemoveObserver(this, WORKERS_SHUTDOWN_TOPIC);
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<RadioManager>
|
||||
RadioManager::FactoryCreate()
|
||||
already_AddRefed<SystemWorkerManager>
|
||||
SystemWorkerManager::FactoryCreate()
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
nsRefPtr<RadioManager> instance(gInstance);
|
||||
nsRefPtr<SystemWorkerManager> instance(gInstance);
|
||||
|
||||
if (!instance) {
|
||||
instance = new RadioManager();
|
||||
instance = new SystemWorkerManager();
|
||||
if (NS_FAILED(instance->Init())) {
|
||||
instance->Shutdown();
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
@ -283,41 +284,54 @@ RadioManager::FactoryCreate()
|
||||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<nsITelephone>
|
||||
RadioManager::GetTelephone()
|
||||
nsIInterfaceRequestor*
|
||||
SystemWorkerManager::GetInterfaceRequestor()
|
||||
{
|
||||
return gInstance;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SystemWorkerManager::GetInterface(const nsIID &aIID, void **aResult)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
if (gInstance) {
|
||||
nsCOMPtr<nsITelephone> retval = gInstance->mTelephone;
|
||||
return retval.forget();
|
||||
if (aIID.Equals(NS_GET_IID(nsITelephone))) {
|
||||
return CallQueryInterface(mTelephoneWorker,
|
||||
reinterpret_cast<nsITelephone**>(aResult));
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
if (aIID.Equals(NS_GET_IID(nsIWifi))) {
|
||||
return CallQueryInterface(mWifiWorker,
|
||||
reinterpret_cast<nsIWifi**>(aResult));
|
||||
}
|
||||
|
||||
NS_WARNING("Got nothing for the requested IID!");
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
RadioManager::InitTelephone(JSContext *cx)
|
||||
SystemWorkerManager::InitTelephone(JSContext *cx)
|
||||
{
|
||||
// The telephony worker component is a hack that gives us a global object for
|
||||
// our own functions and makes creating the worker possible.
|
||||
nsCOMPtr<nsIRadioWorker> worker(do_CreateInstance(kTelephonyWorkerCID));
|
||||
// We're keeping as much of this implementation as possible in JS, so the real
|
||||
// worker lives in nsTelephonyWorker.js. All we do here is hold it alive and
|
||||
// hook it up to the RIL thread.
|
||||
nsCOMPtr<nsIWorkerHolder> worker = do_CreateInstance(kTelephonyWorkerCID);
|
||||
NS_ENSURE_TRUE(worker, NS_ERROR_FAILURE);
|
||||
|
||||
jsval workerval;
|
||||
nsresult rv = worker->GetWorker(&workerval);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ASSERTION(!JSVAL_IS_PRIMITIVE(workerval), "bad worker value");
|
||||
|
||||
JSObject *workerobj = JSVAL_TO_OBJECT(workerval);
|
||||
NS_ENSURE_TRUE(!JSVAL_IS_PRIMITIVE(workerval), NS_ERROR_UNEXPECTED);
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoEnterCompartment ac;
|
||||
if (!ac.enter(cx, workerobj)) {
|
||||
if (!ac.enter(cx, JSVAL_TO_OBJECT(workerval))) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
WorkerCrossThreadDispatcher *wctd = GetWorkerCrossThreadDispatcher(cx, workerval);
|
||||
WorkerCrossThreadDispatcher *wctd =
|
||||
GetWorkerCrossThreadDispatcher(cx, workerval);
|
||||
if (!wctd) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -331,44 +345,28 @@ RadioManager::InitTelephone(JSContext *cx)
|
||||
mozilla::RefPtr<RILReceiver> receiver = new RILReceiver(wctd);
|
||||
StartRil(receiver);
|
||||
|
||||
mTelephone = do_QueryInterface(worker);
|
||||
NS_ENSURE_TRUE(mTelephone, NS_ERROR_FAILURE);
|
||||
|
||||
mTelephoneWorker = worker;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
RadioManager::InitWifi(JSContext *cx)
|
||||
SystemWorkerManager::InitWifi(JSContext *cx)
|
||||
{
|
||||
nsCOMPtr<nsIRadioWorker> worker(do_CreateInstance(kWifiWorkerCID));
|
||||
nsCOMPtr<nsIWorkerHolder> worker = do_CreateInstance(kWifiWorkerCID);
|
||||
NS_ENSURE_TRUE(worker, NS_ERROR_FAILURE);
|
||||
|
||||
mWifi = do_QueryInterface(worker);
|
||||
NS_ENSURE_TRUE(mWifi, NS_ERROR_FAILURE);
|
||||
|
||||
mWifiWorker = worker;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS1(RadioManager, nsIObserver)
|
||||
NS_IMPL_ISUPPORTS2(SystemWorkerManager, nsIObserver, nsIInterfaceRequestor)
|
||||
|
||||
NS_IMETHODIMP
|
||||
RadioManager::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
const PRUnichar* aData)
|
||||
SystemWorkerManager::Observe(nsISupports *aSubject, const char *aTopic,
|
||||
const PRUnichar *aData)
|
||||
{
|
||||
if (!strcmp(aTopic, PROFILE_BEFORE_CHANGE_TOPIC)) {
|
||||
if (!strcmp(aTopic, WORKERS_SHUTDOWN_TOPIC)) {
|
||||
Shutdown();
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs =
|
||||
do_GetService(NS_OBSERVERSERVICE_CONTRACTID);
|
||||
if (obs) {
|
||||
if (NS_FAILED(obs->RemoveObserver(this, aTopic))) {
|
||||
NS_WARNING("Failed to remove observer!");
|
||||
}
|
||||
}
|
||||
else {
|
||||
NS_WARNING("Failed to get observer service!");
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
@ -37,70 +37,48 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef mozilla_dom_telephony_radio_h__
|
||||
#define mozilla_dom_telephony_radio_h__
|
||||
#ifndef mozilla_dom_system_b2g_systemworkermanager_h__
|
||||
#define mozilla_dom_system_b2g_systemworkermanager_h__
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "TelephonyCommon.h"
|
||||
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "mozilla/ipc/Ril.h"
|
||||
|
||||
#define TELEPHONYRADIO_CONTRACTID "@mozilla.org/telephony/radio;1"
|
||||
#define TELEPHONYRADIOINTERFACE_CONTRACTID "@mozilla.org/telephony/radio-interface;1"
|
||||
|
||||
#define BEGIN_TELEPHONY_NAMESPACE \
|
||||
namespace mozilla { namespace dom { namespace telephony {
|
||||
#define END_TELEPHONY_NAMESPACE \
|
||||
} /* namespace telephony */ } /* namespace dom */ } /* namespace mozilla */
|
||||
#define USING_TELEPHONY_NAMESPACE \
|
||||
using namespace mozilla::dom::telephony;
|
||||
|
||||
// {a5c3a6de-84c4-4b15-8611-8aeb8d97f8ba}
|
||||
#define TELEPHONYRADIO_CID \
|
||||
{0xa5c3a6de, 0x84c4, 0x4b15, {0x86, 0x11, 0x8a, 0xeb, 0x8d, 0x97, 0xf8, 0xba}}
|
||||
|
||||
// {a688f191-8ffc-47f3-8740-94a312cf59cb}}
|
||||
#define TELEPHONYRADIOINTERFACE_CID \
|
||||
{0xd66e7ece, 0x41b1, 0x4608, {0x82, 0x80, 0x72, 0x50, 0xa6, 0x44, 0xe6, 0x6f}}
|
||||
|
||||
|
||||
class nsIXPConnectJSObjectHolder;
|
||||
class nsITelephone;
|
||||
class nsIWifi;
|
||||
class nsIWorkerHolder;
|
||||
|
||||
BEGIN_TELEPHONY_NAMESPACE
|
||||
|
||||
class RadioManager : public nsIObserver
|
||||
class SystemWorkerManager : public nsIObserver,
|
||||
public nsIInterfaceRequestor
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
|
||||
nsresult Init();
|
||||
void Shutdown();
|
||||
|
||||
static already_AddRefed<RadioManager>
|
||||
static already_AddRefed<SystemWorkerManager>
|
||||
FactoryCreate();
|
||||
|
||||
static already_AddRefed<nsITelephone>
|
||||
GetTelephone();
|
||||
static nsIInterfaceRequestor*
|
||||
GetInterfaceRequestor();
|
||||
|
||||
protected:
|
||||
RadioManager();
|
||||
~RadioManager();
|
||||
private:
|
||||
SystemWorkerManager();
|
||||
~SystemWorkerManager();
|
||||
|
||||
nsresult InitTelephone(JSContext *cx);
|
||||
nsresult InitWifi(JSContext *cx);
|
||||
|
||||
nsCOMPtr<nsITelephone> mTelephone;
|
||||
nsCOMPtr<nsIWifi> mWifi;
|
||||
nsCOMPtr<nsIWorkerHolder> mTelephoneWorker;
|
||||
nsCOMPtr<nsIWorkerHolder> mWifiWorker;
|
||||
|
||||
bool mShutdown;
|
||||
};
|
||||
|
||||
END_TELEPHONY_NAMESPACE
|
||||
|
||||
#endif // mozilla_dom_telephony_radio_h__
|
||||
#endif // mozilla_dom_system_b2g_systemworkermanager_h__
|
@ -37,7 +37,8 @@
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(8f031451-ac25-4816-a09e-a075bb704e63)]
|
||||
interface nsIRadioWorker : nsISupports {
|
||||
readonly attribute jsval worker;
|
||||
[scriptable, uuid(c04f3102-1ce8-4d57-9c27-8aece9c2740a)]
|
||||
interface nsIWorkerHolder : nsISupports
|
||||
{
|
||||
readonly attribute jsval worker;
|
||||
};
|
@ -47,7 +47,9 @@
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDOMClassInfo.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "SystemWorkerManager.h"
|
||||
|
||||
#include "CallEvent.h"
|
||||
#include "TelephonyCall.h"
|
||||
@ -454,9 +456,11 @@ NS_NewTelephony(nsPIDOMWindow* aWindow, nsIDOMTelephony** aTelephony)
|
||||
|
||||
nsRefPtr<Telephony> telephony;
|
||||
if (phoneAppURL.Equals(documentURL, nsCaseInsensitiveCStringComparator())) {
|
||||
nsCOMPtr<nsITelephone> telephone =
|
||||
do_GetService("@mozilla.org/telephony/radio-interface;1");
|
||||
NS_ENSURE_TRUE(telephone, NS_ERROR_FAILURE);
|
||||
nsIInterfaceRequestor* ireq = SystemWorkerManager::GetInterfaceRequestor();
|
||||
NS_ENSURE_TRUE(ireq, NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsCOMPtr<nsITelephone> telephone = do_GetInterface(ireq);
|
||||
NS_ENSURE_TRUE(telephone, NS_ERROR_UNEXPECTED);
|
||||
|
||||
telephony = Telephony::Create(innerWindow, telephone);
|
||||
}
|
||||
|
@ -35,6 +35,7 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
// This must always match the CID given in nsTelephonyWorker.manifest!
|
||||
#define NS_TELEPHONYWORKER_CID \
|
||||
{ 0x2d831c8d, 0x6017, 0x435b, \
|
||||
{ 0xa8, 0x0c, 0xe5, 0xd4, 0x22, 0x81, 0x0c, 0xea } }
|
||||
|
@ -48,8 +48,8 @@ Cu.import("resource://gre/modules/ril_consts.js", RIL);
|
||||
|
||||
const DEBUG = true; // set to false to suppress debug messages
|
||||
|
||||
const TELEPHONYWORKER_CONTRACTID = "@mozilla.org/telephony/worker;1";
|
||||
const TELEPHONYWORKER_CID = Components.ID("{2d831c8d-6017-435b-a80c-e5d422810cea}");
|
||||
const TELEPHONYWORKER_CID =
|
||||
Components.ID("{2d831c8d-6017-435b-a80c-e5d422810cea}");
|
||||
|
||||
const nsIAudioManager = Ci.nsIAudioManager;
|
||||
const nsITelephone = Ci.nsITelephone;
|
||||
@ -126,12 +126,11 @@ nsTelephonyWorker.prototype = {
|
||||
|
||||
classID: TELEPHONYWORKER_CID,
|
||||
classInfo: XPCOMUtils.generateCI({classID: TELEPHONYWORKER_CID,
|
||||
contractID: TELEPHONYWORKER_CONTRACTID,
|
||||
classDescription: "Telephone",
|
||||
interfaces: [Ci.nsIRadioWorker,
|
||||
interfaces: [Ci.nsIWorkerHolder,
|
||||
Ci.nsITelephone]}),
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIRadioWorker,
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWorkerHolder,
|
||||
Ci.nsITelephone]),
|
||||
|
||||
onerror: function onerror(event) {
|
||||
|
@ -820,10 +820,10 @@ nsWifiWorker.prototype = {
|
||||
classInfo: XPCOMUtils.generateCI({classID: WIFIWORKER_CID,
|
||||
contractID: WIFIWORKER_CONTRACTID,
|
||||
classDescription: "WifiWorker",
|
||||
interfaces: [Ci.nsIRadioWorker,
|
||||
interfaces: [Ci.nsIWorkerHolder,
|
||||
Ci.nsIWifi]}),
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIRadioWorker,
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWorkerHolder,
|
||||
Ci.nsIWifi]),
|
||||
|
||||
setWifiEnabled: function(enable) {
|
||||
|
@ -129,10 +129,14 @@
|
||||
using mozilla::dom::indexedDB::IndexedDatabaseManager;
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
#include "RadioManager.h"
|
||||
using mozilla::dom::telephony::RadioManager;
|
||||
#include "nsITelephone.h"
|
||||
#include "SystemWorkerManager.h"
|
||||
using mozilla::dom::telephony::SystemWorkerManager;
|
||||
#define SYSTEMWORKERMANAGER_CID \
|
||||
{0xd53b6524, 0x6ac3, 0x42b0, {0xae, 0xca, 0x62, 0xb3, 0xc4, 0xe5, 0x2b, 0x04}}
|
||||
#define SYSTEMWORKERMANAGER_CONTRACTID \
|
||||
"@mozilla.org/telephony/system-worker-manager;1"
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
#include "AudioManager.h"
|
||||
using mozilla::dom::telephony::AudioManager;
|
||||
@ -279,29 +283,8 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsChannelPolicy)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(IndexedDatabaseManager,
|
||||
IndexedDatabaseManager::FactoryCreate)
|
||||
#ifdef MOZ_B2G_RIL
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(RadioManager, RadioManager::FactoryCreate)
|
||||
|
||||
// The 'RadioManager' class controls the lifetime of the nsITelephonyWorker
|
||||
// object which is also an nsITelephone, so we don't want to register it
|
||||
// as a global service on app-startup. Instead, we'll (ab)use createInstance()
|
||||
// to always return the one singleton that 'RadioManager' holds on to.
|
||||
static nsresult
|
||||
RadioInterfaceConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
if (NULL != aOuter) {
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsITelephone> inst = RadioManager::GetTelephone();
|
||||
if (NULL == inst) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
*aResult = inst.get();
|
||||
inst.forget();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(SystemWorkerManager,
|
||||
SystemWorkerManager::FactoryCreate)
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
@ -771,8 +754,7 @@ NS_DEFINE_NAMED_CID(NS_DOMJSON_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_TEXTEDITOR_CID);
|
||||
NS_DEFINE_NAMED_CID(INDEXEDDB_MANAGER_CID);
|
||||
#ifdef MOZ_B2G_RIL
|
||||
NS_DEFINE_NAMED_CID(TELEPHONYRADIO_CID);
|
||||
NS_DEFINE_NAMED_CID(TELEPHONYRADIOINTERFACE_CID);
|
||||
NS_DEFINE_NAMED_CID(SYSTEMWORKERMANAGER_CID);
|
||||
#endif
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
NS_DEFINE_NAMED_CID(NS_AUDIOMANAGER_CID);
|
||||
@ -1044,8 +1026,7 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
|
||||
{ &kNS_TEXTEDITOR_CID, false, NULL, nsPlaintextEditorConstructor },
|
||||
{ &kINDEXEDDB_MANAGER_CID, false, NULL, IndexedDatabaseManagerConstructor },
|
||||
#ifdef MOZ_B2G_RIL
|
||||
{ &kTELEPHONYRADIO_CID, true, NULL, RadioManagerConstructor },
|
||||
{ &kTELEPHONYRADIOINTERFACE_CID, true, NULL, RadioInterfaceConstructor },
|
||||
{ &kSYSTEMWORKERMANAGER_CID, true, NULL, SystemWorkerManagerConstructor },
|
||||
#endif
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
{ &kNS_AUDIOMANAGER_CID, true, NULL, AudioManagerConstructor },
|
||||
@ -1182,8 +1163,7 @@ static const mozilla::Module::ContractIDEntry kLayoutContracts[] = {
|
||||
{ "@mozilla.org/editor/texteditor;1", &kNS_TEXTEDITOR_CID },
|
||||
{ INDEXEDDB_MANAGER_CONTRACTID, &kINDEXEDDB_MANAGER_CID },
|
||||
#ifdef MOZ_B2G_RIL
|
||||
{ TELEPHONYRADIO_CONTRACTID, &kTELEPHONYRADIO_CID },
|
||||
{ TELEPHONYRADIOINTERFACE_CONTRACTID, &kTELEPHONYRADIOINTERFACE_CID },
|
||||
{ SYSTEMWORKERMANAGER_CONTRACTID, &kSYSTEMWORKERMANAGER_CID },
|
||||
#endif
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
{ NS_AUDIOMANAGER_CONTRACTID, &kNS_AUDIOMANAGER_CID },
|
||||
@ -1245,11 +1225,8 @@ static const mozilla::Module::CategoryEntry kLayoutCategories[] = {
|
||||
{ JAVASCRIPT_GLOBAL_STATIC_NAMESET_CATEGORY, "PrivilegeManager", NS_SECURITYNAMESET_CONTRACTID },
|
||||
{ "app-startup", "Script Security Manager", "service," NS_SCRIPTSECURITYMANAGER_CONTRACTID },
|
||||
CONTENTDLF_CATEGORIES
|
||||
|
||||
// This probably should be "app-startup" but we want our testing extension to
|
||||
// be able to override the contractid so we wait until "profile-after-change"
|
||||
#ifdef MOZ_B2G_RIL
|
||||
{ "profile-after-change", "Telephony Radio", TELEPHONYRADIO_CONTRACTID },
|
||||
{ "profile-after-change", "Telephony System Worker Manager", SYSTEMWORKERMANAGER_CONTRACTID },
|
||||
#endif
|
||||
{ NULL }
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user