forked from Floorp-Projects/Floorp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBackgroundChildImpl.cpp
167 lines (134 loc) · 3.92 KB
/
BackgroundChildImpl.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "BackgroundChildImpl.h"
#include "FileDescriptorSetChild.h"
#include "mozilla/dom/PBlobChild.h"
#include "mozilla/dom/indexedDB/PBackgroundIDBFactoryChild.h"
#include "mozilla/dom/ipc/BlobChild.h"
#include "mozilla/ipc/PBackgroundTestChild.h"
#include "nsTraceRefcnt.h"
namespace {
class TestChild MOZ_FINAL : public mozilla::ipc::PBackgroundTestChild
{
friend class mozilla::ipc::BackgroundChildImpl;
nsCString mTestArg;
explicit TestChild(const nsCString& aTestArg)
: mTestArg(aTestArg)
{
MOZ_COUNT_CTOR(TestChild);
}
protected:
~TestChild()
{
MOZ_COUNT_DTOR(TestChild);
}
public:
virtual bool
Recv__delete__(const nsCString& aTestArg) MOZ_OVERRIDE;
};
} // anonymous namespace
namespace mozilla {
namespace ipc {
// -----------------------------------------------------------------------------
// BackgroundChildImpl::ThreadLocal
// -----------------------------------------------------------------------------
BackgroundChildImpl::
ThreadLocal::ThreadLocal()
: mCurrentTransaction(nullptr)
#ifdef MOZ_ENABLE_PROFILER_SPS
, mNextTransactionSerialNumber(1)
, mNextRequestSerialNumber(1)
#endif
{
// May happen on any thread!
MOZ_COUNT_CTOR(mozilla::ipc::BackgroundChildImpl::ThreadLocal);
}
BackgroundChildImpl::
ThreadLocal::~ThreadLocal()
{
// May happen on any thread!
MOZ_COUNT_DTOR(mozilla::ipc::BackgroundChildImpl::ThreadLocal);
}
// -----------------------------------------------------------------------------
// BackgroundChildImpl
// -----------------------------------------------------------------------------
BackgroundChildImpl::BackgroundChildImpl()
{
// May happen on any thread!
MOZ_COUNT_CTOR(mozilla::ipc::BackgroundChildImpl);
}
BackgroundChildImpl::~BackgroundChildImpl()
{
// May happen on any thread!
MOZ_COUNT_DTOR(mozilla::ipc::BackgroundChildImpl);
}
void
BackgroundChildImpl::ActorDestroy(ActorDestroyReason aWhy)
{
// May happen on any thread!
}
PBackgroundTestChild*
BackgroundChildImpl::AllocPBackgroundTestChild(const nsCString& aTestArg)
{
return new TestChild(aTestArg);
}
bool
BackgroundChildImpl::DeallocPBackgroundTestChild(PBackgroundTestChild* aActor)
{
MOZ_ASSERT(aActor);
delete static_cast<TestChild*>(aActor);
return true;
}
BackgroundChildImpl::PBackgroundIDBFactoryChild*
BackgroundChildImpl::AllocPBackgroundIDBFactoryChild(
const OptionalWindowId& aOptionalWindowId)
{
MOZ_CRASH("PBackgroundIDBFactoryChild actors should be manually "
"constructed!");
}
bool
BackgroundChildImpl::DeallocPBackgroundIDBFactoryChild(
PBackgroundIDBFactoryChild* aActor)
{
MOZ_ASSERT(aActor);
delete aActor;
return true;
}
auto
BackgroundChildImpl::AllocPBlobChild(const BlobConstructorParams& aParams)
-> PBlobChild*
{
MOZ_ASSERT(aParams.type() != BlobConstructorParams::T__None);
return mozilla::dom::BlobChild::Create(this, aParams);
}
bool
BackgroundChildImpl::DeallocPBlobChild(PBlobChild* aActor)
{
MOZ_ASSERT(aActor);
mozilla::dom::BlobChild::Destroy(aActor);
return true;
}
PFileDescriptorSetChild*
BackgroundChildImpl::AllocPFileDescriptorSetChild(
const FileDescriptor& aFileDescriptor)
{
return new FileDescriptorSetChild(aFileDescriptor);
}
bool
BackgroundChildImpl::DeallocPFileDescriptorSetChild(
PFileDescriptorSetChild* aActor)
{
MOZ_ASSERT(aActor);
delete static_cast<FileDescriptorSetChild*>(aActor);
return true;
}
} // namespace ipc
} // namespace mozilla
bool
TestChild::Recv__delete__(const nsCString& aTestArg)
{
MOZ_RELEASE_ASSERT(aTestArg == mTestArg,
"BackgroundTest message was corrupted!");
return true;
}