mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 01:35:35 +00:00
3a9ff448dc
Backed out changeset e6cd15d43b5a (bug 1121472) Backed out changeset 4f9788639f3f (bug 966439) Backed out changeset ac9a967e5a10 (bug 966439) Backed out changeset 14d322737871 (bug 966439) Backed out changeset 8f941e519580 (bug 966439) Backed out changeset b82d1010c6b4 (bug 966439) Backed out changeset 2c29a52a03bd (bug 966439) Backed out changeset e4b0802a3f06 (bug 966439) Backed out changeset bdc9a0310034 (bug 966439) Backed out changeset 6b3ae19628e6 (bug 966439) Backed out changeset 3d23e775033a (bug 966439) CLOSED TREE
219 lines
5.1 KiB
C++
219 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 LoggingInfo& aLoggingInfo)
|
|
-> PBackgroundIDBFactoryParent*
|
|
{
|
|
using mozilla::dom::indexedDB::AllocPBackgroundIDBFactoryParent;
|
|
|
|
AssertIsInMainProcess();
|
|
AssertIsOnBackgroundThread();
|
|
|
|
return AllocPBackgroundIDBFactoryParent(aLoggingInfo);
|
|
}
|
|
|
|
bool
|
|
BackgroundParentImpl::RecvPBackgroundIDBFactoryConstructor(
|
|
PBackgroundIDBFactoryParent* aActor,
|
|
const LoggingInfo& aLoggingInfo)
|
|
{
|
|
using mozilla::dom::indexedDB::RecvPBackgroundIDBFactoryConstructor;
|
|
|
|
AssertIsInMainProcess();
|
|
AssertIsOnBackgroundThread();
|
|
MOZ_ASSERT(aActor);
|
|
|
|
return RecvPBackgroundIDBFactoryConstructor(aActor, aLoggingInfo);
|
|
}
|
|
|
|
bool
|
|
BackgroundParentImpl::DeallocPBackgroundIDBFactoryParent(
|
|
PBackgroundIDBFactoryParent* aActor)
|
|
{
|
|
using mozilla::dom::indexedDB::DeallocPBackgroundIDBFactoryParent;
|
|
|
|
AssertIsInMainProcess();
|
|
AssertIsOnBackgroundThread();
|
|
MOZ_ASSERT(aActor);
|
|
|
|
return 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();
|
|
}
|