ipc/glue/BackgroundParentImpl.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 #include "BackgroundParentImpl.h"
michael@0 6
michael@0 7 #include "mozilla/Assertions.h"
michael@0 8 #include "mozilla/ipc/BackgroundParent.h"
michael@0 9 #include "mozilla/ipc/PBackgroundTestParent.h"
michael@0 10 #include "nsThreadUtils.h"
michael@0 11 #include "nsTraceRefcnt.h"
michael@0 12 #include "nsXULAppAPI.h"
michael@0 13
michael@0 14 using mozilla::ipc::AssertIsOnBackgroundThread;
michael@0 15
michael@0 16 namespace {
michael@0 17
michael@0 18 void
michael@0 19 AssertIsInMainProcess()
michael@0 20 {
michael@0 21 MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
michael@0 22 }
michael@0 23
michael@0 24 void
michael@0 25 AssertIsOnMainThread()
michael@0 26 {
michael@0 27 MOZ_ASSERT(NS_IsMainThread());
michael@0 28 }
michael@0 29
michael@0 30 class TestParent MOZ_FINAL : public mozilla::ipc::PBackgroundTestParent
michael@0 31 {
michael@0 32 friend class mozilla::ipc::BackgroundParentImpl;
michael@0 33
michael@0 34 TestParent()
michael@0 35 {
michael@0 36 MOZ_COUNT_CTOR(mozilla::ipc::BackgroundTestParent);
michael@0 37 }
michael@0 38
michael@0 39 ~TestParent()
michael@0 40 {
michael@0 41 MOZ_COUNT_DTOR(mozilla::ipc::BackgroundTestParent);
michael@0 42 }
michael@0 43
michael@0 44 virtual void
michael@0 45 ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
michael@0 46 };
michael@0 47
michael@0 48 } // anonymous namespace
michael@0 49
michael@0 50 namespace mozilla {
michael@0 51 namespace ipc {
michael@0 52
michael@0 53 BackgroundParentImpl::BackgroundParentImpl()
michael@0 54 {
michael@0 55 AssertIsInMainProcess();
michael@0 56 AssertIsOnMainThread();
michael@0 57
michael@0 58 MOZ_COUNT_CTOR(mozilla::ipc::BackgroundParentImpl);
michael@0 59 }
michael@0 60
michael@0 61 BackgroundParentImpl::~BackgroundParentImpl()
michael@0 62 {
michael@0 63 AssertIsInMainProcess();
michael@0 64 AssertIsOnMainThread();
michael@0 65
michael@0 66 MOZ_COUNT_DTOR(mozilla::ipc::BackgroundParentImpl);
michael@0 67 }
michael@0 68
michael@0 69 void
michael@0 70 BackgroundParentImpl::ActorDestroy(ActorDestroyReason aWhy)
michael@0 71 {
michael@0 72 AssertIsInMainProcess();
michael@0 73 AssertIsOnBackgroundThread();
michael@0 74 }
michael@0 75
michael@0 76 PBackgroundTestParent*
michael@0 77 BackgroundParentImpl::AllocPBackgroundTestParent(const nsCString& aTestArg)
michael@0 78 {
michael@0 79 AssertIsInMainProcess();
michael@0 80 AssertIsOnBackgroundThread();
michael@0 81
michael@0 82 return new TestParent();
michael@0 83 }
michael@0 84
michael@0 85 bool
michael@0 86 BackgroundParentImpl::RecvPBackgroundTestConstructor(
michael@0 87 PBackgroundTestParent* aActor,
michael@0 88 const nsCString& aTestArg)
michael@0 89 {
michael@0 90 AssertIsInMainProcess();
michael@0 91 AssertIsOnBackgroundThread();
michael@0 92 MOZ_ASSERT(aActor);
michael@0 93
michael@0 94 return PBackgroundTestParent::Send__delete__(aActor, aTestArg);
michael@0 95 }
michael@0 96
michael@0 97 bool
michael@0 98 BackgroundParentImpl::DeallocPBackgroundTestParent(
michael@0 99 PBackgroundTestParent* aActor)
michael@0 100 {
michael@0 101 AssertIsInMainProcess();
michael@0 102 AssertIsOnBackgroundThread();
michael@0 103 MOZ_ASSERT(aActor);
michael@0 104
michael@0 105 delete static_cast<TestParent*>(aActor);
michael@0 106 return true;
michael@0 107 }
michael@0 108
michael@0 109 } // namespace ipc
michael@0 110 } // namespace mozilla
michael@0 111
michael@0 112 void
michael@0 113 TestParent::ActorDestroy(ActorDestroyReason aWhy)
michael@0 114 {
michael@0 115 AssertIsInMainProcess();
michael@0 116 AssertIsOnBackgroundThread();
michael@0 117 }

mercurial