Bug 1857841 - pt 3. Add a new page kind named "fresh" r=glandium
[gecko.git] / dom / clients / manager / ClientSourceChild.cpp
blob7aef60518cb2433112d73997e876e48437981369
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) {
19 if (mSource) {
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();
36 return true;
39 IPCResult ClientSourceChild::RecvPClientSourceOpConstructor(
40 PClientSourceOpChild* aActor, const ClientOpConstructorArgs& aArgs) {
41 auto actor = static_cast<ClientSourceOpChild*>(aActor);
42 actor->Init(aArgs);
43 return IPC_OK();
46 mozilla::ipc::IPCResult ClientSourceChild::RecvEvictFromBFCache() {
47 if (mSource) {
48 mSource->EvictFromBFCache();
51 return IPC_OK();
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));
66 mSource = nullptr;
69 ClientSource* ClientSourceChild::GetSource() const { return mSource; }
71 void ClientSourceChild::MaybeStartTeardown() {
72 if (mTeardownStarted) {
73 return;
75 mTeardownStarted = true;
76 Unused << SendTeardown();
79 } // namespace mozilla::dom