Copy as Markdown

Other Tools

//
// Automatically generated by ipdlc.
// Edit at your own risk
//
#include "mozilla/dom/indexedDB/PBackgroundIDBFactoryChild.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/dom/indexedDB/ActorsChild.h"
#include "mozilla/dom/indexedDB/Key.h"
#include "mozilla/dom/indexedDB/KeyPath.h"
#include "mozilla/dom/indexedDB/SerializationHelpers.h"
#include "mozilla/dom/quota/SerializationHelpers.h"
#include "mozilla/ipc/IPCCore.h"
#include "mozilla/ipc/PBackgroundChild.h"
#include "mozilla/dom/indexedDB/PBackgroundIDBDatabaseChild.h"
#include "mozilla/dom/indexedDB/PBackgroundIDBFactoryRequestChild.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 dom {
namespace indexedDB {
auto PBackgroundIDBFactoryChild::Recv__delete__() -> mozilla::ipc::IPCResult
{
return IPC_OK();
}
auto PBackgroundIDBFactoryChild::RecvPBackgroundIDBDatabaseConstructor(
PBackgroundIDBDatabaseChild* actor,
const DatabaseSpec& spec,
mozilla::NotNull<PBackgroundIDBFactoryRequestChild*> request) -> mozilla::ipc::IPCResult
{
return IPC_OK();
}
MOZ_IMPLICIT PBackgroundIDBFactoryChild::PBackgroundIDBFactoryChild() :
mozilla::ipc::IRefCountedProtocol(PBackgroundIDBFactoryMsgStart, mozilla::ipc::ChildSide)
{
MOZ_COUNT_CTOR(PBackgroundIDBFactoryChild);
}
PBackgroundIDBFactoryChild::~PBackgroundIDBFactoryChild()
{
MOZ_COUNT_DTOR(PBackgroundIDBFactoryChild);
}
auto PBackgroundIDBFactoryChild::ActorAlloc() -> void
{
AddRef();
}
auto PBackgroundIDBFactoryChild::ActorDealloc() -> void
{
Release();
}
auto PBackgroundIDBFactoryChild::OtherPid() const -> ::base::ProcessId
{
::base::ProcessId pid =
::mozilla::ipc::IProtocol::ToplevelProtocol()->OtherPidMaybeInvalid();
MOZ_RELEASE_ASSERT(pid != ::base::kInvalidProcessId);
return pid;
}
auto PBackgroundIDBFactoryChild::Manager() const -> PBackgroundChild*
{
return static_cast<PBackgroundChild*>(IProtocol::Manager());
}
auto PBackgroundIDBFactoryChild::ManagedPBackgroundIDBDatabaseChild(nsTArray<PBackgroundIDBDatabaseChild*>& aArr) const -> void
{
mManagedPBackgroundIDBDatabaseChild.ToArray(aArr);
}
auto PBackgroundIDBFactoryChild::ManagedPBackgroundIDBDatabaseChild() const -> const ManagedContainer<PBackgroundIDBDatabaseChild>&
{
return mManagedPBackgroundIDBDatabaseChild;
}
auto PBackgroundIDBFactoryChild::ManagedPBackgroundIDBFactoryRequestChild(nsTArray<PBackgroundIDBFactoryRequestChild*>& aArr) const -> void
{
mManagedPBackgroundIDBFactoryRequestChild.ToArray(aArr);
}
auto PBackgroundIDBFactoryChild::ManagedPBackgroundIDBFactoryRequestChild() const -> const ManagedContainer<PBackgroundIDBFactoryRequestChild>&
{
return mManagedPBackgroundIDBFactoryRequestChild;
}
auto PBackgroundIDBFactoryChild::AllManagedActorsCount() const -> uint32_t
{
uint32_t total = 0;
total += mManagedPBackgroundIDBDatabaseChild.Count();
total += mManagedPBackgroundIDBFactoryRequestChild.Count();
return total;
}
auto PBackgroundIDBFactoryChild::OpenPBackgroundIDBDatabaseEndpoint(PBackgroundIDBDatabaseChild* aActor) -> ManagedEndpoint<PBackgroundIDBDatabaseParent>
{
if (!aActor) {
NS_WARNING("Cannot bind null PBackgroundIDBDatabaseChild actor");
return ManagedEndpoint<PBackgroundIDBDatabaseParent>();
}
if (aActor->SetManagerAndRegister(this)) {
mManagedPBackgroundIDBDatabaseChild.Insert(aActor);
} else {
NS_WARNING("Failed to bind PBackgroundIDBDatabaseChild actor");
return ManagedEndpoint<PBackgroundIDBDatabaseParent>();
}
// 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<PBackgroundIDBDatabaseParent>(mozilla::ipc::PrivateIPDLInterface(), aActor);
}
auto PBackgroundIDBFactoryChild::BindPBackgroundIDBDatabaseEndpoint(
ManagedEndpoint<PBackgroundIDBDatabaseChild> aEndpoint,
PBackgroundIDBDatabaseChild* aActor) -> bool
{
return aEndpoint.Bind(mozilla::ipc::PrivateIPDLInterface(), aActor, this, mManagedPBackgroundIDBDatabaseChild);
}
auto PBackgroundIDBFactoryChild::OpenPBackgroundIDBFactoryRequestEndpoint(PBackgroundIDBFactoryRequestChild* aActor) -> ManagedEndpoint<PBackgroundIDBFactoryRequestParent>
{
if (!aActor) {
NS_WARNING("Cannot bind null PBackgroundIDBFactoryRequestChild actor");
return ManagedEndpoint<PBackgroundIDBFactoryRequestParent>();
}
if (aActor->SetManagerAndRegister(this)) {
mManagedPBackgroundIDBFactoryRequestChild.Insert(aActor);
} else {
NS_WARNING("Failed to bind PBackgroundIDBFactoryRequestChild actor");
return ManagedEndpoint<PBackgroundIDBFactoryRequestParent>();
}
// 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<PBackgroundIDBFactoryRequestParent>(mozilla::ipc::PrivateIPDLInterface(), aActor);
}
auto PBackgroundIDBFactoryChild::BindPBackgroundIDBFactoryRequestEndpoint(
ManagedEndpoint<PBackgroundIDBFactoryRequestChild> aEndpoint,
PBackgroundIDBFactoryRequestChild* aActor) -> bool
{
return aEndpoint.Bind(mozilla::ipc::PrivateIPDLInterface(), aActor, this, mManagedPBackgroundIDBFactoryRequestChild);
}
auto PBackgroundIDBFactoryChild::SendDeleteMe() -> bool
{
UniquePtr<IPC::Message> msg__ = PBackgroundIDBFactory::Msg_DeleteMe(Id());
IPC::MessageWriter writer__{
(*(msg__)),
this};
if (mozilla::ipc::LoggingEnabledFor("PBackgroundIDBFactory", mozilla::ipc::ChildSide)) {
mozilla::ipc::LogMessageForProtocol(
"PBackgroundIDBFactoryChild",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Sending ",
msg__->type(),
mozilla::ipc::MessageDirection::eSending);
}
AUTO_PROFILER_LABEL("PBackgroundIDBFactory::Msg_DeleteMe", OTHER);
bool sendok__ = ChannelSend(std::move(msg__));
return sendok__;
}
auto PBackgroundIDBFactoryChild::SendPBackgroundIDBFactoryRequestConstructor(const FactoryRequestParams& params) -> PBackgroundIDBFactoryRequestChild*
{
PBackgroundIDBFactoryRequestChild* actor = (static_cast<indexedDB::BackgroundFactoryChild*>(this))->AllocPBackgroundIDBFactoryRequestChild(params);
return SendPBackgroundIDBFactoryRequestConstructor(std::move(actor), std::move(params));
}
auto PBackgroundIDBFactoryChild::SendPBackgroundIDBFactoryRequestConstructor(
PBackgroundIDBFactoryRequestChild* actor,
const FactoryRequestParams& params) -> PBackgroundIDBFactoryRequestChild*
{
if (!actor) {
NS_WARNING("Cannot bind null PBackgroundIDBFactoryRequestChild actor");
return nullptr;
}
if (actor->SetManagerAndRegister(this)) {
mManagedPBackgroundIDBFactoryRequestChild.Insert(actor);
} else {
NS_WARNING("Failed to bind PBackgroundIDBFactoryRequestChild actor");
return nullptr;
}
// Build our constructor message.
UniquePtr<IPC::Message> msg__ = PBackgroundIDBFactory::Msg_PBackgroundIDBFactoryRequestConstructor(Id());
IPC::MessageWriter writer__{
(*(msg__)),
this};
IPC::WriteParam((&(writer__)), actor);
// Sentinel = 'actor'
((&(writer__)))->WriteSentinel(102892058);
IPC::WriteParam((&(writer__)), params);
// Sentinel = 'params'
((&(writer__)))->WriteSentinel(146997893);
// Notify the other side about the newly created actor. This can
// fail if our manager has already been destroyed.
//
// NOTE: If the send call fails due to toplevel channel teardown,
// the `IProtocol::ChannelSend` wrapper absorbs the error for us,
// so we don't tear down actors unexpectedly.
if (mozilla::ipc::LoggingEnabledFor("PBackgroundIDBFactory", mozilla::ipc::ChildSide)) {
mozilla::ipc::LogMessageForProtocol(
"PBackgroundIDBFactoryChild",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Sending ",
msg__->type(),
mozilla::ipc::MessageDirection::eSending);
}
AUTO_PROFILER_LABEL("PBackgroundIDBFactory::Msg_PBackgroundIDBFactoryRequestConstructor", OTHER);
bool sendok__ = ChannelSend(std::move(msg__));
// Warn, destroy the actor, and return null if the message failed to
// send. Otherwise, return the successfully created actor reference.
if (!sendok__) {
NS_WARNING("Error sending PBackgroundIDBFactoryRequestChild constructor");
actor->ActorDisconnected(FailedConstructor);
return nullptr;
}
return actor;
}
auto PBackgroundIDBFactoryChild::SendGetDatabases(
const PersistenceType& persistenceType,
const PrincipalInfo& principalInfo,
mozilla::ipc::ResolveCallback<GetDatabasesResponse>&& aResolve,
mozilla::ipc::RejectCallback&& aReject) -> void
{
UniquePtr<IPC::Message> msg__ = PBackgroundIDBFactory::Msg_GetDatabases(Id());
IPC::MessageWriter writer__{
(*(msg__)),
this};
IPC::WriteParam((&(writer__)), persistenceType);
// Sentinel = 'persistenceType'
((&(writer__)))->WriteSentinel(853345864);
IPC::WriteParam((&(writer__)), principalInfo);
// Sentinel = 'principalInfo'
((&(writer__)))->WriteSentinel(633472335);
if (mozilla::ipc::LoggingEnabledFor("PBackgroundIDBFactory", mozilla::ipc::ChildSide)) {
mozilla::ipc::LogMessageForProtocol(
"PBackgroundIDBFactoryChild",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Sending ",
msg__->type(),
mozilla::ipc::MessageDirection::eSending);
}
AUTO_PROFILER_LABEL("PBackgroundIDBFactory::Msg_GetDatabases", OTHER);
ChannelSend(std::move(msg__), PBackgroundIDBFactory::Reply_GetDatabases__ID, std::move(aResolve), std::move(aReject));
return;
}
auto PBackgroundIDBFactoryChild::SendGetDatabases(
const PersistenceType& persistenceType,
const PrincipalInfo& principalInfo) -> RefPtr<GetDatabasesPromise>
{
RefPtr<MozPromise<GetDatabasesResponse, ResponseRejectReason, true>::Private> promise__ = new MozPromise<GetDatabasesResponse, ResponseRejectReason, true>::Private(__func__);
promise__->UseDirectTaskDispatch(__func__);
SendGetDatabases(std::move(persistenceType), std::move(principalInfo), [promise__](GetDatabasesResponse&& aValue) {
promise__->Resolve(std::move(aValue), __func__);
}, [promise__](ResponseRejectReason&& aReason) {
promise__->Reject(std::move(aReason), __func__);
});
return promise__;
}
auto PBackgroundIDBFactoryChild::RemoveManagee(
int32_t aProtocolId,
IProtocol* aListener) -> void
{
switch (aProtocolId) {
case PBackgroundIDBDatabaseMsgStart:
MOZ_ALWAYS_TRUE(mManagedPBackgroundIDBDatabaseChild.EnsureRemoved(static_cast<PBackgroundIDBDatabaseChild*>(aListener)));
return;
case PBackgroundIDBFactoryRequestMsgStart:
MOZ_ALWAYS_TRUE(mManagedPBackgroundIDBFactoryRequestChild.EnsureRemoved(static_cast<PBackgroundIDBFactoryRequestChild*>(aListener)));
return;
default:
FatalError("unreached");
return; }
}
auto PBackgroundIDBFactoryChild::DeallocManagee(
int32_t aProtocolId,
IProtocol* aListener) -> void
{
switch (aProtocolId) {
case PBackgroundIDBFactoryRequestMsgStart:
static_cast<indexedDB::BackgroundFactoryChild*>(this)->DeallocPBackgroundIDBFactoryRequestChild(static_cast<PBackgroundIDBFactoryRequestChild*>(aListener));
return;
default:
FatalError("unreached");
return;
}
}
auto PBackgroundIDBFactoryChild::OnMessageReceived(const Message& msg__) -> PBackgroundIDBFactoryChild::Result
{
switch (msg__.type()) {
case MANAGED_ENDPOINT_BOUND_MESSAGE_TYPE:
{
if (!mAwaitingManagedEndpointBind) {
NS_WARNING("Unexpected managed endpoint lifecycle message after actor bound!");
return MsgNotAllowed;
}
mAwaitingManagedEndpointBind = false;
return MsgProcessed;
}
case MANAGED_ENDPOINT_DROPPED_MESSAGE_TYPE:
{
if (!mAwaitingManagedEndpointBind) {
NS_WARNING("Unexpected managed endpoint lifecycle message after actor bound!");
return MsgNotAllowed;
}
mAwaitingManagedEndpointBind = false;
this->ActorDisconnected(ManagedEndpointDropped);
return MsgProcessed;
}
case PBackgroundIDBFactory::Reply_PBackgroundIDBFactoryRequestConstructor__ID:
{
return MsgProcessed;
}
case PBackgroundIDBFactory::Reply_GetDatabases__ID:
{
if (mozilla::ipc::LoggingEnabledFor("PBackgroundIDBFactory", mozilla::ipc::ChildSide)) {
mozilla::ipc::LogMessageForProtocol(
"PBackgroundIDBFactoryChild",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Received ",
(&(msg__))->type(),
mozilla::ipc::MessageDirection::eReceiving);
}
AUTO_PROFILER_LABEL("PBackgroundIDBFactory::Msg_GetDatabases", 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<GetDatabasesResponse> CallbackHolder;
auto* callback = static_cast<CallbackHolder*>(untypedCallback.get());
if (!callback) {
FatalError("Error unknown callback");
return MsgProcessingError;
}
if (resolve__) {
auto maybe__response = IPC::ReadParam<GetDatabasesResponse>((&(reader__)));
if (!maybe__response) {
FatalError("Error deserializing 'GetDatabasesResponse'");
return MsgValueError;
}
auto& response = *maybe__response;
// Sentinel = 'response'
if ((!(((&(reader__)))->ReadSentinel(260965232)))) {
mozilla::ipc::SentinelReadError("Error deserializing 'GetDatabasesResponse'");
return MsgValueError;
}
reader__.EndRead();
callback->Resolve(std::move(response));
} else {
ResponseRejectReason reason__{};
if (!IPC::ReadParam(&reader__, &reason__)) {
FatalError("Error deserializing ResponseRejectReason");
return MsgValueError;
}
reader__.EndRead();
callback->Reject(std::move(reason__));
}
return MsgProcessed;
}
case PBackgroundIDBFactory::Msg___delete____ID:
{
if (mozilla::ipc::LoggingEnabledFor("PBackgroundIDBFactory", mozilla::ipc::ChildSide)) {
mozilla::ipc::LogMessageForProtocol(
"PBackgroundIDBFactoryChild",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Received ",
(&(msg__))->type(),
mozilla::ipc::MessageDirection::eReceiving);
}
AUTO_PROFILER_LABEL("PBackgroundIDBFactory::Msg___delete__", OTHER);
mozilla::ipc::IPCResult __ok = (static_cast<indexedDB::BackgroundFactoryChild*>(this))->Recv__delete__();
if ((!(__ok))) {
mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
// Error handled in mozilla::ipc::IPCResult
return MsgProcessingError;
}
this->ActorDisconnected(Deletion);
return MsgProcessed;
}
case PBackgroundIDBFactory::Msg_PBackgroundIDBDatabaseConstructor__ID:
{
if (mozilla::ipc::LoggingEnabledFor("PBackgroundIDBFactory", mozilla::ipc::ChildSide)) {
mozilla::ipc::LogMessageForProtocol(
"PBackgroundIDBFactoryChild",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Received ",
(&(msg__))->type(),
mozilla::ipc::MessageDirection::eReceiving);
}
AUTO_PROFILER_LABEL("PBackgroundIDBFactory::Msg_PBackgroundIDBDatabaseConstructor", 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__spec = IPC::ReadParam<DatabaseSpec>((&(reader__)));
if (!maybe__spec) {
FatalError("Error deserializing 'DatabaseSpec'");
return MsgValueError;
}
auto& spec = *maybe__spec;
// Sentinel = 'spec'
if ((!(((&(reader__)))->ReadSentinel(72155564)))) {
mozilla::ipc::SentinelReadError("Error deserializing 'DatabaseSpec'");
return MsgValueError;
}
auto maybe__request = IPC::ReadParam<mozilla::NotNull<PBackgroundIDBFactoryRequestChild*>>((&(reader__)));
if (!maybe__request) {
FatalError("Error deserializing 'NotNull<PBackgroundIDBFactoryRequest>'");
return MsgValueError;
}
auto& request = *maybe__request;
// Sentinel = 'request'
if ((!(((&(reader__)))->ReadSentinel(202703626)))) {
mozilla::ipc::SentinelReadError("Error deserializing 'NotNull<PBackgroundIDBFactoryRequest>'");
return MsgValueError;
}
reader__.EndRead();
RefPtr<PBackgroundIDBDatabaseChild> actor = (static_cast<indexedDB::BackgroundFactoryChild*>(this))->AllocPBackgroundIDBDatabaseChild(spec, request);
if (!actor) {
NS_WARNING("Cannot bind null PBackgroundIDBDatabaseChild actor");
return MsgValueError;
}
if (actor->SetManagerAndRegister(this, (handle__).mId)) {
mManagedPBackgroundIDBDatabaseChild.Insert(actor);
} else {
NS_WARNING("Failed to bind PBackgroundIDBDatabaseChild actor");
return MsgValueError;
}
mozilla::ipc::IPCResult __ok = (static_cast<indexedDB::BackgroundFactoryChild*>(this))->RecvPBackgroundIDBDatabaseConstructor(actor, std::move(spec), request);
if ((!(__ok))) {
mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
// Error handled in mozilla::ipc::IPCResult
return MsgProcessingError;
}
return MsgProcessed;
}
default:
return MsgNotKnown;
}
}
auto PBackgroundIDBFactoryChild::OnMessageReceived(
const Message& msg__,
UniquePtr<Message>& reply__) -> PBackgroundIDBFactoryChild::Result
{
return MsgNotKnown;
}
auto PBackgroundIDBFactoryChild::DoomSubtree() -> void
{
for (auto* key : mManagedPBackgroundIDBDatabaseChild) {
key->DoomSubtree();
}
for (auto* key : mManagedPBackgroundIDBFactoryRequestChild) {
key->DoomSubtree();
}
SetDoomed();
}
auto PBackgroundIDBFactoryChild::PeekManagedActor() -> IProtocol*
{
if (IProtocol* actor = mManagedPBackgroundIDBDatabaseChild.Peek()) {
return actor;
}
if (IProtocol* actor = mManagedPBackgroundIDBFactoryRequestChild.Peek()) {
return actor;
}
return nullptr;
}
} // namespace indexedDB
} // namespace dom
} // namespace mozilla
namespace IPC {
auto ParamTraits<::mozilla::dom::indexedDB::PBackgroundIDBFactoryChild*>::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::dom::indexedDB::PBackgroundIDBFactoryChild*>::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, "PBackgroundIDBFactory", PBackgroundIDBFactoryMsgStart);
if (actor.isSome()) {
return static_cast<::mozilla::dom::indexedDB::PBackgroundIDBFactoryChild*>(actor.ref());
}
return {};
}
} // namespace IPC