michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "BackgroundParentImpl.h" michael@0: michael@0: #include "mozilla/Assertions.h" michael@0: #include "mozilla/ipc/BackgroundParent.h" michael@0: #include "mozilla/ipc/PBackgroundTestParent.h" michael@0: #include "nsThreadUtils.h" michael@0: #include "nsTraceRefcnt.h" michael@0: #include "nsXULAppAPI.h" michael@0: michael@0: using mozilla::ipc::AssertIsOnBackgroundThread; michael@0: michael@0: namespace { michael@0: michael@0: void michael@0: AssertIsInMainProcess() michael@0: { michael@0: MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); michael@0: } michael@0: michael@0: void michael@0: AssertIsOnMainThread() michael@0: { michael@0: MOZ_ASSERT(NS_IsMainThread()); michael@0: } michael@0: michael@0: class TestParent MOZ_FINAL : public mozilla::ipc::PBackgroundTestParent michael@0: { michael@0: friend class mozilla::ipc::BackgroundParentImpl; michael@0: michael@0: TestParent() michael@0: { michael@0: MOZ_COUNT_CTOR(mozilla::ipc::BackgroundTestParent); michael@0: } michael@0: michael@0: ~TestParent() michael@0: { michael@0: MOZ_COUNT_DTOR(mozilla::ipc::BackgroundTestParent); michael@0: } michael@0: michael@0: virtual void michael@0: ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: } // anonymous namespace michael@0: michael@0: namespace mozilla { michael@0: namespace ipc { michael@0: michael@0: BackgroundParentImpl::BackgroundParentImpl() michael@0: { michael@0: AssertIsInMainProcess(); michael@0: AssertIsOnMainThread(); michael@0: michael@0: MOZ_COUNT_CTOR(mozilla::ipc::BackgroundParentImpl); michael@0: } michael@0: michael@0: BackgroundParentImpl::~BackgroundParentImpl() michael@0: { michael@0: AssertIsInMainProcess(); michael@0: AssertIsOnMainThread(); michael@0: michael@0: MOZ_COUNT_DTOR(mozilla::ipc::BackgroundParentImpl); michael@0: } michael@0: michael@0: void michael@0: BackgroundParentImpl::ActorDestroy(ActorDestroyReason aWhy) michael@0: { michael@0: AssertIsInMainProcess(); michael@0: AssertIsOnBackgroundThread(); michael@0: } michael@0: michael@0: PBackgroundTestParent* michael@0: BackgroundParentImpl::AllocPBackgroundTestParent(const nsCString& aTestArg) michael@0: { michael@0: AssertIsInMainProcess(); michael@0: AssertIsOnBackgroundThread(); michael@0: michael@0: return new TestParent(); michael@0: } michael@0: michael@0: bool michael@0: BackgroundParentImpl::RecvPBackgroundTestConstructor( michael@0: PBackgroundTestParent* aActor, michael@0: const nsCString& aTestArg) michael@0: { michael@0: AssertIsInMainProcess(); michael@0: AssertIsOnBackgroundThread(); michael@0: MOZ_ASSERT(aActor); michael@0: michael@0: return PBackgroundTestParent::Send__delete__(aActor, aTestArg); michael@0: } michael@0: michael@0: bool michael@0: BackgroundParentImpl::DeallocPBackgroundTestParent( michael@0: PBackgroundTestParent* aActor) michael@0: { michael@0: AssertIsInMainProcess(); michael@0: AssertIsOnBackgroundThread(); michael@0: MOZ_ASSERT(aActor); michael@0: michael@0: delete static_cast(aActor); michael@0: return true; michael@0: } michael@0: michael@0: } // namespace ipc michael@0: } // namespace mozilla michael@0: michael@0: void michael@0: TestParent::ActorDestroy(ActorDestroyReason aWhy) michael@0: { michael@0: AssertIsInMainProcess(); michael@0: AssertIsOnBackgroundThread(); michael@0: }