1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "ClientSourceChild.h"
9 #include "ClientSource.h"
10 #include "ClientSourceOpChild.h"
11 #include "mozilla/dom/ClientIPCTypes.h"
12 #include "mozilla/Unused.h"
14 namespace mozilla::dom
{
16 using mozilla::ipc::IPCResult
;
18 void ClientSourceChild::ActorDestroy(ActorDestroyReason aReason
) {
20 mSource
->RevokeActor(this);
22 // Revoking the actor link should automatically cause the owner
23 // to call RevokeOwner() as well.
24 MOZ_DIAGNOSTIC_ASSERT(!mSource
);
28 PClientSourceOpChild
* ClientSourceChild::AllocPClientSourceOpChild(
29 const ClientOpConstructorArgs
& aArgs
) {
30 return new ClientSourceOpChild();
33 bool ClientSourceChild::DeallocPClientSourceOpChild(
34 PClientSourceOpChild
* aActor
) {
35 static_cast<ClientSourceOpChild
*>(aActor
)->ScheduleDeletion();
39 IPCResult
ClientSourceChild::RecvPClientSourceOpConstructor(
40 PClientSourceOpChild
* aActor
, const ClientOpConstructorArgs
& aArgs
) {
41 auto actor
= static_cast<ClientSourceOpChild
*>(aActor
);
46 mozilla::ipc::IPCResult
ClientSourceChild::RecvEvictFromBFCache() {
48 mSource
->EvictFromBFCache();
54 ClientSourceChild::ClientSourceChild(const ClientSourceConstructorArgs
& aArgs
)
55 : mSource(nullptr), mTeardownStarted(false) {}
57 void ClientSourceChild::SetOwner(ClientThing
<ClientSourceChild
>* aThing
) {
58 MOZ_DIAGNOSTIC_ASSERT(aThing
);
59 MOZ_DIAGNOSTIC_ASSERT(!mSource
);
60 mSource
= static_cast<ClientSource
*>(aThing
);
63 void ClientSourceChild::RevokeOwner(ClientThing
<ClientSourceChild
>* aThing
) {
64 MOZ_DIAGNOSTIC_ASSERT(mSource
);
65 MOZ_DIAGNOSTIC_ASSERT(mSource
== static_cast<ClientSource
*>(aThing
));
69 ClientSource
* ClientSourceChild::GetSource() const { return mSource
; }
71 void ClientSourceChild::MaybeStartTeardown() {
72 if (mTeardownStarted
) {
75 mTeardownStarted
= true;
76 Unused
<< SendTeardown();
79 } // namespace mozilla::dom