Thu, 22 Jan 2015 13:21:57 +0100
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 "BackgroundChildImpl.h" |
michael@0 | 6 | |
michael@0 | 7 | #include "mozilla/ipc/PBackgroundTestChild.h" |
michael@0 | 8 | #include "nsTraceRefcnt.h" |
michael@0 | 9 | |
michael@0 | 10 | namespace { |
michael@0 | 11 | |
michael@0 | 12 | class TestChild MOZ_FINAL : public mozilla::ipc::PBackgroundTestChild |
michael@0 | 13 | { |
michael@0 | 14 | friend class mozilla::ipc::BackgroundChildImpl; |
michael@0 | 15 | |
michael@0 | 16 | nsCString mTestArg; |
michael@0 | 17 | |
michael@0 | 18 | TestChild(const nsCString& aTestArg) |
michael@0 | 19 | : mTestArg(aTestArg) |
michael@0 | 20 | { |
michael@0 | 21 | MOZ_COUNT_CTOR(mozilla::ipc::BackgroundTestChild); |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | ~TestChild() |
michael@0 | 25 | { |
michael@0 | 26 | MOZ_COUNT_DTOR(mozilla::ipc::BackgroundTestChild); |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | virtual bool |
michael@0 | 30 | Recv__delete__(const nsCString& aTestArg) MOZ_OVERRIDE; |
michael@0 | 31 | }; |
michael@0 | 32 | |
michael@0 | 33 | } // anonymous namespace |
michael@0 | 34 | |
michael@0 | 35 | namespace mozilla { |
michael@0 | 36 | namespace ipc { |
michael@0 | 37 | |
michael@0 | 38 | // ----------------------------------------------------------------------------- |
michael@0 | 39 | // BackgroundChildImpl::ThreadLocal |
michael@0 | 40 | // ----------------------------------------------------------------------------- |
michael@0 | 41 | |
michael@0 | 42 | BackgroundChildImpl:: |
michael@0 | 43 | ThreadLocal::ThreadLocal() |
michael@0 | 44 | { |
michael@0 | 45 | // May happen on any thread! |
michael@0 | 46 | MOZ_COUNT_CTOR(mozilla::ipc::BackgroundChildImpl::ThreadLocal); |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | BackgroundChildImpl:: |
michael@0 | 50 | ThreadLocal::~ThreadLocal() |
michael@0 | 51 | { |
michael@0 | 52 | // May happen on any thread! |
michael@0 | 53 | MOZ_COUNT_DTOR(mozilla::ipc::BackgroundChildImpl::ThreadLocal); |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | // ----------------------------------------------------------------------------- |
michael@0 | 57 | // BackgroundChildImpl |
michael@0 | 58 | // ----------------------------------------------------------------------------- |
michael@0 | 59 | |
michael@0 | 60 | BackgroundChildImpl::BackgroundChildImpl() |
michael@0 | 61 | { |
michael@0 | 62 | // May happen on any thread! |
michael@0 | 63 | MOZ_COUNT_CTOR(mozilla::ipc::BackgroundChildImpl); |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | BackgroundChildImpl::~BackgroundChildImpl() |
michael@0 | 67 | { |
michael@0 | 68 | // May happen on any thread! |
michael@0 | 69 | MOZ_COUNT_DTOR(mozilla::ipc::BackgroundChildImpl); |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | void |
michael@0 | 73 | BackgroundChildImpl::ActorDestroy(ActorDestroyReason aWhy) |
michael@0 | 74 | { |
michael@0 | 75 | // May happen on any thread! |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | PBackgroundTestChild* |
michael@0 | 79 | BackgroundChildImpl::AllocPBackgroundTestChild(const nsCString& aTestArg) |
michael@0 | 80 | { |
michael@0 | 81 | return new TestChild(aTestArg); |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | bool |
michael@0 | 85 | BackgroundChildImpl::DeallocPBackgroundTestChild(PBackgroundTestChild* aActor) |
michael@0 | 86 | { |
michael@0 | 87 | MOZ_ASSERT(aActor); |
michael@0 | 88 | |
michael@0 | 89 | delete static_cast<TestChild*>(aActor); |
michael@0 | 90 | return true; |
michael@0 | 91 | } |
michael@0 | 92 | |
michael@0 | 93 | } // namespace ipc |
michael@0 | 94 | } // namespace mozilla |
michael@0 | 95 | |
michael@0 | 96 | bool |
michael@0 | 97 | TestChild::Recv__delete__(const nsCString& aTestArg) |
michael@0 | 98 | { |
michael@0 | 99 | MOZ_RELEASE_ASSERT(aTestArg == mTestArg, |
michael@0 | 100 | "BackgroundTest message was corrupted!"); |
michael@0 | 101 | |
michael@0 | 102 | return true; |
michael@0 | 103 | } |