Bug 870676: Part 2 - Implement IPDL for mozFMRadio. r=khuey

This commit is contained in:
Kyle Huey 2013-08-28 10:17:37 -07:00
Родитель d4da372687
Коммит 6b509a77ff
18 изменённых файлов: 844 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,182 @@
/* -*- 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/. */
#include "FMRadioChild.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/dom/FMRadioRequestChild.h"
using namespace mozilla::hal;
BEGIN_FMRADIO_NAMESPACE
StaticAutoPtr<FMRadioChild> FMRadioChild::sFMRadioChild;
FMRadioChild::FMRadioChild()
: mEnabled(false)
, mFrequency(0)
, mObserverList(FMRadioEventObserverList())
{
MOZ_COUNT_CTOR(FMRadioChild);
ContentChild::GetSingleton()->SendPFMRadioConstructor(this);
StatusInfo statusInfo;
SendGetStatusInfo(&statusInfo);
mEnabled = statusInfo.enabled();
mFrequency = statusInfo.frequency();
mUpperBound = statusInfo.upperBound();
mLowerBound= statusInfo.lowerBound();
mChannelWidth = statusInfo.channelWidth();
}
FMRadioChild::~FMRadioChild()
{
MOZ_COUNT_DTOR(FMRadioChild);
}
bool
FMRadioChild::IsEnabled() const
{
return mEnabled;
}
double
FMRadioChild::GetFrequency() const
{
return mFrequency;
}
double
FMRadioChild::GetFrequencyUpperBound() const
{
return mUpperBound;
}
double
FMRadioChild::GetFrequencyLowerBound() const
{
return mLowerBound;
}
double
FMRadioChild::GetChannelWidth() const
{
return mChannelWidth;
}
void
FMRadioChild::Enable(double aFrequency, ReplyRunnable* aReplyRunnable)
{
SendRequest(aReplyRunnable, EnableRequestArgs(aFrequency));
}
void
FMRadioChild::Disable(ReplyRunnable* aReplyRunnable)
{
SendRequest(aReplyRunnable, DisableRequestArgs());
}
void
FMRadioChild::SetFrequency(double aFrequency,
ReplyRunnable* aReplyRunnable)
{
SendRequest(aReplyRunnable, SetFrequencyRequestArgs(aFrequency));
}
void
FMRadioChild::Seek(FMRadioSeekDirection aDirection, ReplyRunnable* aReplyRunnable)
{
SendRequest(aReplyRunnable, SeekRequestArgs(aDirection));
}
void
FMRadioChild::CancelSeek(ReplyRunnable* aReplyRunnable)
{
SendRequest(aReplyRunnable, CancelSeekRequestArgs());
}
inline void
FMRadioChild::NotifyFMRadioEvent(FMRadioEventType aType)
{
mObserverList.Broadcast(aType);
}
void
FMRadioChild::AddObserver(FMRadioEventObserver* aObserver)
{
mObserverList.AddObserver(aObserver);
}
void
FMRadioChild::RemoveObserver(FMRadioEventObserver* aObserver)
{
mObserverList.RemoveObserver(aObserver);
}
void
FMRadioChild::SendRequest(ReplyRunnable* aReplyRunnable,
FMRadioRequestArgs aArgs)
{
PFMRadioRequestChild* childRequest = new FMRadioRequestChild(aReplyRunnable);
SendPFMRadioRequestConstructor(childRequest, aArgs);
}
bool
FMRadioChild::RecvNotifyFrequencyChanged(const double& aFrequency)
{
mFrequency = aFrequency;
NotifyFMRadioEvent(FrequencyChanged);
return true;
}
bool
FMRadioChild::RecvNotifyEnabledChanged(const bool& aEnabled,
const double& aFrequency)
{
mEnabled = aEnabled;
mFrequency = aFrequency;
NotifyFMRadioEvent(EnabledChanged);
return true;
}
bool
FMRadioChild::Recv__delete__()
{
return true;
}
PFMRadioRequestChild*
FMRadioChild::AllocPFMRadioRequestChild(const FMRadioRequestArgs& aArgs)
{
MOZ_CRASH();
return nullptr;
}
bool
FMRadioChild::DeallocPFMRadioRequestChild(PFMRadioRequestChild* aActor)
{
delete aActor;
return true;
}
// static
FMRadioChild*
FMRadioChild::Singleton()
{
MOZ_ASSERT(XRE_GetProcessType() != GeckoProcessType_Default);
MOZ_ASSERT(NS_IsMainThread());
if (!sFMRadioChild) {
sFMRadioChild = new FMRadioChild();
}
return sFMRadioChild;
}
END_FMRADIO_NAMESPACE

Просмотреть файл

@ -0,0 +1,91 @@
/* -*- 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_dom_fmradiochild_h__
#define mozilla_dom_fmradiochild_h__
#include "FMRadioCommon.h"
#include "FMRadioService.h"
#include "mozilla/dom/PFMRadioChild.h"
#include "mozilla/StaticPtr.h"
BEGIN_FMRADIO_NAMESPACE
/**
* FMRadioChild plays two roles:
* - Kind of proxy of FMRadioService
* Redirect all the requests coming from web content to FMRadioService
* in parent through IPC channel.
* - Child Actor of PFMRadio
* IPC channel to transfer the requests.
*/
class FMRadioChild MOZ_FINAL : public IFMRadioService
, public PFMRadioChild
{
public:
static FMRadioChild* Singleton();
~FMRadioChild();
void SendRequest(ReplyRunnable* aReplyRunnable, FMRadioRequestArgs aArgs);
/* IFMRadioService */
virtual bool IsEnabled() const MOZ_OVERRIDE;
virtual double GetFrequency() const MOZ_OVERRIDE;
virtual double GetFrequencyUpperBound() const MOZ_OVERRIDE;
virtual double GetFrequencyLowerBound() const MOZ_OVERRIDE;
virtual double GetChannelWidth() const MOZ_OVERRIDE;
virtual void Enable(double aFrequency, ReplyRunnable* aReplyRunnable) MOZ_OVERRIDE;
virtual void Disable(ReplyRunnable* aReplyRunnable) MOZ_OVERRIDE;
virtual void SetFrequency(double frequency,
ReplyRunnable* aReplyRunnable) MOZ_OVERRIDE;
virtual void Seek(mozilla::hal::FMRadioSeekDirection aDirection,
ReplyRunnable* aReplyRunnable) MOZ_OVERRIDE;
virtual void CancelSeek(ReplyRunnable* aReplyRunnable) MOZ_OVERRIDE;
virtual void AddObserver(FMRadioEventObserver* aObserver) MOZ_OVERRIDE;
virtual void RemoveObserver(FMRadioEventObserver* aObserver) MOZ_OVERRIDE;
/* PFMRadioChild */
virtual bool
Recv__delete__() MOZ_OVERRIDE;
virtual bool
RecvNotifyFrequencyChanged(const double& aFrequency) MOZ_OVERRIDE;
virtual bool
RecvNotifyEnabledChanged(const bool& aEnabled,
const double& aFrequency) MOZ_OVERRIDE;
virtual PFMRadioRequestChild*
AllocPFMRadioRequestChild(const FMRadioRequestArgs& aArgs) MOZ_OVERRIDE;
virtual bool
DeallocPFMRadioRequestChild(PFMRadioRequestChild* aActor) MOZ_OVERRIDE;
private:
FMRadioChild();
void Init();
inline void NotifyFMRadioEvent(FMRadioEventType aType);
bool mEnabled;
double mFrequency;
double mUpperBound;
double mLowerBound;
double mChannelWidth;
FMRadioEventObserverList mObserverList;
private:
static StaticAutoPtr<FMRadioChild> sFMRadioChild;
};
END_FMRADIO_NAMESPACE
#endif // mozilla_dom_fmradiochild_h__

Просмотреть файл

@ -0,0 +1,101 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#include "FMRadioParent.h"
#include "mozilla/unused.h"
#include "mozilla/dom/ContentParent.h"
#include "FMRadioRequestParent.h"
#include "FMRadioService.h"
BEGIN_FMRADIO_NAMESPACE
FMRadioParent::FMRadioParent()
{
MOZ_COUNT_CTOR(FMRadioParent);
IFMRadioService::Singleton()->AddObserver(this);
}
FMRadioParent::~FMRadioParent()
{
MOZ_COUNT_DTOR(FMRadioParent);
IFMRadioService::Singleton()->RemoveObserver(this);
}
bool
FMRadioParent::RecvGetStatusInfo(StatusInfo* aStatusInfo)
{
aStatusInfo->enabled() = IFMRadioService::Singleton()->IsEnabled();
aStatusInfo->frequency() = IFMRadioService::Singleton()->GetFrequency();
aStatusInfo->upperBound() =
IFMRadioService::Singleton()->GetFrequencyUpperBound();
aStatusInfo->lowerBound() =
IFMRadioService::Singleton()->GetFrequencyLowerBound();
aStatusInfo->channelWidth() =
IFMRadioService::Singleton()->GetChannelWidth();
return true;
}
PFMRadioRequestParent*
FMRadioParent::AllocPFMRadioRequestParent(const FMRadioRequestArgs& aArgs)
{
nsRefPtr<FMRadioRequestParent> requestParent = new FMRadioRequestParent();
switch (aArgs.type()) {
case FMRadioRequestArgs::TEnableRequestArgs:
IFMRadioService::Singleton()->Enable(
aArgs.get_EnableRequestArgs().frequency(), requestParent);
break;
case FMRadioRequestArgs::TDisableRequestArgs:
IFMRadioService::Singleton()->Disable(requestParent);
break;
case FMRadioRequestArgs::TSetFrequencyRequestArgs:
IFMRadioService::Singleton()->SetFrequency(
aArgs.get_SetFrequencyRequestArgs().frequency(), requestParent);
break;
case FMRadioRequestArgs::TSeekRequestArgs:
IFMRadioService::Singleton()->Seek(
aArgs.get_SeekRequestArgs().direction(), requestParent);
break;
case FMRadioRequestArgs::TCancelSeekRequestArgs:
IFMRadioService::Singleton()->CancelSeek(requestParent);
break;
default:
MOZ_CRASH();
}
return requestParent.forget().get();
}
bool
FMRadioParent::DeallocPFMRadioRequestParent(PFMRadioRequestParent* aActor)
{
FMRadioRequestParent* parent = static_cast<FMRadioRequestParent*>(aActor);
NS_RELEASE(parent);
return true;
}
void
FMRadioParent::Notify(const FMRadioEventType& aType)
{
switch (aType) {
case FrequencyChanged:
unused << SendNotifyFrequencyChanged(
IFMRadioService::Singleton()->GetFrequency());
break;
case EnabledChanged:
unused << SendNotifyEnabledChanged(
IFMRadioService::Singleton()->IsEnabled(),
IFMRadioService::Singleton()->GetFrequency());
break;
default:
NS_RUNTIMEABORT("not reached");
break;
}
}
END_FMRADIO_NAMESPACE

Просмотреть файл

@ -0,0 +1,41 @@
/* -*- 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_dom_fmradioparent_h__
#define mozilla_dom_fmradioparent_h__
#include "FMRadioCommon.h"
#include "mozilla/dom/PFMRadioParent.h"
#include "mozilla/HalTypes.h"
BEGIN_FMRADIO_NAMESPACE
class PFMRadioRequestParent;
class FMRadioParent MOZ_FINAL : public PFMRadioParent
, public FMRadioEventObserver
{
public:
FMRadioParent();
~FMRadioParent();
virtual bool
RecvGetStatusInfo(StatusInfo* aStatusInfo) MOZ_OVERRIDE;
virtual PFMRadioRequestParent*
AllocPFMRadioRequestParent(const FMRadioRequestArgs& aArgs) MOZ_OVERRIDE;
virtual bool
DeallocPFMRadioRequestParent(PFMRadioRequestParent* aActor) MOZ_OVERRIDE;
/* FMRadioEventObserver */
virtual void Notify(const FMRadioEventType& aType) MOZ_OVERRIDE;
};
END_FMRADIO_NAMESPACE
#endif // mozilla_dom_fmradioparent_h__

Просмотреть файл

@ -0,0 +1,33 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#include "mozilla/dom/PFMRadioRequestChild.h"
#include "FMRadioRequestChild.h"
#include "FMRadioService.h"
BEGIN_FMRADIO_NAMESPACE
FMRadioRequestChild::FMRadioRequestChild(ReplyRunnable* aReplyRunnable)
: mReplyRunnable(aReplyRunnable)
{
MOZ_COUNT_CTOR(FMRadioRequestChild);
}
FMRadioRequestChild::~FMRadioRequestChild()
{
MOZ_COUNT_DTOR(FMRadioRequestChild);
}
bool
FMRadioRequestChild::Recv__delete__(const FMRadioResponseType& aType)
{
mReplyRunnable->SetReply(aType);
NS_DispatchToMainThread(mReplyRunnable);
return true;
}
END_FMRADIO_NAMESPACE

Просмотреть файл

@ -0,0 +1,34 @@
/* -*- 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_dom_fmradiorequestchild_h__
#define mozilla_dom_fmradiorequestchild_h__
#include "FMRadioCommon.h"
#include "mozilla/dom/PFMRadioRequestChild.h"
#include "DOMRequest.h"
BEGIN_FMRADIO_NAMESPACE
class ReplyRunnable;
class FMRadioRequestChild MOZ_FINAL : public PFMRadioRequestChild
{
public:
FMRadioRequestChild(ReplyRunnable* aReplyRunnable);
~FMRadioRequestChild();
virtual bool
Recv__delete__(const FMRadioResponseType& aResponse) MOZ_OVERRIDE;
private:
nsRefPtr<ReplyRunnable> mReplyRunnable;
};
END_FMRADIO_NAMESPACE
#endif // mozilla_dom_fmradiorequestchild_h__

Просмотреть файл

@ -0,0 +1,43 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#include "FMRadioRequestParent.h"
#include "FMRadioService.h"
#include "mozilla/unused.h"
#include "mozilla/dom/PFMRadio.h"
BEGIN_FMRADIO_NAMESPACE
FMRadioRequestParent::FMRadioRequestParent()
: mActorDestroyed(false)
{
MOZ_COUNT_CTOR(FMRadioRequestParent);
}
FMRadioRequestParent::~FMRadioRequestParent()
{
MOZ_COUNT_DTOR(FMRadioRequestParent);
}
void
FMRadioRequestParent::ActorDestroy(ActorDestroyReason aWhy)
{
mActorDestroyed = true;
}
nsresult
FMRadioRequestParent::Run()
{
MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
if (!mActorDestroyed) {
unused << Send__delete__(this, mResponseType);
}
return NS_OK;
}
END_FMRADIO_NAMESPACE

Просмотреть файл

@ -0,0 +1,34 @@
/* -*- 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_dom_fmradiorequestparent_h__
#define mozilla_dom_fmradiorequestparent_h__
#include "FMRadioCommon.h"
#include "mozilla/dom/PFMRadioRequestParent.h"
#include "FMRadioService.h"
BEGIN_FMRADIO_NAMESPACE
class FMRadioRequestParent MOZ_FINAL : public PFMRadioRequestParent
, public ReplyRunnable
{
public:
FMRadioRequestParent();
~FMRadioRequestParent();
virtual void ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
NS_IMETHOD Run();
private:
bool mActorDestroyed;
};
END_FMRADIO_NAMESPACE
#endif // mozilla_dom_fmradiorequestparent_h__

Просмотреть файл

@ -0,0 +1,22 @@
# 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/.
DEPTH = @DEPTH@
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
LIBRARY_NAME = domfmradio_s
LOCAL_INCLUDES += \
-I$(topsrcdir)/dom/fmradio \
$(NULL)
include $(topsrcdir)/dom/dom-config.mk
include $(topsrcdir)/config/rules.mk
include $(topsrcdir)/ipc/chromium/chromium-config.mk

Просмотреть файл

@ -0,0 +1,94 @@
/* 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/. */
include "mozilla/HalTypes.h";
include protocol PContent;
include protocol PFMRadioRequest;
using mozilla::hal::FMRadioSeekDirection;
namespace mozilla {
namespace dom {
struct EnableRequestArgs
{
double frequency;
};
struct DisableRequestArgs
{
};
struct SetFrequencyRequestArgs
{
double frequency;
};
struct SeekRequestArgs
{
FMRadioSeekDirection direction;
};
struct CancelSeekRequestArgs
{
};
union FMRadioRequestArgs
{
EnableRequestArgs;
DisableRequestArgs;
SetFrequencyRequestArgs;
SeekRequestArgs;
CancelSeekRequestArgs;
};
struct StatusInfo
{
bool enabled;
double frequency;
double upperBound;
double lowerBound;
double channelWidth;
};
sync protocol PFMRadio
{
manager PContent;
manages PFMRadioRequest;
child:
/**
* Sent when the frequency is changed.
*/
NotifyFrequencyChanged(double frequency);
/**
* Sent when the power state of FM radio HW is changed.
*/
NotifyEnabledChanged(bool enabled, double frequency);
__delete__();
parent:
/**
* Get the current status infomation of FM radio HW synchronously.
* Sent when the singleton object of FMRadioChild is initialized.
*/
sync GetStatusInfo() returns (StatusInfo info);
/**
* Send request to parent process to operate the FM radio HW.
*
* We don't have separate Enable/SetFrequency/etc. methods instead here,
* because we can leverage the IPC messaging mechanism to manage the mapping
* of the asynchronous request and the DOMRequest we returned to the caller
* on web content, otherwise, we have to do the mapping stuff manually which
* is more error prone.
*/
PFMRadioRequest(FMRadioRequestArgs requestType);
};
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -0,0 +1,43 @@
/* 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/. */
include protocol PFMRadio;
namespace mozilla {
namespace dom {
struct ErrorResponse
{
nsString error;
};
struct SuccessResponse
{
};
union FMRadioResponseType
{
ErrorResponse;
SuccessResponse;
};
/**
* The protocol is used for sending asynchronous operation requests of
* FM radio HW from child to parent, and the type of the request is defined in
* FMRadioRequestArgs.
*
* When the request completed, the result, i.e. FMRadioResponseType, will be
* sent back to child from parent in the `__delete__` message.
*/
async protocol PFMRadioRequest
{
manager PFMRadio;
child:
__delete__(FMRadioResponseType response);
};
} // namespace dom
} // namespace mozilla

24
dom/fmradio/ipc/moz.build Normal file
Просмотреть файл

@ -0,0 +1,24 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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/.
EXPORTS.mozilla.dom += [
'FMRadioChild.h',
'FMRadioParent.h',
'FMRadioRequestChild.h',
'FMRadioRequestParent.h',
]
CPP_SOURCES += [
'FMRadioChild.cpp',
'FMRadioParent.cpp',
'FMRadioRequestChild.cpp',
'FMRadioRequestParent.cpp',
]
FAIL_ON_WARNINGS = True
LIBXUL_LIBRARY = True

Просмотреть файл

@ -98,6 +98,7 @@
#include "mozilla/dom/mobilemessage/SmsChild.h"
#include "mozilla/dom/devicestorage/DeviceStorageRequestChild.h"
#include "mozilla/dom/bluetooth/PBluetoothChild.h"
#include "mozilla/dom/PFMRadioChild.h"
#include "mozilla/ipc/InputStreamUtils.h"
#ifdef MOZ_WEBSPEECH
@ -925,6 +926,30 @@ ContentChild::DeallocPBluetoothChild(PBluetoothChild* aActor)
#endif
}
PFMRadioChild*
ContentChild::AllocPFMRadioChild()
{
#ifdef MOZ_B2G_FM
NS_RUNTIMEABORT("No one should be allocating PFMRadioChild actors");
return nullptr;
#else
NS_RUNTIMEABORT("No support for FMRadio on this platform!");
return nullptr;
#endif
}
bool
ContentChild::DeallocPFMRadioChild(PFMRadioChild* aActor)
{
#ifdef MOZ_B2G_FM
delete aActor;
return true;
#else
NS_RUNTIMEABORT("No support for FMRadio on this platform!");
return false;
#endif
}
PSpeechSynthesisChild*
ContentChild::AllocPSpeechSynthesisChild()
{

Просмотреть файл

@ -158,6 +158,9 @@ public:
virtual PBluetoothChild* AllocPBluetoothChild();
virtual bool DeallocPBluetoothChild(PBluetoothChild* aActor);
virtual PFMRadioChild* AllocPFMRadioChild();
virtual bool DeallocPFMRadioChild(PFMRadioChild* aActor);
virtual PSpeechSynthesisChild* AllocPSpeechSynthesisChild();
virtual bool DeallocPSpeechSynthesisChild(PSpeechSynthesisChild* aActor);

Просмотреть файл

@ -32,6 +32,7 @@
#include "mozilla/dom/power/PowerManagerService.h"
#include "mozilla/dom/DOMStorageIPC.h"
#include "mozilla/dom/bluetooth/PBluetoothParent.h"
#include "mozilla/dom/PFMRadioParent.h"
#include "mozilla/dom/devicestorage/DeviceStorageRequestParent.h"
#include "SmsParent.h"
#include "mozilla/Hal.h"
@ -125,6 +126,11 @@ using namespace mozilla::system;
#endif
#include "JavaScriptParent.h"
#ifdef MOZ_B2G_FM
#include "mozilla/dom/FMRadioParent.h"
#endif
#include "Crypto.h"
#ifdef MOZ_WEBSPEECH
@ -2259,6 +2265,32 @@ ContentParent::RecvPBluetoothConstructor(PBluetoothParent* aActor)
#endif
}
PFMRadioParent*
ContentParent::AllocPFMRadioParent()
{
#ifdef MOZ_B2G_FM
if (!AssertAppProcessPermission(this, "fmradio")) {
return nullptr;
}
return new FMRadioParent();
#else
NS_WARNING("No support for FMRadio on this platform!");
return nullptr;
#endif
}
bool
ContentParent::DeallocPFMRadioParent(PFMRadioParent* aActor)
{
#ifdef MOZ_B2G_FM
delete aActor;
return true;
#else
NS_WARNING("No support for FMRadio on this platform!");
return false;
#endif
}
PSpeechSynthesisParent*
ContentParent::AllocPSpeechSynthesisParent()
{

Просмотреть файл

@ -328,6 +328,9 @@ private:
virtual bool DeallocPBluetoothParent(PBluetoothParent* aActor);
virtual bool RecvPBluetoothConstructor(PBluetoothParent* aActor);
virtual PFMRadioParent* AllocPFMRadioParent();
virtual bool DeallocPFMRadioParent(PFMRadioParent* aActor);
virtual PSpeechSynthesisParent* AllocPSpeechSynthesisParent();
virtual bool DeallocPSpeechSynthesisParent(PSpeechSynthesisParent* aActor);
virtual bool RecvPSpeechSynthesisConstructor(PSpeechSynthesisParent* aActor);

Просмотреть файл

@ -33,6 +33,7 @@ LOCAL_INCLUDES += \
-I$(topsrcdir)/hal/sandbox \
-I$(topsrcdir)/dom/mobilemessage/src/ipc \
-I$(topsrcdir)/dom/devicestorage \
-I$(topsrcdir)/dom/fmradio/ipc \
-I$(topsrcdir)/widget/xpwidgets \
-I$(topsrcdir)/dom/bluetooth \
-I$(topsrcdir)/layout/base \

Просмотреть файл

@ -11,6 +11,7 @@ include protocol PCompositor;
include protocol PCrashReporter;
include protocol PExternalHelperApp;
include protocol PDeviceStorageRequest;
include protocol PFMRadio;
include protocol PHal;
include protocol PImageBridge;
include protocol PIndexedDB;
@ -126,6 +127,40 @@ union DeviceStorageParams
DeviceStorageAvailableParams;
};
struct FMRadioRequestEnableParams
{
double frequency;
};
struct FMRadioRequestDisableParams
{
};
struct FMRadioRequestSetFrequencyParams
{
double frequency;
};
struct FMRadioRequestSeekParams
{
bool upward;
};
struct FMRadioRequestCancelSeekParams
{
};
union FMRadioRequestParams
{
FMRadioRequestEnableParams;
FMRadioRequestDisableParams;
FMRadioRequestSetFrequencyParams;
FMRadioRequestSeekParams;
FMRadioRequestCancelSeekParams;
};
union PrefValue {
nsCString;
int32_t;
@ -154,6 +189,7 @@ rpc protocol PContent
manages PCrashReporter;
manages PDeviceStorageRequest;
manages PExternalHelperApp;
manages PFMRadio;
manages PHal;
manages PIndexedDB;
manages PMemoryReportRequest;
@ -319,6 +355,8 @@ parent:
PBluetooth();
PFMRadio();
// Services remoting
async StartVisitedQuery(URIParams uri);