ipc/glue/BackgroundChildImpl.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

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     3  * You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #include "BackgroundChildImpl.h"
     7 #include "mozilla/ipc/PBackgroundTestChild.h"
     8 #include "nsTraceRefcnt.h"
    10 namespace {
    12 class TestChild MOZ_FINAL : public mozilla::ipc::PBackgroundTestChild
    13 {
    14   friend class mozilla::ipc::BackgroundChildImpl;
    16   nsCString mTestArg;
    18   TestChild(const nsCString& aTestArg)
    19   : mTestArg(aTestArg)
    20   {
    21     MOZ_COUNT_CTOR(mozilla::ipc::BackgroundTestChild);
    22   }
    24   ~TestChild()
    25   {
    26     MOZ_COUNT_DTOR(mozilla::ipc::BackgroundTestChild);
    27   }
    29   virtual bool
    30   Recv__delete__(const nsCString& aTestArg) MOZ_OVERRIDE;
    31 };
    33 } // anonymous namespace
    35 namespace mozilla {
    36 namespace ipc {
    38 // -----------------------------------------------------------------------------
    39 // BackgroundChildImpl::ThreadLocal
    40 // -----------------------------------------------------------------------------
    42 BackgroundChildImpl::
    43 ThreadLocal::ThreadLocal()
    44 {
    45   // May happen on any thread!
    46   MOZ_COUNT_CTOR(mozilla::ipc::BackgroundChildImpl::ThreadLocal);
    47 }
    49 BackgroundChildImpl::
    50 ThreadLocal::~ThreadLocal()
    51 {
    52   // May happen on any thread!
    53   MOZ_COUNT_DTOR(mozilla::ipc::BackgroundChildImpl::ThreadLocal);
    54 }
    56 // -----------------------------------------------------------------------------
    57 // BackgroundChildImpl
    58 // -----------------------------------------------------------------------------
    60 BackgroundChildImpl::BackgroundChildImpl()
    61 {
    62   // May happen on any thread!
    63   MOZ_COUNT_CTOR(mozilla::ipc::BackgroundChildImpl);
    64 }
    66 BackgroundChildImpl::~BackgroundChildImpl()
    67 {
    68   // May happen on any thread!
    69   MOZ_COUNT_DTOR(mozilla::ipc::BackgroundChildImpl);
    70 }
    72 void
    73 BackgroundChildImpl::ActorDestroy(ActorDestroyReason aWhy)
    74 {
    75   // May happen on any thread!
    76 }
    78 PBackgroundTestChild*
    79 BackgroundChildImpl::AllocPBackgroundTestChild(const nsCString& aTestArg)
    80 {
    81   return new TestChild(aTestArg);
    82 }
    84 bool
    85 BackgroundChildImpl::DeallocPBackgroundTestChild(PBackgroundTestChild* aActor)
    86 {
    87   MOZ_ASSERT(aActor);
    89   delete static_cast<TestChild*>(aActor);
    90   return true;
    91 }
    93 } // namespace ipc
    94 } // namespace mozilla
    96 bool
    97 TestChild::Recv__delete__(const nsCString& aTestArg)
    98 {
    99   MOZ_RELEASE_ASSERT(aTestArg == mTestArg,
   100                      "BackgroundTest message was corrupted!");
   102   return true;
   103 }

mercurial