Files
palemoon27/dom/presentation/ipc/PresentationChild.cpp
T
roytam1 8cb2d1cd9e import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1069230 - Presentation API implementation. Part 1 - WebIDL Bindings. r=smaug (180d2e23a)
- Bug 1142770 - part 1 - Use telephony service creator for telephony IPC service. r=hsinyi (447da4e64)
- Bug 1142770 - part 2 - disable telephonyservice and voicemailservice. r=fabrice (5e0592769)
- Bug 1069230 - Presentation API implementation. Part 2 - Presentation service and listeners. r=smaug (4be1d0628)
- Bug 1069230 - Presentation API implementation. Part 3 - IPC. r=smaug (10db1c229)
- Bug 1069230 - Presentation API implementation. Part 4 - Establish session (sender) & available changes. r=smaug (d7b358f74)
- Bug 1069230 - Presentation API implementation. Part 5 - Establish session (receiver). r=smaug (e60709725)
- Bug 1020179 - ContentPermissionPrompt change in b2g. r=fabrice (7aab4449e)
- Bug 1020179 - Test case for visibilitychange. r=fabrice (d404f25e6)
- Bug 1069230 - Presentation API implementation. Part 6 - mozChromeEvent for app launch. r=fabrice r=smaug (17081096c)
- Bug 1069230 - Presentation API implementation. Part 7 - Presentation session. r=smaug (29227f2cf)
- Bug 1069230 - Presentation API implementation. Part 8 - Data transport channel. r=jdm (2eb3a49ca)
- Bug 1069230 - Presentation API implementation. Part 9 - Tests. r=kikuo (3cb72b71e)
- Bug 1162700 - Split the AppInfo into initial setting of the values and the further initialization. r=smaug (d0b8d1470)
2021-06-08 15:21:25 +08:00

131 lines
2.9 KiB
C++

/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
/* vim: set ts=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 "mozilla/StaticPtr.h"
#include "PresentationChild.h"
#include "PresentationIPCService.h"
#include "nsThreadUtils.h"
using namespace mozilla;
using namespace mozilla::dom;
/*
* Implementation of PresentationChild
*/
PresentationChild::PresentationChild(PresentationIPCService* aService)
: mActorDestroyed(false)
, mService(aService)
{
MOZ_ASSERT(mService);
MOZ_COUNT_CTOR(PresentationChild);
}
PresentationChild::~PresentationChild()
{
MOZ_COUNT_DTOR(PresentationChild);
if (!mActorDestroyed) {
Send__delete__(this);
}
mService = nullptr;
}
void
PresentationChild::ActorDestroy(ActorDestroyReason aWhy)
{
mActorDestroyed = true;
mService->NotifyPresentationChildDestroyed();
mService = nullptr;
}
PPresentationRequestChild*
PresentationChild::AllocPPresentationRequestChild(const PresentationRequest& aRequest)
{
NS_NOTREACHED("We should never be manually allocating PPresentationRequestChild actors");
return nullptr;
}
bool
PresentationChild::DeallocPPresentationRequestChild(PPresentationRequestChild* aActor)
{
delete aActor;
return true;
}
bool
PresentationChild::RecvNotifyAvailableChange(const bool& aAvailable)
{
if (mService) {
NS_WARN_IF(NS_FAILED(mService->NotifyAvailableChange(aAvailable)));
}
return true;
}
bool
PresentationChild::RecvNotifySessionStateChange(const nsString& aSessionId,
const uint16_t& aState)
{
if (mService) {
NS_WARN_IF(NS_FAILED(mService->NotifySessionStateChange(aSessionId, aState)));
}
return true;
}
bool
PresentationChild::RecvNotifyMessage(const nsString& aSessionId,
const nsCString& aData)
{
if (mService) {
NS_WARN_IF(NS_FAILED(mService->NotifyMessage(aSessionId, aData)));
}
return true;
}
/*
* Implementation of PresentationRequestChild
*/
PresentationRequestChild::PresentationRequestChild(nsIPresentationServiceCallback* aCallback)
: mActorDestroyed(false)
, mCallback(aCallback)
{
MOZ_COUNT_CTOR(PresentationRequestChild);
}
PresentationRequestChild::~PresentationRequestChild()
{
MOZ_COUNT_DTOR(PresentationRequestChild);
mCallback = nullptr;
}
void
PresentationRequestChild::ActorDestroy(ActorDestroyReason aWhy)
{
mActorDestroyed = true;
mCallback = nullptr;
}
bool
PresentationRequestChild::Recv__delete__(const nsresult& aResult)
{
if (mActorDestroyed) {
return true;
}
if (mCallback) {
if (NS_SUCCEEDED(aResult)) {
NS_WARN_IF(NS_FAILED(mCallback->NotifySuccess()));
} else {
NS_WARN_IF(NS_FAILED(mCallback->NotifyError(aResult)));
}
}
return true;
}