2013-11-26 23:59:41 -08:00
|
|
|
/* 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 "mozilla/Assertions.h"
|
|
|
|
#include "mozilla/ipc/BackgroundParent.h"
|
|
|
|
#include "mozilla/ipc/PBackgroundTestParent.h"
|
|
|
|
#include "nsThreadUtils.h"
|
|
|
|
#include "nsTraceRefcnt.h"
|
|
|
|
#include "nsXULAppAPI.h"
|
|
|
|
|
|
|
|
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()
|
|
|
|
{
|
2014-07-15 08:37:45 -07:00
|
|
|
MOZ_COUNT_CTOR(TestParent);
|
2013-11-26 23:59:41 -08:00
|
|
|
}
|
|
|
|
|
2014-07-15 08:37:45 -07:00
|
|
|
protected:
|
2013-11-26 23:59:41 -08:00
|
|
|
~TestParent()
|
|
|
|
{
|
2014-07-15 08:37:45 -07:00
|
|
|
MOZ_COUNT_DTOR(TestParent);
|
2013-11-26 23:59:41 -08:00
|
|
|
}
|
|
|
|
|
2014-07-15 08:37:45 -07:00
|
|
|
public:
|
2013-11-26 23:59:41 -08:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2014-09-17 16:36:01 -07:00
|
|
|
PBackgroundTestParent*
|
2013-11-26 23:59:41 -08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace ipc
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
void
|
|
|
|
TestParent::ActorDestroy(ActorDestroyReason aWhy)
|
|
|
|
{
|
|
|
|
AssertIsInMainProcess();
|
|
|
|
AssertIsOnBackgroundThread();
|
|
|
|
}
|