Copy as Markdown

Other Tools

//
// Automatically generated by ipdlc.
// Edit at your own risk
//
#include "mozilla/layers/PVideoBridgeParent.h"
#include "gfxipc/ShadowLayerUtils.h"
#include "mozilla/GfxMessageUtils.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/ipc/IPCCore.h"
#include "mozilla/layers/CompositorTypes.h"
#include "mozilla/layers/LayersMessageUtils.h"
#include "mozilla/layers/VideoBridgeParent.h"
#include "mozilla/layers/WebRenderMessageUtils.h"
#include "nsPoint.h"
#include "nsRect.h"
#include "mozilla/layers/PTextureParent.h"
#include "ipc/IPCMessageUtils.h"
#include "ipc/IPCMessageUtilsSpecializations.h"
#include "nsIFile.h"
#include "mozilla/ipc/Endpoint.h"
#include "mozilla/ipc/ProtocolMessageUtils.h"
#include "mozilla/ipc/ProtocolUtils.h"
#include "mozilla/ipc/ShmemMessageUtils.h"
#include "mozilla/ipc/TaintingIPCUtils.h"
namespace mozilla {
namespace layers {
auto PVideoBridgeParent::RecvPTextureConstructor(
PTextureParent* actor,
const SurfaceDescriptor& aSharedData,
ReadLockDescriptor&& aReadLock,
const LayersBackend& aBackend,
const TextureFlags& aTextureFlags,
const ContentParentId& aContentId,
const uint64_t& aSerial) -> mozilla::ipc::IPCResult
{
return IPC_OK();
}
auto PVideoBridgeParent::ProcessingError(
Result aCode,
const char* aReason) -> void
{
}
auto PVideoBridgeParent::ShouldContinueFromReplyTimeout() -> bool
{
return true;
}
MOZ_IMPLICIT PVideoBridgeParent::PVideoBridgeParent() :
mozilla::ipc::IToplevelProtocol("PVideoBridgeParent", PVideoBridgeMsgStart, mozilla::ipc::ParentSide)
{
MOZ_COUNT_CTOR(PVideoBridgeParent);
}
PVideoBridgeParent::~PVideoBridgeParent()
{
MOZ_COUNT_DTOR(PVideoBridgeParent);
}
auto PVideoBridgeParent::ActorAlloc() -> void
{
MOZ_RELEASE_ASSERT(XRE_IsParentProcess() || XRE_IsGPUProcess(), "Invalid process for `PVideoBridgeParent'");
AddRef();
}
auto PVideoBridgeParent::ActorDealloc() -> void
{
Release();
}
auto PVideoBridgeParent::OtherPid() const -> ::base::ProcessId
{
::base::ProcessId pid =
::mozilla::ipc::IProtocol::ToplevelProtocol()->OtherPidMaybeInvalid();
MOZ_RELEASE_ASSERT(pid != ::base::kInvalidProcessId);
return pid;
}
auto PVideoBridgeParent::ManagedPTextureParent(nsTArray<PTextureParent*>& aArr) const -> void
{
mManagedPTextureParent.ToArray(aArr);
}
auto PVideoBridgeParent::ManagedPTextureParent() const -> const ManagedContainer<PTextureParent>&
{
return mManagedPTextureParent;
}
auto PVideoBridgeParent::AllManagedActorsCount() const -> uint32_t
{
uint32_t total = 0;
total += mManagedPTextureParent.Count();
return total;
}
auto PVideoBridgeParent::OpenPTextureEndpoint(PTextureParent* aActor) -> ManagedEndpoint<PTextureChild>
{
if (!aActor) {
NS_WARNING("Cannot bind null PTextureParent actor");
return ManagedEndpoint<PTextureChild>();
}
if (aActor->SetManagerAndRegister(this)) {
mManagedPTextureParent.Insert(aActor);
} else {
NS_WARNING("Failed to bind PTextureParent actor");
return ManagedEndpoint<PTextureChild>();
}
// Mark our actor as awaiting the other side to be bound. This will
// be cleared when a `MANAGED_ENDPOINT_{DROPPED,BOUND}` message is
// received.
aActor->mAwaitingManagedEndpointBind = true;
return ManagedEndpoint<PTextureChild>(mozilla::ipc::PrivateIPDLInterface(), aActor);
}
auto PVideoBridgeParent::BindPTextureEndpoint(
ManagedEndpoint<PTextureParent> aEndpoint,
PTextureParent* aActor) -> bool
{
return aEndpoint.Bind(mozilla::ipc::PrivateIPDLInterface(), aActor, this, mManagedPTextureParent);
}
auto PVideoBridgeParent::SendPing(
mozilla::ipc::ResolveCallback<void_t>&& aResolve,
mozilla::ipc::RejectCallback&& aReject) -> void
{
UniquePtr<IPC::Message> msg__ = PVideoBridge::Msg_Ping(MSG_ROUTING_CONTROL);
IPC::MessageWriter writer__{
(*(msg__)),
this};
if (mozilla::ipc::LoggingEnabledFor("PVideoBridge", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PVideoBridgeParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Sending ",
msg__->type(),
mozilla::ipc::MessageDirection::eSending);
}
AUTO_PROFILER_LABEL("PVideoBridge::Msg_Ping", OTHER);
ChannelSend(std::move(msg__), PVideoBridge::Reply_Ping__ID, std::move(aResolve), std::move(aReject));
return;
}
auto PVideoBridgeParent::SendPing() -> RefPtr<PingPromise>
{
RefPtr<MozPromise<void_t, ResponseRejectReason, true>::Private> promise__ = new MozPromise<void_t, ResponseRejectReason, true>::Private(__func__);
promise__->UseDirectTaskDispatch(__func__);
SendPing([promise__](void_t&& aValue) {
promise__->Resolve(std::move(aValue), __func__);
}, [promise__](ResponseRejectReason&& aReason) {
promise__->Reject(std::move(aReason), __func__);
});
return promise__;
}
auto PVideoBridgeParent::RemoveManagee(
int32_t aProtocolId,
IProtocol* aListener) -> void
{
switch (aProtocolId) {
case PTextureMsgStart:
MOZ_ALWAYS_TRUE(mManagedPTextureParent.EnsureRemoved(static_cast<PTextureParent*>(aListener)));
return;
default:
FatalError("unreached");
return; }
}
auto PVideoBridgeParent::DeallocManagee(
int32_t aProtocolId,
IProtocol* aListener) -> void
{
switch (aProtocolId) {
case PTextureMsgStart:
static_cast<VideoBridgeParent*>(this)->DeallocPTextureParent(static_cast<PTextureParent*>(aListener));
return;
default:
FatalError("unreached");
return;
}
}
auto PVideoBridgeParent::OnMessageReceived(const Message& msg__) -> PVideoBridgeParent::Result
{
int32_t route__ = msg__.routing_id();
if (MSG_ROUTING_CONTROL != route__) {
IProtocol* routed__ = Lookup(route__);
if (!routed__ || !routed__->GetLifecycleProxy()) {
if (mozilla::ipc::LoggingEnabledFor("PVideoBridge", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PVideoBridgeParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Ignored message for dead actor",
(&(msg__))->type(),
mozilla::ipc::MessageDirection::eSending);
}
return MsgProcessed;
}
RefPtr<mozilla::ipc::ActorLifecycleProxy> proxy__ =
routed__->GetLifecycleProxy();
return proxy__->Get()->OnMessageReceived(msg__);
}
switch (msg__.type()) {
case PVideoBridge::Reply_Ping__ID:
{
if (mozilla::ipc::LoggingEnabledFor("PVideoBridge", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PVideoBridgeParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Received ",
(&(msg__))->type(),
mozilla::ipc::MessageDirection::eReceiving);
}
AUTO_PROFILER_LABEL("PVideoBridge::Msg_Ping", OTHER);
IPC::MessageReader reader__{
msg__,
this};
bool resolve__ = false;
if (!IPC::ReadParam(&reader__, &resolve__)) {
FatalError("Error deserializing bool");
return MsgValueError;
}
UniquePtr<MessageChannel::UntypedCallbackHolder> untypedCallback =
GetIPCChannel()->PopCallback(msg__, Id());
typedef MessageChannel::CallbackHolder<void_t> CallbackHolder;
auto* callback = static_cast<CallbackHolder*>(untypedCallback.get());
if (!callback) {
FatalError("Error unknown callback");
return MsgProcessingError;
}
if (resolve__) {
auto maybe__ok = IPC::ReadParam<void_t>((&(reader__)));
if (!maybe__ok) {
FatalError("Error deserializing 'void_t'");
return MsgValueError;
}
auto& ok = *maybe__ok;
// Sentinel = 'ok'
if ((!(((&(reader__)))->ReadSentinel(21692635)))) {
mozilla::ipc::SentinelReadError("Error deserializing 'void_t'");
return MsgValueError;
}
reader__.EndRead();
callback->Resolve(std::move(ok));
} else {
ResponseRejectReason reason__{};
if (!IPC::ReadParam(&reader__, &reason__)) {
FatalError("Error deserializing ResponseRejectReason");
return MsgValueError;
}
reader__.EndRead();
callback->Reject(std::move(reason__));
}
return MsgProcessed;
}
case PVideoBridge::Msg_PTextureConstructor__ID:
{
if (mozilla::ipc::LoggingEnabledFor("PVideoBridge", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PVideoBridgeParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Received ",
(&(msg__))->type(),
mozilla::ipc::MessageDirection::eReceiving);
}
AUTO_PROFILER_LABEL("PVideoBridge::Msg_PTextureConstructor", OTHER);
IPC::MessageReader reader__{
msg__,
this};
auto maybe__handle__ = IPC::ReadParam<ActorHandle>((&(reader__)));
if (!maybe__handle__) {
FatalError("Error deserializing 'ActorHandle'");
return MsgValueError;
}
auto& handle__ = *maybe__handle__;
// Sentinel = 'actor'
if ((!(((&(reader__)))->ReadSentinel(102892058)))) {
mozilla::ipc::SentinelReadError("Error deserializing 'ActorHandle'");
return MsgValueError;
}
auto maybe__aSharedData = IPC::ReadParam<SurfaceDescriptor>((&(reader__)));
if (!maybe__aSharedData) {
FatalError("Error deserializing 'SurfaceDescriptor'");
return MsgValueError;
}
auto& aSharedData = *maybe__aSharedData;
// Sentinel = 'aSharedData'
if ((!(((&(reader__)))->ReadSentinel(420480051)))) {
mozilla::ipc::SentinelReadError("Error deserializing 'SurfaceDescriptor'");
return MsgValueError;
}
auto maybe__aReadLock = IPC::ReadParam<ReadLockDescriptor>((&(reader__)));
if (!maybe__aReadLock) {
FatalError("Error deserializing 'ReadLockDescriptor'");
return MsgValueError;
}
auto& aReadLock = *maybe__aReadLock;
// Sentinel = 'aReadLock'
if ((!(((&(reader__)))->ReadSentinel(279774055)))) {
mozilla::ipc::SentinelReadError("Error deserializing 'ReadLockDescriptor'");
return MsgValueError;
}
auto maybe__aBackend = IPC::ReadParam<LayersBackend>((&(reader__)));
if (!maybe__aBackend) {
FatalError("Error deserializing 'LayersBackend'");
return MsgValueError;
}
auto& aBackend = *maybe__aBackend;
// Sentinel = 'aBackend'
if ((!(((&(reader__)))->ReadSentinel(221119242)))) {
mozilla::ipc::SentinelReadError("Error deserializing 'LayersBackend'");
return MsgValueError;
}
auto maybe__aTextureFlags = IPC::ReadParam<TextureFlags>((&(reader__)));
if (!maybe__aTextureFlags) {
FatalError("Error deserializing 'TextureFlags'");
return MsgValueError;
}
auto& aTextureFlags = *maybe__aTextureFlags;
// Sentinel = 'aTextureFlags'
if ((!(((&(reader__)))->ReadSentinel(614139200)))) {
mozilla::ipc::SentinelReadError("Error deserializing 'TextureFlags'");
return MsgValueError;
}
auto maybe__aContentId = IPC::ReadParam<ContentParentId>((&(reader__)));
if (!maybe__aContentId) {
FatalError("Error deserializing 'ContentParentId'");
return MsgValueError;
}
auto& aContentId = *maybe__aContentId;
// Sentinel = 'aContentId'
if ((!(((&(reader__)))->ReadSentinel(358876138)))) {
mozilla::ipc::SentinelReadError("Error deserializing 'ContentParentId'");
return MsgValueError;
}
auto maybe__aSerial = IPC::ReadParam<uint64_t>((&(reader__)));
if (!maybe__aSerial) {
FatalError("Error deserializing 'uint64_t'");
return MsgValueError;
}
auto& aSerial = *maybe__aSerial;
// Sentinel = 'aSerial'
if ((!(((&(reader__)))->ReadSentinel(181011138)))) {
mozilla::ipc::SentinelReadError("Error deserializing 'uint64_t'");
return MsgValueError;
}
reader__.EndRead();
PTextureParent* actor = (static_cast<VideoBridgeParent*>(this))->AllocPTextureParent(aSharedData, aReadLock, aBackend, aTextureFlags, aContentId, aSerial);
if (!actor) {
NS_WARNING("Cannot bind null PTextureParent actor");
return MsgValueError;
}
if (actor->SetManagerAndRegister(this, (handle__).mId)) {
mManagedPTextureParent.Insert(actor);
} else {
NS_WARNING("Failed to bind PTextureParent actor");
return MsgValueError;
}
mozilla::ipc::IPCResult __ok = (static_cast<VideoBridgeParent*>(this))->RecvPTextureConstructor(std::move(actor), std::move(aSharedData), std::move(aReadLock), std::move(aBackend), std::move(aTextureFlags), std::move(aContentId), std::move(aSerial));
if ((!(__ok))) {
mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
// Error handled in mozilla::ipc::IPCResult
return MsgProcessingError;
}
return MsgProcessed;
}
default:
return MsgNotKnown;
case SHMEM_CREATED_MESSAGE_TYPE:
{
if (!ShmemCreated(msg__)) {
return MsgPayloadError;
}
return MsgProcessed;
}
case SHMEM_DESTROYED_MESSAGE_TYPE:
{
if (!ShmemDestroyed(msg__)) {
return MsgPayloadError;
}
return MsgProcessed;
}
}
}
auto PVideoBridgeParent::OnMessageReceived(
const Message& msg__,
UniquePtr<Message>& reply__) -> PVideoBridgeParent::Result
{
int32_t route__ = msg__.routing_id();
if (MSG_ROUTING_CONTROL != route__) {
IProtocol* routed__ = Lookup(route__);
if (!routed__ || !routed__->GetLifecycleProxy()) {
return MsgRouteError;
}
RefPtr<mozilla::ipc::ActorLifecycleProxy> proxy__ =
routed__->GetLifecycleProxy();
return proxy__->Get()->OnMessageReceived(msg__, reply__);
}
return MsgNotKnown;
}
auto PVideoBridgeParent::DoomSubtree() -> void
{
for (auto* key : mManagedPTextureParent) {
key->DoomSubtree();
}
SetDoomed();
}
auto PVideoBridgeParent::PeekManagedActor() -> IProtocol*
{
if (IProtocol* actor = mManagedPTextureParent.Peek()) {
return actor;
}
return nullptr;
}
} // namespace layers
} // namespace mozilla
namespace IPC {
auto ParamTraits<::mozilla::layers::PVideoBridgeParent*>::Write(
IPC::MessageWriter* aWriter,
const paramType& aVar) -> void
{
MOZ_RELEASE_ASSERT(
aWriter->GetActor(),
"Cannot serialize managed actors without an actor");
int32_t id;
if (!aVar) {
id = 0; // kNullActorId
} else {
id = aVar->Id();
if (id == 1) { // kFreedActorId
aVar->FatalError("Actor has been |delete|d");
}
MOZ_RELEASE_ASSERT(
aWriter->GetActor()->GetIPCChannel() == aVar->GetIPCChannel(),
"Actor must be from the same channel as the"
" actor it's being sent over");
MOZ_RELEASE_ASSERT(
aVar->CanSend(),
"Actor must still be open when sending");
}
IPC::WriteParam(aWriter, id);
}
auto ParamTraits<::mozilla::layers::PVideoBridgeParent*>::Read(IPC::MessageReader* aReader) -> IPC::ReadResult<paramType>
{
MOZ_RELEASE_ASSERT(
aReader->GetActor(),
"Cannot deserialize managed actors without an actor");
mozilla::Maybe<mozilla::ipc::IProtocol*> actor = aReader->GetActor()
->ReadActor(aReader, true, "PVideoBridge", PVideoBridgeMsgStart);
if (actor.isSome()) {
return static_cast<::mozilla::layers::PVideoBridgeParent*>(actor.ref());
}
return {};
}
} // namespace IPC