ipc/glue/BackgroundChildImpl.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ipc/glue/BackgroundChildImpl.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,103 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#include "BackgroundChildImpl.h"
     1.9 +
    1.10 +#include "mozilla/ipc/PBackgroundTestChild.h"
    1.11 +#include "nsTraceRefcnt.h"
    1.12 +
    1.13 +namespace {
    1.14 +
    1.15 +class TestChild MOZ_FINAL : public mozilla::ipc::PBackgroundTestChild
    1.16 +{
    1.17 +  friend class mozilla::ipc::BackgroundChildImpl;
    1.18 +
    1.19 +  nsCString mTestArg;
    1.20 +
    1.21 +  TestChild(const nsCString& aTestArg)
    1.22 +  : mTestArg(aTestArg)
    1.23 +  {
    1.24 +    MOZ_COUNT_CTOR(mozilla::ipc::BackgroundTestChild);
    1.25 +  }
    1.26 +
    1.27 +  ~TestChild()
    1.28 +  {
    1.29 +    MOZ_COUNT_DTOR(mozilla::ipc::BackgroundTestChild);
    1.30 +  }
    1.31 +
    1.32 +  virtual bool
    1.33 +  Recv__delete__(const nsCString& aTestArg) MOZ_OVERRIDE;
    1.34 +};
    1.35 +
    1.36 +} // anonymous namespace
    1.37 +
    1.38 +namespace mozilla {
    1.39 +namespace ipc {
    1.40 +
    1.41 +// -----------------------------------------------------------------------------
    1.42 +// BackgroundChildImpl::ThreadLocal
    1.43 +// -----------------------------------------------------------------------------
    1.44 +
    1.45 +BackgroundChildImpl::
    1.46 +ThreadLocal::ThreadLocal()
    1.47 +{
    1.48 +  // May happen on any thread!
    1.49 +  MOZ_COUNT_CTOR(mozilla::ipc::BackgroundChildImpl::ThreadLocal);
    1.50 +}
    1.51 +
    1.52 +BackgroundChildImpl::
    1.53 +ThreadLocal::~ThreadLocal()
    1.54 +{
    1.55 +  // May happen on any thread!
    1.56 +  MOZ_COUNT_DTOR(mozilla::ipc::BackgroundChildImpl::ThreadLocal);
    1.57 +}
    1.58 +
    1.59 +// -----------------------------------------------------------------------------
    1.60 +// BackgroundChildImpl
    1.61 +// -----------------------------------------------------------------------------
    1.62 +
    1.63 +BackgroundChildImpl::BackgroundChildImpl()
    1.64 +{
    1.65 +  // May happen on any thread!
    1.66 +  MOZ_COUNT_CTOR(mozilla::ipc::BackgroundChildImpl);
    1.67 +}
    1.68 +
    1.69 +BackgroundChildImpl::~BackgroundChildImpl()
    1.70 +{
    1.71 +  // May happen on any thread!
    1.72 +  MOZ_COUNT_DTOR(mozilla::ipc::BackgroundChildImpl);
    1.73 +}
    1.74 +
    1.75 +void
    1.76 +BackgroundChildImpl::ActorDestroy(ActorDestroyReason aWhy)
    1.77 +{
    1.78 +  // May happen on any thread!
    1.79 +}
    1.80 +
    1.81 +PBackgroundTestChild*
    1.82 +BackgroundChildImpl::AllocPBackgroundTestChild(const nsCString& aTestArg)
    1.83 +{
    1.84 +  return new TestChild(aTestArg);
    1.85 +}
    1.86 +
    1.87 +bool
    1.88 +BackgroundChildImpl::DeallocPBackgroundTestChild(PBackgroundTestChild* aActor)
    1.89 +{
    1.90 +  MOZ_ASSERT(aActor);
    1.91 +
    1.92 +  delete static_cast<TestChild*>(aActor);
    1.93 +  return true;
    1.94 +}
    1.95 +
    1.96 +} // namespace ipc
    1.97 +} // namespace mozilla
    1.98 +
    1.99 +bool
   1.100 +TestChild::Recv__delete__(const nsCString& aTestArg)
   1.101 +{
   1.102 +  MOZ_RELEASE_ASSERT(aTestArg == mTestArg,
   1.103 +                     "BackgroundTest message was corrupted!");
   1.104 +
   1.105 +  return true;
   1.106 +}

mercurial