1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "SocketProcessBridgeParent.h"
7 #include "SocketProcessLogging.h"
9 #include "mozilla/ipc/BackgroundParent.h"
10 #include "mozilla/ipc/Endpoint.h"
11 #include "SocketProcessChild.h"
16 SocketProcessBridgeParent::SocketProcessBridgeParent(
17 ProcessId aId
, Endpoint
<PSocketProcessBridgeParent
>&& aEndpoint
)
18 : mId(aId
), mClosed(false) {
20 "CONSTRUCT SocketProcessBridgeParent::SocketProcessBridgeParent mId=%d\n",
22 MOZ_COUNT_CTOR(SocketProcessBridgeParent
);
23 DebugOnly
<bool> ok
= aEndpoint
.Bind(this);
27 SocketProcessBridgeParent::~SocketProcessBridgeParent() {
28 LOG(("DESTRUCT SocketProcessBridgeParent::SocketProcessBridgeParent mId=%d\n",
30 MOZ_COUNT_DTOR(SocketProcessBridgeParent
);
33 mozilla::ipc::IPCResult
SocketProcessBridgeParent::RecvTest() {
34 LOG(("SocketProcessBridgeParent::RecvTest\n"));
39 mozilla::ipc::IPCResult
SocketProcessBridgeParent::RecvInitBackground(
40 Endpoint
<PBackgroundParent
>&& aEndpoint
) {
41 LOG(("SocketProcessBridgeParent::RecvInitBackground mId=%d\n", mId
));
42 if (!ipc::BackgroundParent::Alloc(nullptr, std::move(aEndpoint
))) {
43 return IPC_FAIL(this, "BackgroundParent::Alloc failed");
49 void SocketProcessBridgeParent::ActorDestroy(ActorDestroyReason aWhy
) {
50 LOG(("SocketProcessBridgeParent::ActorDestroy mId=%d\n", mId
));
53 GetCurrentSerialEventTarget()->Dispatch(
54 NewRunnableMethod("net::SocketProcessBridgeParent::DeferredDestroy", this,
55 &SocketProcessBridgeParent::DeferredDestroy
));
58 void SocketProcessBridgeParent::DeferredDestroy() {
59 if (SocketProcessChild
* child
= SocketProcessChild::GetSingleton()) {
60 child
->DestroySocketProcessBridgeParent(mId
);
65 } // namespace mozilla