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