2017-11-01 20:19:38 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* 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 "ClientSourceChild.h"
|
|
|
|
|
2017-12-05 22:54:10 +03:00
|
|
|
#include "ClientSource.h"
|
2017-11-01 20:19:38 +03:00
|
|
|
#include "ClientSourceOpChild.h"
|
|
|
|
#include "mozilla/dom/ClientIPCTypes.h"
|
|
|
|
#include "mozilla/Unused.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
using mozilla::ipc::IPCResult;
|
|
|
|
|
|
|
|
void ClientSourceChild::ActorDestroy(ActorDestroyReason aReason) {
|
|
|
|
if (mSource) {
|
|
|
|
mSource->RevokeActor(this);
|
|
|
|
|
|
|
|
// Revoking the actor link should automatically cause the owner
|
|
|
|
// to call RevokeOwner() as well.
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(!mSource);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PClientSourceOpChild* ClientSourceChild::AllocPClientSourceOpChild(
|
|
|
|
const ClientOpConstructorArgs& aArgs) {
|
|
|
|
return new ClientSourceOpChild();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ClientSourceChild::DeallocPClientSourceOpChild(
|
|
|
|
PClientSourceOpChild* aActor) {
|
2020-02-19 20:56:08 +03:00
|
|
|
static_cast<ClientSourceOpChild*>(aActor)->ScheduleDeletion();
|
2017-11-01 20:19:38 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
IPCResult ClientSourceChild::RecvPClientSourceOpConstructor(
|
|
|
|
PClientSourceOpChild* aActor, const ClientOpConstructorArgs& aArgs) {
|
|
|
|
auto actor = static_cast<ClientSourceOpChild*>(aActor);
|
|
|
|
actor->Init(aArgs);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
ClientSourceChild::ClientSourceChild(const ClientSourceConstructorArgs& aArgs)
|
|
|
|
: mSource(nullptr), mTeardownStarted(false) {}
|
|
|
|
|
|
|
|
void ClientSourceChild::SetOwner(ClientThing<ClientSourceChild>* aThing) {
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(aThing);
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(!mSource);
|
2017-12-05 22:54:10 +03:00
|
|
|
mSource = static_cast<ClientSource*>(aThing);
|
2017-11-01 20:19:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ClientSourceChild::RevokeOwner(ClientThing<ClientSourceChild>* aThing) {
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(mSource);
|
2017-12-05 22:54:10 +03:00
|
|
|
MOZ_DIAGNOSTIC_ASSERT(mSource == static_cast<ClientSource*>(aThing));
|
2017-11-01 20:19:38 +03:00
|
|
|
mSource = nullptr;
|
|
|
|
}
|
|
|
|
|
2017-12-05 22:54:10 +03:00
|
|
|
ClientSource* ClientSourceChild::GetSource() const { return mSource; }
|
|
|
|
|
2017-11-01 20:19:38 +03:00
|
|
|
void ClientSourceChild::MaybeStartTeardown() {
|
|
|
|
if (mTeardownStarted) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mTeardownStarted = true;
|
|
|
|
Unused << SendTeardown();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|