ipc/glue/BackgroundParentImpl.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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 "BackgroundParentImpl.h"
     7 #include "mozilla/Assertions.h"
     8 #include "mozilla/ipc/BackgroundParent.h"
     9 #include "mozilla/ipc/PBackgroundTestParent.h"
    10 #include "nsThreadUtils.h"
    11 #include "nsTraceRefcnt.h"
    12 #include "nsXULAppAPI.h"
    14 using mozilla::ipc::AssertIsOnBackgroundThread;
    16 namespace {
    18 void
    19 AssertIsInMainProcess()
    20 {
    21   MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
    22 }
    24 void
    25 AssertIsOnMainThread()
    26 {
    27   MOZ_ASSERT(NS_IsMainThread());
    28 }
    30 class TestParent MOZ_FINAL : public mozilla::ipc::PBackgroundTestParent
    31 {
    32   friend class mozilla::ipc::BackgroundParentImpl;
    34   TestParent()
    35   {
    36     MOZ_COUNT_CTOR(mozilla::ipc::BackgroundTestParent);
    37   }
    39   ~TestParent()
    40   {
    41     MOZ_COUNT_DTOR(mozilla::ipc::BackgroundTestParent);
    42   }
    44   virtual void
    45   ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
    46 };
    48 } // anonymous namespace
    50 namespace mozilla {
    51 namespace ipc {
    53 BackgroundParentImpl::BackgroundParentImpl()
    54 {
    55   AssertIsInMainProcess();
    56   AssertIsOnMainThread();
    58   MOZ_COUNT_CTOR(mozilla::ipc::BackgroundParentImpl);
    59 }
    61 BackgroundParentImpl::~BackgroundParentImpl()
    62 {
    63   AssertIsInMainProcess();
    64   AssertIsOnMainThread();
    66   MOZ_COUNT_DTOR(mozilla::ipc::BackgroundParentImpl);
    67 }
    69 void
    70 BackgroundParentImpl::ActorDestroy(ActorDestroyReason aWhy)
    71 {
    72   AssertIsInMainProcess();
    73   AssertIsOnBackgroundThread();
    74 }
    76 PBackgroundTestParent*
    77 BackgroundParentImpl::AllocPBackgroundTestParent(const nsCString& aTestArg)
    78 {
    79   AssertIsInMainProcess();
    80   AssertIsOnBackgroundThread();
    82   return new TestParent();
    83 }
    85 bool
    86 BackgroundParentImpl::RecvPBackgroundTestConstructor(
    87                                                   PBackgroundTestParent* aActor,
    88                                                   const nsCString& aTestArg)
    89 {
    90   AssertIsInMainProcess();
    91   AssertIsOnBackgroundThread();
    92   MOZ_ASSERT(aActor);
    94   return PBackgroundTestParent::Send__delete__(aActor, aTestArg);
    95 }
    97 bool
    98 BackgroundParentImpl::DeallocPBackgroundTestParent(
    99                                                   PBackgroundTestParent* aActor)
   100 {
   101   AssertIsInMainProcess();
   102   AssertIsOnBackgroundThread();
   103   MOZ_ASSERT(aActor);
   105   delete static_cast<TestParent*>(aActor);
   106   return true;
   107 }
   109 } // namespace ipc
   110 } // namespace mozilla
   112 void
   113 TestParent::ActorDestroy(ActorDestroyReason aWhy)
   114 {
   115   AssertIsInMainProcess();
   116   AssertIsOnBackgroundThread();
   117 }

mercurial