mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
217 lines
5.1 KiB
C++
217 lines
5.1 KiB
C++
/* 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 "BackgroundParentImpl.h"
|
|
|
|
#include "FileDescriptorSetParent.h"
|
|
#include "mozilla/Assertions.h"
|
|
#include "mozilla/dom/PBlobParent.h"
|
|
#include "mozilla/dom/indexedDB/ActorsParent.h"
|
|
#include "mozilla/dom/ipc/BlobParent.h"
|
|
#include "mozilla/ipc/BackgroundParent.h"
|
|
#include "mozilla/ipc/PBackgroundTestParent.h"
|
|
#include "nsThreadUtils.h"
|
|
#include "nsTraceRefcnt.h"
|
|
#include "nsXULAppAPI.h"
|
|
|
|
#ifdef DISABLE_ASSERTS_FOR_FUZZING
|
|
#define ASSERT_UNLESS_FUZZING(...) do { } while (0)
|
|
#else
|
|
#define ASSERT_UNLESS_FUZZING(...) MOZ_ASSERT(false)
|
|
#endif
|
|
|
|
using mozilla::ipc::AssertIsOnBackgroundThread;
|
|
|
|
namespace {
|
|
|
|
void
|
|
AssertIsInMainProcess()
|
|
{
|
|
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
|
|
}
|
|
|
|
void
|
|
AssertIsOnMainThread()
|
|
{
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
}
|
|
|
|
class TestParent MOZ_FINAL : public mozilla::ipc::PBackgroundTestParent
|
|
{
|
|
friend class mozilla::ipc::BackgroundParentImpl;
|
|
|
|
TestParent()
|
|
{
|
|
MOZ_COUNT_CTOR(TestParent);
|
|
}
|
|
|
|
protected:
|
|
~TestParent()
|
|
{
|
|
MOZ_COUNT_DTOR(TestParent);
|
|
}
|
|
|
|
public:
|
|
virtual void
|
|
ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
|
|
};
|
|
|
|
} // anonymous namespace
|
|
|
|
namespace mozilla {
|
|
namespace ipc {
|
|
|
|
BackgroundParentImpl::BackgroundParentImpl()
|
|
{
|
|
AssertIsInMainProcess();
|
|
AssertIsOnMainThread();
|
|
|
|
MOZ_COUNT_CTOR(mozilla::ipc::BackgroundParentImpl);
|
|
}
|
|
|
|
BackgroundParentImpl::~BackgroundParentImpl()
|
|
{
|
|
AssertIsInMainProcess();
|
|
AssertIsOnMainThread();
|
|
|
|
MOZ_COUNT_DTOR(mozilla::ipc::BackgroundParentImpl);
|
|
}
|
|
|
|
void
|
|
BackgroundParentImpl::ActorDestroy(ActorDestroyReason aWhy)
|
|
{
|
|
AssertIsInMainProcess();
|
|
AssertIsOnBackgroundThread();
|
|
}
|
|
|
|
BackgroundParentImpl::PBackgroundTestParent*
|
|
BackgroundParentImpl::AllocPBackgroundTestParent(const nsCString& aTestArg)
|
|
{
|
|
AssertIsInMainProcess();
|
|
AssertIsOnBackgroundThread();
|
|
|
|
return new TestParent();
|
|
}
|
|
|
|
bool
|
|
BackgroundParentImpl::RecvPBackgroundTestConstructor(
|
|
PBackgroundTestParent* aActor,
|
|
const nsCString& aTestArg)
|
|
{
|
|
AssertIsInMainProcess();
|
|
AssertIsOnBackgroundThread();
|
|
MOZ_ASSERT(aActor);
|
|
|
|
return PBackgroundTestParent::Send__delete__(aActor, aTestArg);
|
|
}
|
|
|
|
bool
|
|
BackgroundParentImpl::DeallocPBackgroundTestParent(
|
|
PBackgroundTestParent* aActor)
|
|
{
|
|
AssertIsInMainProcess();
|
|
AssertIsOnBackgroundThread();
|
|
MOZ_ASSERT(aActor);
|
|
|
|
delete static_cast<TestParent*>(aActor);
|
|
return true;
|
|
}
|
|
|
|
auto
|
|
BackgroundParentImpl::AllocPBackgroundIDBFactoryParent(
|
|
const OptionalWindowId& aOptionalWindowId)
|
|
-> PBackgroundIDBFactoryParent*
|
|
{
|
|
using mozilla::dom::indexedDB::AllocPBackgroundIDBFactoryParent;
|
|
|
|
AssertIsInMainProcess();
|
|
AssertIsOnBackgroundThread();
|
|
|
|
return AllocPBackgroundIDBFactoryParent(this, aOptionalWindowId);
|
|
}
|
|
|
|
bool
|
|
BackgroundParentImpl::RecvPBackgroundIDBFactoryConstructor(
|
|
PBackgroundIDBFactoryParent* aActor,
|
|
const OptionalWindowId& aOptionalWindowId)
|
|
{
|
|
using mozilla::dom::indexedDB::RecvPBackgroundIDBFactoryConstructor;
|
|
|
|
AssertIsInMainProcess();
|
|
AssertIsOnBackgroundThread();
|
|
MOZ_ASSERT(aActor);
|
|
|
|
return RecvPBackgroundIDBFactoryConstructor(this, aActor, aOptionalWindowId);
|
|
}
|
|
|
|
bool
|
|
BackgroundParentImpl::DeallocPBackgroundIDBFactoryParent(
|
|
PBackgroundIDBFactoryParent* aActor)
|
|
{
|
|
AssertIsInMainProcess();
|
|
AssertIsOnBackgroundThread();
|
|
MOZ_ASSERT(aActor);
|
|
|
|
return mozilla::dom::indexedDB::DeallocPBackgroundIDBFactoryParent(aActor);
|
|
}
|
|
|
|
auto
|
|
BackgroundParentImpl::AllocPBlobParent(const BlobConstructorParams& aParams)
|
|
-> PBlobParent*
|
|
{
|
|
AssertIsInMainProcess();
|
|
AssertIsOnBackgroundThread();
|
|
|
|
if (NS_WARN_IF(aParams.type() !=
|
|
BlobConstructorParams::TParentBlobConstructorParams)) {
|
|
ASSERT_UNLESS_FUZZING();
|
|
return nullptr;
|
|
}
|
|
|
|
return mozilla::dom::BlobParent::Create(this, aParams);
|
|
}
|
|
|
|
bool
|
|
BackgroundParentImpl::DeallocPBlobParent(PBlobParent* aActor)
|
|
{
|
|
AssertIsInMainProcess();
|
|
AssertIsOnBackgroundThread();
|
|
MOZ_ASSERT(aActor);
|
|
|
|
mozilla::dom::BlobParent::Destroy(aActor);
|
|
return true;
|
|
}
|
|
|
|
PFileDescriptorSetParent*
|
|
BackgroundParentImpl::AllocPFileDescriptorSetParent(
|
|
const FileDescriptor& aFileDescriptor)
|
|
{
|
|
AssertIsInMainProcess();
|
|
AssertIsOnBackgroundThread();
|
|
|
|
return new FileDescriptorSetParent(aFileDescriptor);
|
|
}
|
|
|
|
bool
|
|
BackgroundParentImpl::DeallocPFileDescriptorSetParent(
|
|
PFileDescriptorSetParent* aActor)
|
|
{
|
|
AssertIsInMainProcess();
|
|
AssertIsOnBackgroundThread();
|
|
MOZ_ASSERT(aActor);
|
|
|
|
delete static_cast<FileDescriptorSetParent*>(aActor);
|
|
return true;
|
|
}
|
|
|
|
} // namespace ipc
|
|
} // namespace mozilla
|
|
|
|
void
|
|
TestParent::ActorDestroy(ActorDestroyReason aWhy)
|
|
{
|
|
AssertIsInMainProcess();
|
|
AssertIsOnBackgroundThread();
|
|
}
|