mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-16 13:56:29 +00:00
Bug 1312800 - Remove dom/inputport. r=jst
MozReview-Commit-ID: BhvPV6lIWd3 --HG-- extra : rebase_source : 647c6531521c7317144c7bc436753be8c57f1327
This commit is contained in:
parent
fb3661afd7
commit
84c6b489b3
@ -40,7 +40,6 @@
|
||||
#include "mozilla/dom/power/PowerManagerService.h"
|
||||
#include "mozilla/dom/FlyWebPublishedServer.h"
|
||||
#include "mozilla/dom/FlyWebService.h"
|
||||
#include "mozilla/dom/InputPortManager.h"
|
||||
#include "mozilla/dom/Permissions.h"
|
||||
#include "mozilla/dom/Presentation.h"
|
||||
#include "mozilla/dom/ServiceWorkerContainer.h"
|
||||
@ -207,7 +206,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Navigator)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBatteryManager)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBatteryPromise)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPowerManager)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mInputPortManager)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mConnection)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mStorageManager)
|
||||
#ifdef MOZ_AUDIO_CHANNEL_MANAGER
|
||||
@ -270,10 +268,6 @@ Navigator::Invalidate()
|
||||
mPowerManager = nullptr;
|
||||
}
|
||||
|
||||
if (mInputPortManager) {
|
||||
mInputPortManager = nullptr;
|
||||
}
|
||||
|
||||
if (mConnection) {
|
||||
mConnection->Shutdown();
|
||||
mConnection = nullptr;
|
||||
@ -1583,23 +1577,6 @@ Navigator::RequestWakeLock(const nsAString &aTopic, ErrorResult& aRv)
|
||||
return pmService->NewWakeLock(aTopic, mWindow, aRv);
|
||||
}
|
||||
|
||||
InputPortManager*
|
||||
Navigator::GetInputPortManager(ErrorResult& aRv)
|
||||
{
|
||||
if (!mInputPortManager) {
|
||||
if (!mWindow) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
mInputPortManager = InputPortManager::Create(mWindow, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return mInputPortManager;
|
||||
}
|
||||
|
||||
already_AddRefed<LegacyMozTCPSocket>
|
||||
Navigator::MozTCPSocket()
|
||||
{
|
||||
|
@ -73,7 +73,6 @@ class Connection;
|
||||
} // namespace network
|
||||
|
||||
class PowerManager;
|
||||
class InputPortManager;
|
||||
class DeviceStorageAreaListener;
|
||||
class Presentation;
|
||||
class LegacyMozTCPSocket;
|
||||
@ -209,7 +208,6 @@ public:
|
||||
ErrorResult& aRv);
|
||||
|
||||
DesktopNotificationCenter* GetMozNotification(ErrorResult& aRv);
|
||||
InputPortManager* GetInputPortManager(ErrorResult& aRv);
|
||||
already_AddRefed<LegacyMozTCPSocket> MozTCPSocket();
|
||||
network::Connection* GetConnection(ErrorResult& aRv);
|
||||
MediaDevices* GetMediaDevices(ErrorResult& aRv);
|
||||
@ -302,7 +300,6 @@ private:
|
||||
RefPtr<battery::BatteryManager> mBatteryManager;
|
||||
RefPtr<Promise> mBatteryPromise;
|
||||
RefPtr<PowerManager> mPowerManager;
|
||||
RefPtr<InputPortManager> mInputPortManager;
|
||||
RefPtr<network::Connection> mConnection;
|
||||
#ifdef MOZ_AUDIO_CHANNEL_MANAGER
|
||||
RefPtr<system::AudioChannelManager> mAudioChannelManager;
|
||||
|
@ -1,43 +0,0 @@
|
||||
/* -*- 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 "mozilla/dom/AVInputPort.h"
|
||||
#include "mozilla/dom/AVInputPortBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
AVInputPort::AVInputPort(nsPIDOMWindowInner* aWindow)
|
||||
: InputPort(aWindow)
|
||||
{
|
||||
}
|
||||
|
||||
AVInputPort::~AVInputPort()
|
||||
{
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<AVInputPort>
|
||||
AVInputPort::Create(nsPIDOMWindowInner* aWindow,
|
||||
nsIInputPortListener* aListener,
|
||||
nsIInputPortData* aData,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
RefPtr<AVInputPort> inputport = new AVInputPort(aWindow);
|
||||
inputport->Init(aData, aListener, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
return inputport.forget();
|
||||
}
|
||||
|
||||
JSObject*
|
||||
AVInputPort::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
return AVInputPortBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} //namespace mozilla
|
@ -1,34 +0,0 @@
|
||||
/* -*- 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/. */
|
||||
|
||||
#ifndef mozilla_dom_AVInputPort_h
|
||||
#define mozilla_dom_AVInputPort_h
|
||||
|
||||
#include "mozilla/dom/InputPort.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class AVInputPort final : public InputPort
|
||||
{
|
||||
public:
|
||||
static already_AddRefed<AVInputPort> Create(nsPIDOMWindowInner* aWindow,
|
||||
nsIInputPortListener* aListener,
|
||||
nsIInputPortData* aData,
|
||||
ErrorResult& aRv);
|
||||
|
||||
virtual JSObject* WrapObject(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
private:
|
||||
explicit AVInputPort(nsPIDOMWindowInner* aWindow);
|
||||
|
||||
~AVInputPort();
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_AVInputPort_h
|
@ -1,43 +0,0 @@
|
||||
/* -*- 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 "mozilla/dom/DisplayPortInputPort.h"
|
||||
#include "mozilla/dom/DisplayPortInputPortBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
DisplayPortInputPort::DisplayPortInputPort(nsPIDOMWindowInner* aWindow)
|
||||
: InputPort(aWindow)
|
||||
{
|
||||
}
|
||||
|
||||
DisplayPortInputPort::~DisplayPortInputPort()
|
||||
{
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<DisplayPortInputPort>
|
||||
DisplayPortInputPort::Create(nsPIDOMWindowInner* aWindow,
|
||||
nsIInputPortListener* aListener,
|
||||
nsIInputPortData* aData,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
RefPtr<DisplayPortInputPort> inputport = new DisplayPortInputPort(aWindow);
|
||||
inputport->Init(aData, aListener, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
return inputport.forget();
|
||||
}
|
||||
|
||||
JSObject*
|
||||
DisplayPortInputPort::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
return DisplayPortInputPortBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} //namespace mozilla
|
@ -1,35 +0,0 @@
|
||||
/* -*- 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/. */
|
||||
|
||||
#ifndef mozilla_dom_DisplayPortInputPort_h
|
||||
#define mozilla_dom_DisplayPortInputPort_h
|
||||
|
||||
#include "mozilla/dom/InputPort.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class DisplayPortInputPort final : public InputPort
|
||||
{
|
||||
public:
|
||||
static already_AddRefed<DisplayPortInputPort>
|
||||
Create(nsPIDOMWindowInner* aWindow,
|
||||
nsIInputPortListener* aListener,
|
||||
nsIInputPortData* aData,
|
||||
ErrorResult& aRv);
|
||||
|
||||
virtual JSObject* WrapObject(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
private:
|
||||
explicit DisplayPortInputPort(nsPIDOMWindowInner* aWindow);
|
||||
|
||||
~DisplayPortInputPort();
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_DisplayPortInputPort_h
|
@ -1,208 +0,0 @@
|
||||
/* -*- 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 "FakeInputPortService.h"
|
||||
#include "InputPortData.h"
|
||||
#include "mozilla/dom/InputPort.h"
|
||||
#include "nsIMutableArray.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
namespace {
|
||||
class InputPortServiceNotifyRunnable final : public Runnable
|
||||
{
|
||||
public:
|
||||
InputPortServiceNotifyRunnable(
|
||||
nsIInputPortServiceCallback* aCallback,
|
||||
nsIArray* aDataList,
|
||||
uint16_t aErrorCode = nsIInputPortServiceCallback::INPUTPORT_ERROR_OK)
|
||||
: mCallback(aCallback)
|
||||
, mDataList(aDataList)
|
||||
, mErrorCode(aErrorCode)
|
||||
{
|
||||
MOZ_ASSERT(aCallback);
|
||||
MOZ_ASSERT(aDataList);
|
||||
}
|
||||
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
if (mErrorCode == nsIInputPortServiceCallback::INPUTPORT_ERROR_OK) {
|
||||
return mCallback->NotifySuccess(mDataList);
|
||||
} else {
|
||||
return mCallback->NotifyError(mErrorCode);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIInputPortServiceCallback> mCallback;
|
||||
nsCOMPtr<nsIArray> mDataList;
|
||||
uint16_t mErrorCode;
|
||||
};
|
||||
|
||||
class PortConnectionChangedCallback final : public nsITimerCallback
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
PortConnectionChangedCallback(nsIInputPortData* aInputPortData,
|
||||
nsIInputPortListener* aInputPortListener,
|
||||
const bool aIsConnected)
|
||||
: mInputPortData(aInputPortData)
|
||||
, mInputPortListener(aInputPortListener)
|
||||
, mIsConnected(aIsConnected)
|
||||
{}
|
||||
|
||||
NS_IMETHOD
|
||||
Notify(nsITimer* aTimer) override
|
||||
{
|
||||
InputPortData* portData = static_cast<InputPortData*>(mInputPortData.get());
|
||||
portData->SetConnected(mIsConnected);
|
||||
nsresult rv = mInputPortListener->NotifyConnectionChanged(
|
||||
portData->GetId(), mIsConnected);
|
||||
return rv;
|
||||
}
|
||||
|
||||
private:
|
||||
~PortConnectionChangedCallback() {}
|
||||
|
||||
nsCOMPtr<nsIInputPortData> mInputPortData;
|
||||
nsCOMPtr<nsIInputPortListener> mInputPortListener;
|
||||
bool mIsConnected;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
NS_IMPL_ISUPPORTS(PortConnectionChangedCallback, nsITimerCallback)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(FakeInputPortService)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(FakeInputPortService)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mInputPortListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPortConnectionChangedTimer)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPortDatas)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(FakeInputPortService)
|
||||
tmp->Shutdown();
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mInputPortListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mPortConnectionChangedTimer)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mPortDatas)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(FakeInputPortService)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(FakeInputPortService)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(FakeInputPortService)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIInputPortService)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
FakeInputPortService::FakeInputPortService()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
FakeInputPortService::~FakeInputPortService()
|
||||
{
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
void
|
||||
FakeInputPortService::Init()
|
||||
{
|
||||
nsCOMPtr<nsIInputPortData> portData1 =
|
||||
MockInputPort(NS_LITERAL_STRING("1"), NS_LITERAL_STRING("av"), true);
|
||||
mPortDatas.AppendElement(portData1);
|
||||
|
||||
nsCOMPtr<nsIInputPortData> portData2 =
|
||||
MockInputPort(NS_LITERAL_STRING("2"), NS_LITERAL_STRING("displayport"), false);
|
||||
mPortDatas.AppendElement(portData2);
|
||||
|
||||
nsCOMPtr<nsIInputPortData> portData3 =
|
||||
MockInputPort(NS_LITERAL_STRING("3"), NS_LITERAL_STRING("hdmi"), true);
|
||||
mPortDatas.AppendElement(portData3);
|
||||
}
|
||||
|
||||
void
|
||||
FakeInputPortService::Shutdown()
|
||||
{
|
||||
if (mPortConnectionChangedTimer) {
|
||||
mPortConnectionChangedTimer->Cancel();
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
FakeInputPortService::GetInputPortListener(nsIInputPortListener** aInputPortListener)
|
||||
{
|
||||
if (!mInputPortListener) {
|
||||
*aInputPortListener = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*aInputPortListener = mInputPortListener;
|
||||
NS_ADDREF(*aInputPortListener);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
FakeInputPortService::SetInputPortListener(nsIInputPortListener* aInputPortListener)
|
||||
{
|
||||
mInputPortListener = aInputPortListener;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
FakeInputPortService::GetInputPorts(nsIInputPortServiceCallback* aCallback)
|
||||
{
|
||||
if (!aCallback) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIMutableArray> portDataList = do_CreateInstance(NS_ARRAY_CONTRACTID);
|
||||
if (!portDataList) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < mPortDatas.Length(); i++) {
|
||||
portDataList->AppendElement(mPortDatas[i], false);
|
||||
}
|
||||
|
||||
mPortConnectionChangedTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
|
||||
NS_ENSURE_TRUE(mPortConnectionChangedTimer, NS_ERROR_OUT_OF_MEMORY);
|
||||
bool isConnected = false;
|
||||
mPortDatas[0]->GetConnected(&isConnected);
|
||||
//simulate the connection change event.
|
||||
RefPtr<PortConnectionChangedCallback> connectionChangedCb =
|
||||
new PortConnectionChangedCallback(mPortDatas[0], mInputPortListener, !isConnected);
|
||||
nsresult rv = mPortConnectionChangedTimer->InitWithCallback(
|
||||
connectionChangedCb, 100, nsITimer::TYPE_ONE_SHOT);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRunnable> runnable =
|
||||
new InputPortServiceNotifyRunnable(aCallback, portDataList);
|
||||
return NS_DispatchToCurrentThread(runnable);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIInputPortData>
|
||||
FakeInputPortService::MockInputPort(const nsAString& aId,
|
||||
const nsAString& aType,
|
||||
bool aIsConnected)
|
||||
{
|
||||
nsCOMPtr<nsIInputPortData> portData = new InputPortData();
|
||||
portData->SetId(aId);
|
||||
portData->SetType(aType);
|
||||
portData->SetConnected(aIsConnected);
|
||||
return portData.forget();
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
@ -1,55 +0,0 @@
|
||||
/* -*- 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/. */
|
||||
|
||||
#ifndef mozilla_dom_FakeInputPortService_h
|
||||
#define mozilla_dom_FakeInputPortService_h
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsIInputPortService.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#define FAKE_INPUTPORT_SERVICE_CONTRACTID \
|
||||
"@mozilla.org/inputport/fakeinputportservice;1"
|
||||
#define FAKE_INPUTPORT_SERVICE_CID \
|
||||
{ 0xea6b01c5, 0xad04, 0x4f2a, \
|
||||
{ 0x8a, 0xbe, 0x64, 0xdb, 0xa2, 0x22, 0xe3, 0x3d } }
|
||||
|
||||
class nsITimer;
|
||||
class nsIInputPortData;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class FakeInputPortService final : public nsIInputPortService
|
||||
{
|
||||
public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS(FakeInputPortService)
|
||||
NS_DECL_NSIINPUTPORTSERVICE
|
||||
|
||||
FakeInputPortService();
|
||||
|
||||
private:
|
||||
~FakeInputPortService();
|
||||
|
||||
void Init();
|
||||
|
||||
void Shutdown();
|
||||
|
||||
already_AddRefed<nsIInputPortData> MockInputPort(const nsAString& aId,
|
||||
const nsAString& aType,
|
||||
bool aIsConnected);
|
||||
|
||||
nsCOMPtr<nsIInputPortListener> mInputPortListener;
|
||||
nsCOMPtr<nsITimer> mPortConnectionChangedTimer;
|
||||
nsTArray<nsCOMPtr<nsIInputPortData>> mPortDatas;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_FakeInputPortService_h
|
@ -1,44 +0,0 @@
|
||||
/* -*- 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 "mozilla/dom/HDMIInputPort.h"
|
||||
#include "mozilla/dom/HDMIInputPortBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
HDMIInputPort::HDMIInputPort(nsPIDOMWindowInner* aWindow)
|
||||
: InputPort(aWindow)
|
||||
{
|
||||
}
|
||||
|
||||
HDMIInputPort::~HDMIInputPort()
|
||||
{
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<HDMIInputPort>
|
||||
HDMIInputPort::Create(nsPIDOMWindowInner* aWindow,
|
||||
nsIInputPortListener* aListener,
|
||||
nsIInputPortData* aData,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
RefPtr<HDMIInputPort> inputport = new HDMIInputPort(aWindow);
|
||||
inputport->Init(aData, aListener, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
return inputport.forget();
|
||||
}
|
||||
|
||||
|
||||
JSObject*
|
||||
HDMIInputPort::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
return HDMIInputPortBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} //namespace mozilla
|
@ -1,35 +0,0 @@
|
||||
/* -*- 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/. */
|
||||
|
||||
#ifndef mozilla_dom_HDMIInputPort_h
|
||||
#define mozilla_dom_HDMIInputPort_h
|
||||
|
||||
#include "mozilla/dom/InputPort.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class HDMIInputPort final : public InputPort
|
||||
{
|
||||
public:
|
||||
static already_AddRefed<HDMIInputPort>
|
||||
Create(nsPIDOMWindowInner* aWindow,
|
||||
nsIInputPortListener* aListener,
|
||||
nsIInputPortData* aData,
|
||||
ErrorResult& aRv);
|
||||
|
||||
virtual JSObject* WrapObject(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
private:
|
||||
explicit HDMIInputPort(nsPIDOMWindowInner* aWindow);
|
||||
|
||||
~HDMIInputPort();
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_HDMIInputPort_h
|
@ -1,119 +0,0 @@
|
||||
/* -*- 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 "MediaStreamGraph.h"
|
||||
#include "DOMMediaStream.h"
|
||||
#include "InputPortData.h"
|
||||
#include "InputPortListeners.h"
|
||||
#include "mozilla/AsyncEventDispatcher.h"
|
||||
#include "mozilla/dom/InputPort.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(InputPort, DOMEventTargetHelper,
|
||||
mStream,
|
||||
mInputPortListener)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(InputPort, DOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(InputPort, DOMEventTargetHelper)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(InputPort)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
||||
|
||||
InputPort::InputPort(nsPIDOMWindowInner* aWindow)
|
||||
: DOMEventTargetHelper(aWindow)
|
||||
, mIsConnected(false)
|
||||
{
|
||||
}
|
||||
|
||||
InputPort::~InputPort()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
InputPort::Init(nsIInputPortData* aData, nsIInputPortListener* aListener, ErrorResult& aRv)
|
||||
{
|
||||
MOZ_ASSERT(aData);
|
||||
MOZ_ASSERT(aListener);
|
||||
|
||||
aRv = aData->GetId(mId);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(mId.IsEmpty())) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
InputPortType type = static_cast<InputPortData*>(aData)->GetType();
|
||||
if (NS_WARN_IF(type == InputPortType::EndGuard_)) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
aData->GetConnected(&mIsConnected);
|
||||
|
||||
mInputPortListener = static_cast<InputPortListener*>(aListener);
|
||||
mInputPortListener->RegisterInputPort(this);
|
||||
|
||||
MediaStreamGraph* graph =
|
||||
MediaStreamGraph::GetInstance(MediaStreamGraph::SYSTEM_THREAD_DRIVER,
|
||||
AudioChannel::Normal);
|
||||
mStream = DOMMediaStream::CreateSourceStreamAsInput(GetOwner(), graph);
|
||||
}
|
||||
|
||||
void
|
||||
InputPort::Shutdown()
|
||||
{
|
||||
MOZ_ASSERT(mInputPortListener);
|
||||
if (mInputPortListener) {
|
||||
mInputPortListener->UnregisterInputPort(this);
|
||||
mInputPortListener = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/* virtual */ JSObject*
|
||||
InputPort::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
return InputPortBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
void
|
||||
InputPort::NotifyConnectionChanged(bool aIsConnected)
|
||||
{
|
||||
MOZ_ASSERT(mIsConnected != aIsConnected);
|
||||
mIsConnected = aIsConnected;
|
||||
|
||||
RefPtr<AsyncEventDispatcher> asyncDispatcher =
|
||||
new AsyncEventDispatcher(this,
|
||||
aIsConnected ? NS_LITERAL_STRING("connect") :
|
||||
NS_LITERAL_STRING("disconnect"),
|
||||
false);
|
||||
asyncDispatcher->PostDOMEvent();
|
||||
}
|
||||
|
||||
void
|
||||
InputPort::GetId(nsAString& aId) const
|
||||
{
|
||||
aId = mId;
|
||||
}
|
||||
|
||||
DOMMediaStream*
|
||||
InputPort::Stream() const
|
||||
{
|
||||
return mStream;
|
||||
}
|
||||
|
||||
bool
|
||||
InputPort::Connected() const
|
||||
{
|
||||
return mIsConnected;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
@ -1,59 +0,0 @@
|
||||
/* -*- 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/. */
|
||||
|
||||
#ifndef mozilla_dom_InputPort_h
|
||||
#define mozilla_dom_InputPort_h
|
||||
|
||||
#include "InputPortListeners.h"
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "mozilla/dom/InputPortBinding.h"
|
||||
#include "nsIInputPortService.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class DOMMediaStream;
|
||||
|
||||
namespace dom {
|
||||
|
||||
class InputPort : public DOMEventTargetHelper
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(InputPort, DOMEventTargetHelper)
|
||||
|
||||
// WebIDL (internal functions)
|
||||
virtual JSObject* WrapObject(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
void NotifyConnectionChanged(bool aIsConnected);
|
||||
|
||||
// WebIDL (public APIs)
|
||||
void GetId(nsAString& aId) const;
|
||||
|
||||
DOMMediaStream* Stream() const;
|
||||
|
||||
bool Connected() const;
|
||||
|
||||
IMPL_EVENT_HANDLER(connect);
|
||||
IMPL_EVENT_HANDLER(disconnect);
|
||||
|
||||
protected:
|
||||
explicit InputPort(nsPIDOMWindowInner* aWindow);
|
||||
|
||||
virtual ~InputPort();
|
||||
|
||||
void Init(nsIInputPortData* aData, nsIInputPortListener* aListener, ErrorResult& aRv);
|
||||
void Shutdown();
|
||||
|
||||
nsString mId;
|
||||
RefPtr<DOMMediaStream> mStream;
|
||||
RefPtr<InputPortListener> mInputPortListener;
|
||||
bool mIsConnected;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_InputPort_h
|
@ -1,113 +0,0 @@
|
||||
/* -*- 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 "InputPortData.h"
|
||||
#include "nsString.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
namespace {
|
||||
|
||||
InputPortType
|
||||
ToInputPortType(const nsAString& aStr)
|
||||
{
|
||||
if (aStr.EqualsLiteral("av")) {
|
||||
return InputPortType::Av;
|
||||
}
|
||||
|
||||
if (aStr.EqualsLiteral("displayport")) {
|
||||
return InputPortType::Displayport;
|
||||
}
|
||||
|
||||
if (aStr.EqualsLiteral("hdmi")) {
|
||||
return InputPortType::Hdmi;
|
||||
}
|
||||
|
||||
return InputPortType::EndGuard_;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NS_IMPL_ISUPPORTS(InputPortData, nsIInputPortData)
|
||||
|
||||
InputPortData::InputPortData()
|
||||
: mIsConnected(false)
|
||||
{
|
||||
}
|
||||
|
||||
InputPortData::~InputPortData()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InputPortData::GetId(nsAString& aId)
|
||||
{
|
||||
aId = mId;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InputPortData::SetId(const nsAString& aId)
|
||||
{
|
||||
if (aId.IsEmpty()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
mId = aId;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InputPortData::GetType(nsAString& aType)
|
||||
{
|
||||
aType = mType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InputPortData::SetType(const nsAString& aType)
|
||||
{
|
||||
if (aType.IsEmpty()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (InputPortType::EndGuard_ == ToInputPortType(aType)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
mType = aType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InputPortData::GetConnected(bool* aIsConnected)
|
||||
{
|
||||
*aIsConnected = mIsConnected;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InputPortData::SetConnected(const bool aIsConnected)
|
||||
{
|
||||
mIsConnected = aIsConnected;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
const nsString&
|
||||
InputPortData::GetId() const
|
||||
{
|
||||
return mId;
|
||||
}
|
||||
|
||||
InputPortType
|
||||
InputPortData::GetType() const
|
||||
{
|
||||
return ToInputPortType(mType);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
@ -1,49 +0,0 @@
|
||||
/* -*- 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/. */
|
||||
|
||||
#ifndef mozilla_dom_InputPortData_h
|
||||
#define mozilla_dom_InputPortData_h
|
||||
|
||||
#include "mozilla/dom/InputPortBinding.h"
|
||||
#include "nsIInputPortService.h"
|
||||
|
||||
class nsString;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
enum class InputPortType : uint32_t
|
||||
{
|
||||
Av,
|
||||
Displayport,
|
||||
Hdmi,
|
||||
EndGuard_
|
||||
};
|
||||
|
||||
class InputPortData final : public nsIInputPortData
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIINPUTPORTDATA
|
||||
|
||||
InputPortData();
|
||||
|
||||
const nsString& GetId() const;
|
||||
|
||||
InputPortType GetType() const;
|
||||
|
||||
private:
|
||||
~InputPortData();
|
||||
|
||||
nsString mId;
|
||||
nsString mType;
|
||||
bool mIsConnected;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_InputPortData_h
|
@ -1,54 +0,0 @@
|
||||
/* -*- 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 "InputPortListeners.h"
|
||||
#include "mozilla/dom/InputPort.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION(InputPortListener, mInputPorts)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(InputPortListener)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(InputPortListener)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(InputPortListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIInputPortListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
void
|
||||
InputPortListener::RegisterInputPort(InputPort* aPort)
|
||||
{
|
||||
MOZ_ASSERT(!mInputPorts.Contains(aPort));
|
||||
mInputPorts.AppendElement(aPort);
|
||||
}
|
||||
|
||||
void
|
||||
InputPortListener::UnregisterInputPort(InputPort* aPort)
|
||||
{
|
||||
MOZ_ASSERT(mInputPorts.Contains(aPort));
|
||||
mInputPorts.RemoveElement(aPort);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InputPortListener::NotifyConnectionChanged(const nsAString& aPortId,
|
||||
bool aIsConnected)
|
||||
{
|
||||
for (uint32_t i = 0; i < mInputPorts.Length(); ++i) {
|
||||
nsString id;
|
||||
mInputPorts[i]->GetId(id);
|
||||
if (aPortId.Equals(id)) {
|
||||
mInputPorts[i]->NotifyConnectionChanged(aIsConnected);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
@ -1,39 +0,0 @@
|
||||
/* -*- 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/. */
|
||||
|
||||
#ifndef mozilla_dom_InputPortListeners_h
|
||||
#define mozilla_dom_InputPortListeners_h
|
||||
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsIInputPortService.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class InputPort;
|
||||
|
||||
class InputPortListener final : public nsIInputPortListener
|
||||
{
|
||||
public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS(InputPortListener)
|
||||
NS_DECL_NSIINPUTPORTLISTENER
|
||||
|
||||
void RegisterInputPort(InputPort* aPort);
|
||||
|
||||
void UnregisterInputPort(InputPort* aPort);
|
||||
|
||||
private:
|
||||
~InputPortListener() {}
|
||||
|
||||
nsTArray<RefPtr<InputPort>> mInputPorts;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_InputPortListeners_h
|
@ -1,215 +0,0 @@
|
||||
/* -*- 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 "InputPortServiceFactory.h"
|
||||
#include "mozilla/dom/InputPort.h"
|
||||
#include "mozilla/dom/InputPortManager.h"
|
||||
#include "mozilla/dom/InputPortManagerBinding.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "nsArrayUtils.h"
|
||||
#include "nsIInputPortService.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(InputPortManager,
|
||||
mParent,
|
||||
mInputPortService,
|
||||
mPendingGetInputPortsPromises,
|
||||
mInputPorts)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(InputPortManager)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(InputPortManager)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(InputPortManager)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIInputPortServiceCallback)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
InputPortManager::InputPortManager(nsPIDOMWindowInner* aWindow)
|
||||
: mParent(aWindow)
|
||||
, mIsReady(false)
|
||||
{
|
||||
}
|
||||
|
||||
InputPortManager::~InputPortManager()
|
||||
{
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<InputPortManager>
|
||||
InputPortManager::Create(nsPIDOMWindowInner* aWindow, ErrorResult& aRv)
|
||||
{
|
||||
RefPtr<InputPortManager> manager = new InputPortManager(aWindow);
|
||||
manager->Init(aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
return manager.forget();
|
||||
}
|
||||
|
||||
void
|
||||
InputPortManager::Init(ErrorResult& aRv)
|
||||
{
|
||||
mInputPortService = InputPortServiceFactory::AutoCreateInputPortService();
|
||||
if (NS_WARN_IF(!mInputPortService)) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
aRv = mInputPortService->GetInputPorts(this);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
nsPIDOMWindowInner*
|
||||
InputPortManager::GetParentObject() const
|
||||
{
|
||||
return mParent;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
InputPortManager::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
return InputPortManagerBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
void
|
||||
InputPortManager::RejectPendingGetInputPortsPromises(nsresult aRv)
|
||||
{
|
||||
// Reject pending promises.
|
||||
uint32_t length = mPendingGetInputPortsPromises.Length();
|
||||
for(uint32_t i = 0; i < length; i++) {
|
||||
mPendingGetInputPortsPromises[i]->MaybeReject(aRv);
|
||||
}
|
||||
mPendingGetInputPortsPromises.Clear();
|
||||
}
|
||||
|
||||
nsresult
|
||||
InputPortManager::SetInputPorts(const nsTArray<RefPtr<InputPort>>& aPorts)
|
||||
{
|
||||
MOZ_ASSERT(!mIsReady);
|
||||
// Should be called only when InputPortManager hasn't been ready yet.
|
||||
if (mIsReady) {
|
||||
return NS_ERROR_DOM_INVALID_STATE_ERR;
|
||||
}
|
||||
|
||||
mInputPorts = aPorts;
|
||||
mIsReady = true;
|
||||
|
||||
// Resolve pending promises.
|
||||
uint32_t length = mPendingGetInputPortsPromises.Length();
|
||||
for(uint32_t i = 0; i < length; i++) {
|
||||
mPendingGetInputPortsPromises[i]->MaybeResolve(mInputPorts);
|
||||
}
|
||||
mPendingGetInputPortsPromises.Clear();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<Promise>
|
||||
InputPortManager::GetInputPorts(ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetParentObject());
|
||||
MOZ_ASSERT(global);
|
||||
|
||||
RefPtr<Promise> promise = Promise::Create(global, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (mIsReady) {
|
||||
promise->MaybeResolve(mInputPorts);
|
||||
} else {
|
||||
mPendingGetInputPortsPromises.AppendElement(promise);
|
||||
}
|
||||
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InputPortManager::NotifySuccess(nsIArray* aDataList)
|
||||
{
|
||||
MOZ_ASSERT(aDataList);
|
||||
|
||||
if (!aDataList) {
|
||||
RejectPendingGetInputPortsPromises(NS_ERROR_DOM_ABORT_ERR);
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
uint32_t length;
|
||||
nsresult rv = aDataList->GetLength(&length);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIInputPortListener> portListener;
|
||||
rv = mInputPortService->GetInputPortListener(
|
||||
getter_AddRefs(portListener));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
ErrorResult erv;
|
||||
nsTArray<RefPtr<InputPort>> ports(length);
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
nsCOMPtr<nsIInputPortData> portData = do_QueryElementAt(aDataList, i);
|
||||
if (NS_WARN_IF(!portData)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
InputPortData* data = static_cast<InputPortData*>(portData.get());
|
||||
RefPtr<InputPort> port;
|
||||
switch (data->GetType()) {
|
||||
case InputPortType::Av:
|
||||
port = AVInputPort::Create(GetParentObject(), portListener,
|
||||
portData, erv);
|
||||
break;
|
||||
case InputPortType::Displayport:
|
||||
port = DisplayPortInputPort::Create(GetParentObject(),
|
||||
portListener, portData, erv);
|
||||
break;
|
||||
case InputPortType::Hdmi:
|
||||
port = HDMIInputPort::Create(GetParentObject(), portListener,
|
||||
portData, erv);
|
||||
break;
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("Unknown InputPort type");
|
||||
break;
|
||||
}
|
||||
MOZ_ASSERT(port);
|
||||
|
||||
ports.AppendElement(port);
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(erv.Failed())) {
|
||||
return erv.StealNSResult();
|
||||
}
|
||||
|
||||
erv = SetInputPorts(ports);
|
||||
|
||||
return erv.StealNSResult();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InputPortManager::NotifyError(uint16_t aErrorCode)
|
||||
{
|
||||
switch (aErrorCode) {
|
||||
case nsIInputPortServiceCallback::INPUTPORT_ERROR_FAILURE:
|
||||
case nsIInputPortServiceCallback::INPUTPORT_ERROR_INVALID_ARG:
|
||||
RejectPendingGetInputPortsPromises(NS_ERROR_DOM_ABORT_ERR);
|
||||
return NS_OK;
|
||||
case nsIInputPortServiceCallback::INPUTPORT_ERROR_NOT_SUPPORTED:
|
||||
RejectPendingGetInputPortsPromises(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
RejectPendingGetInputPortsPromises(NS_ERROR_DOM_ABORT_ERR);
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
@ -1,63 +0,0 @@
|
||||
/* -*- 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/. */
|
||||
|
||||
#ifndef mozilla_dom_InputPortManager_h
|
||||
#define mozilla_dom_InputPortManager_h
|
||||
|
||||
#include "nsIInputPortService.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
class nsIInputPortService;
|
||||
class nsPIDOMWindowInner;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class Promise;
|
||||
class InputPort;
|
||||
|
||||
class InputPortManager final : public nsIInputPortServiceCallback,
|
||||
public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(InputPortManager)
|
||||
NS_DECL_NSIINPUTPORTSERVICECALLBACK
|
||||
|
||||
static already_AddRefed<InputPortManager>
|
||||
Create(nsPIDOMWindowInner* aWindow, ErrorResult& aRv);
|
||||
|
||||
// WebIDL (internal functions)
|
||||
nsPIDOMWindowInner* GetParentObject() const;
|
||||
|
||||
virtual JSObject* WrapObject(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
// WebIDL (public APIs)
|
||||
already_AddRefed<Promise> GetInputPorts(ErrorResult& aRv);
|
||||
|
||||
private:
|
||||
explicit InputPortManager(nsPIDOMWindowInner* aWindow);
|
||||
|
||||
~InputPortManager();
|
||||
|
||||
void Init(ErrorResult& aRv);
|
||||
|
||||
void RejectPendingGetInputPortsPromises(nsresult aRv);
|
||||
|
||||
nsresult SetInputPorts(const nsTArray<RefPtr<InputPort>>& aPorts);
|
||||
|
||||
nsTArray<RefPtr<Promise>> mPendingGetInputPortsPromises;
|
||||
nsTArray<RefPtr<InputPort>> mInputPorts;
|
||||
nsCOMPtr<nsPIDOMWindowInner> mParent;
|
||||
nsCOMPtr<nsIInputPortService> mInputPortService;
|
||||
bool mIsReady;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_InputPortManager_h__
|
@ -1,47 +0,0 @@
|
||||
/* -*- 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 "FakeInputPortService.h"
|
||||
#include "InputPortListeners.h"
|
||||
#include "InputPortServiceFactory.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsIInputPortService.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
/* static */ already_AddRefed<FakeInputPortService>
|
||||
InputPortServiceFactory::CreateFakeInputPortService()
|
||||
{
|
||||
RefPtr<FakeInputPortService> service = new FakeInputPortService();
|
||||
return service.forget();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<nsIInputPortService>
|
||||
InputPortServiceFactory::AutoCreateInputPortService()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIInputPortService> service =
|
||||
do_GetService(INPUTPORT_SERVICE_CONTRACTID);
|
||||
if (!service) {
|
||||
// Fallback to the fake service.
|
||||
service = do_GetService(FAKE_INPUTPORT_SERVICE_CONTRACTID, &rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
MOZ_ASSERT(service);
|
||||
rv = service->SetInputPortListener(new InputPortListener());
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return service.forget();
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
@ -1,30 +0,0 @@
|
||||
/* -*- 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/. */
|
||||
|
||||
#ifndef mozilla_dom_InputPortServiceFactory_h
|
||||
#define mozilla_dom_InputPortServiceFactory_h
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsIInputPortService;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class FakeInputPortService;
|
||||
|
||||
class InputPortServiceFactory final
|
||||
{
|
||||
public:
|
||||
static already_AddRefed<FakeInputPortService> CreateFakeInputPortService();
|
||||
|
||||
static already_AddRefed<nsIInputPortService> AutoCreateInputPortService();
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_InputPortServiceFactory_h
|
@ -1,46 +0,0 @@
|
||||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# 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/.
|
||||
|
||||
EXPORTS.mozilla.dom += [
|
||||
'AVInputPort.h',
|
||||
'DisplayPortInputPort.h',
|
||||
'HDMIInputPort.h',
|
||||
'InputPort.h',
|
||||
'InputPortManager.h',
|
||||
]
|
||||
|
||||
EXPORTS += [
|
||||
'FakeInputPortService.h',
|
||||
'InputPortData.h',
|
||||
'InputPortListeners.h',
|
||||
'InputPortServiceFactory.h',
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'AVInputPort.cpp',
|
||||
'DisplayPortInputPort.cpp',
|
||||
'FakeInputPortService.cpp',
|
||||
'HDMIInputPort.cpp',
|
||||
'InputPort.cpp',
|
||||
'InputPortData.cpp',
|
||||
'InputPortListeners.cpp',
|
||||
'InputPortManager.cpp',
|
||||
'InputPortServiceFactory.cpp',
|
||||
]
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'nsIInputPortService.idl',
|
||||
]
|
||||
|
||||
XPIDL_MODULE = 'dom_inputport'
|
||||
|
||||
MOCHITEST_MANIFESTS += ['test/mochitest/mochitest.ini']
|
||||
|
||||
XPCSHELL_TESTS_MANIFESTS += ['test/xpcshell/xpcshell.ini']
|
||||
|
||||
include('/ipc/chromium/chromium-config.mozbuild')
|
||||
|
||||
FINAL_LIBRARY = 'xul'
|
@ -1,75 +0,0 @@
|
||||
/* 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 "nsISupports.idl"
|
||||
|
||||
interface nsIArray;
|
||||
|
||||
%{C++
|
||||
#define INPUTPORT_DATA_CID \
|
||||
{ 0x90b192d1, 0x357a, 0x4793, { 0xab, 0x58, 0x04, 0xee, 0x21, 0x62, 0x27, 0xda } }
|
||||
#define INPUTPORT_DATA_CONTRACTID \
|
||||
"@mozilla.org/inputport/inputportdata;1"
|
||||
%}
|
||||
|
||||
/**
|
||||
* XPCOM component which acts as the container for input port data.
|
||||
*/
|
||||
[scriptable, builtinclass, uuid(244a2b1d-aa1f-4188-a639-ddb56c554b6d)]
|
||||
interface nsIInputPortData : nsISupports
|
||||
{
|
||||
attribute DOMString id;
|
||||
attribute DOMString type;
|
||||
attribute boolean connected;
|
||||
};
|
||||
|
||||
[builtinclass, uuid(32a62e7c-f698-4846-81f7-617c87854d32)]
|
||||
interface nsIInputPortListener : nsISupports
|
||||
{
|
||||
void notifyConnectionChanged(in DOMString portId,
|
||||
in boolean isConnected);
|
||||
};
|
||||
|
||||
[builtinclass, uuid(c2a47757-25f6-4bc8-bd27-c23af2d87381)]
|
||||
interface nsIInputPortServiceCallback : nsISupports
|
||||
{
|
||||
const unsigned short INPUTPORT_ERROR_OK = 0;
|
||||
const unsigned short INPUTPORT_ERROR_FAILURE = 1;
|
||||
const unsigned short INPUTPORT_ERROR_INVALID_ARG = 2;
|
||||
const unsigned short INPUTPORT_ERROR_NOT_SUPPORTED = 3;
|
||||
|
||||
/**
|
||||
* Called when something wrong happens.
|
||||
*
|
||||
* @param errorCode Error code listed above from the underlying layer.
|
||||
*/
|
||||
void notifyError(in unsigned short errorCode);
|
||||
|
||||
/**
|
||||
* Called when the operation succeeds.
|
||||
*
|
||||
* @param dataList A list of data.
|
||||
* An array of |nsIInputPortData| when used for |getInputPorts()|.
|
||||
*
|
||||
* NOTE: |nsIArray| is adopted to prevent this interface from being split into
|
||||
* multiple interfaces with different |notifySuccess|. Though the
|
||||
* implementation of TV service may need |nsIMutableArray| to fill in the
|
||||
* array, it doesn't seem necessary for other places to use the mutable one.
|
||||
*/
|
||||
void notifySuccess([optional] in nsIArray dataList);
|
||||
};
|
||||
|
||||
|
||||
%{C++
|
||||
#define INPUTPORT_SERVICE_CONTRACTID \
|
||||
"@mozilla.org/inputport/inputportservice;1"
|
||||
%}
|
||||
|
||||
[uuid(6214dae0-840e-11e4-b4a9-0800200c9a66)]
|
||||
interface nsIInputPortService : nsISupports
|
||||
{
|
||||
attribute nsIInputPortListener inputPortListener;
|
||||
|
||||
void getInputPorts(in nsIInputPortServiceCallback callback);
|
||||
};
|
@ -1,5 +0,0 @@
|
||||
[DEFAULT]
|
||||
skip-if = buildapp != 'b2g'
|
||||
|
||||
[test_inputport_get_inputports.html]
|
||||
[test_inputport_connection_event.html]
|
@ -1,72 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1026350
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test Inputport Connection Event</title>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1026350">Test Inputport Connection Event
|
||||
</a>
|
||||
<script type="application/javascript;version=1.8">
|
||||
|
||||
'use strict';
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function testInputportConnectionEvent() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var inputPortMgr = navigator.inputPortManager;
|
||||
inputPortMgr.getInputPorts().then(
|
||||
function(aPorts) {
|
||||
ok(aPorts.length > 0, "Got at least 1 inputport.");
|
||||
var port0 = aPorts[0];
|
||||
var port0_isConnected = port0.connected;
|
||||
port0.onconnect = function(aEvent) {
|
||||
var port = aEvent.target;
|
||||
is(port.id, port0.id, "The inputport ID should be the same");
|
||||
ok(port.connected, "The connected value matches the connect evnet purpose");
|
||||
is(port.connected, !port0_isConnected, "The connected value should change");
|
||||
resolve();
|
||||
}
|
||||
port0.ondisconnect = function (aEvent) {
|
||||
var port = aEvent.target;
|
||||
is(port.id, port0.id, "The inputport ID should be the same");
|
||||
ok(!port.connected, "The connected value matches the disconnect evnet purpose");
|
||||
is(port.connected, !port0_isConnected, "The connected value should change");
|
||||
resolve();
|
||||
}
|
||||
},
|
||||
function(aError) {
|
||||
ok(false, "Fail to get input ports: " + aError);
|
||||
resolve();
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function runTest() {
|
||||
ok(navigator.inputPortManager, 'should have navigator.inputPortManager');
|
||||
|
||||
testInputportConnectionEvent()
|
||||
.then(function() {
|
||||
info('test finished');
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}
|
||||
|
||||
SpecialPowers.pushPrefEnv({"set": [["dom.inputport.enabled", true],
|
||||
//to ignore app scope check.
|
||||
["dom.ignore_webidl_scope_checks", true]]}, function() {
|
||||
SpecialPowers.pushPermissions(
|
||||
[{'type': 'inputport', 'allow': true, 'context': document}], runTest);
|
||||
});
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -1,63 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1026350
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Inputport API Test</title>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1026350">Test Inputport API</a>
|
||||
<script type="application/javascript;version=1.8">
|
||||
|
||||
'use strict';
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function testGetInputports() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var inputPortMgr = navigator.inputPortManager;
|
||||
inputPortMgr.getInputPorts().then(
|
||||
function(aPorts) {
|
||||
ok(aPorts.length > 0, "Got at least 1 inputport.");
|
||||
for (var i=0; i < aPorts.length; ++i) {
|
||||
var port = aPorts[i];
|
||||
ok(port instanceof InputPort, "Inputport " + i + " should be in the right type.");
|
||||
ok('id' in port, "Inputport " + i + " should have an ID.");
|
||||
ok('connected' in port, "Inputport " + i + " should have a connected property.");
|
||||
ok(port.stream, "Inputport " + i + " should have non null stream.");
|
||||
resolve();
|
||||
}
|
||||
},
|
||||
function(aError) {
|
||||
ok(false, "Fail to get input ports: " + aError);
|
||||
resolve();
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function runTest() {
|
||||
ok(navigator.inputPortManager, 'should have navigator.inputPortManager');
|
||||
|
||||
testGetInputports()
|
||||
.then(function() {
|
||||
info('test finished');
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}
|
||||
|
||||
SpecialPowers.pushPrefEnv({"set": [["dom.inputport.enabled", true],
|
||||
//to ignore app scope check.
|
||||
["dom.ignore_webidl_scope_checks", true]]}, function() {
|
||||
SpecialPowers.pushPermissions(
|
||||
[{'type': 'inputport', 'allow': true, 'context': document}], runTest);
|
||||
});
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -1,61 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
||||
|
||||
function run_test() {
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
add_test(function test_valid_inputport_id() {
|
||||
var inputportId = "inputportId";
|
||||
|
||||
var data = Cc["@mozilla.org/inputport/inputportdata;1"].
|
||||
createInstance(Ci.nsIInputPortData);
|
||||
data.id = inputportId;
|
||||
|
||||
equal(data.id, inputportId);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
add_test(function test_empty_inputport_id() {
|
||||
var data = Cc["@mozilla.org/inputport/inputportdata;1"].
|
||||
createInstance(Ci.nsIInputPortData);
|
||||
Assert.throws(function() {
|
||||
data.id = "";
|
||||
}, /NS_ERROR_ILLEGAL_VALUE/i);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
add_test(function test_valid_type() {
|
||||
var inputportType = "hdmi";
|
||||
|
||||
var data = Cc["@mozilla.org/inputport/inputportdata;1"].
|
||||
createInstance(Ci.nsIInputPortData);
|
||||
data.type = inputportType;
|
||||
|
||||
equal(data.type, inputportType);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
add_test(function test_empty_type() {
|
||||
var data = Cc["@mozilla.org/inputport/inputportdata;1"].
|
||||
createInstance(Ci.nsIInputPortData);
|
||||
Assert.throws(function() {
|
||||
data.type = "";
|
||||
}, /NS_ERROR_ILLEGAL_VALUE/i);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
add_test(function test_is_connected() {
|
||||
var data = Cc["@mozilla.org/inputport/inputportdata;1"].
|
||||
createInstance(Ci.nsIInputPortData);
|
||||
data.connected = true;
|
||||
|
||||
ok(data.connected);
|
||||
|
||||
run_next_test();
|
||||
});
|
@ -1,6 +0,0 @@
|
||||
[DEFAULT]
|
||||
skip-if = buildapp != 'b2g'
|
||||
head =
|
||||
tail =
|
||||
|
||||
[test_inputport_data.js]
|
@ -58,7 +58,6 @@ DIRS += [
|
||||
'geolocation',
|
||||
'grid',
|
||||
'html',
|
||||
'inputport',
|
||||
'json',
|
||||
'jsurl',
|
||||
'asmjscache',
|
||||
|
@ -1,9 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/.
|
||||
*/
|
||||
|
||||
[Pref="dom.inputport.enabled", ChromeOnly]
|
||||
interface AVInputPort : InputPort {
|
||||
};
|
@ -1,9 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/.
|
||||
*/
|
||||
|
||||
[Pref="dom.inputport.enabled", ChromeOnly]
|
||||
interface DisplayPortInputPort : InputPort {
|
||||
};
|
@ -1,9 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/.
|
||||
*/
|
||||
|
||||
[Pref="dom.inputport.enabled", ChromeOnly]
|
||||
interface HDMIInputPort : InputPort {
|
||||
};
|
@ -1,16 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/.
|
||||
*
|
||||
* Reference https://wiki.mozilla.org/Input_Port_API#Basic_Port_Interface
|
||||
*/
|
||||
|
||||
[Pref="dom.inputport.enabled", ChromeOnly]
|
||||
interface InputPort : EventTarget {
|
||||
readonly attribute DOMString id;
|
||||
readonly attribute MediaStream stream;
|
||||
readonly attribute boolean connected;
|
||||
attribute EventHandler onconnect;
|
||||
attribute EventHandler ondisconnect;
|
||||
};
|
@ -1,13 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/.
|
||||
*
|
||||
* Reference https://wiki.mozilla.org/Input_Port_API#InputPortManager
|
||||
*/
|
||||
|
||||
[Pref="dom.inputport.enabled", ChromeOnly]
|
||||
interface InputPortManager {
|
||||
[Throws]
|
||||
Promise<sequence<InputPort>> getInputPorts();
|
||||
};
|
@ -353,11 +353,6 @@ partial interface Navigator {
|
||||
optional (ArrayBufferView or Blob or DOMString or FormData)? data = null);
|
||||
};
|
||||
|
||||
partial interface Navigator {
|
||||
[Throws, Pref="dom.inputport.enabled", ChromeOnly]
|
||||
readonly attribute InputPortManager inputPortManager;
|
||||
};
|
||||
|
||||
partial interface Navigator {
|
||||
[Throws, Pref="dom.presentation.enabled", SameObject]
|
||||
readonly attribute Presentation? presentation;
|
||||
|
@ -47,7 +47,6 @@ WEBIDL_FILES = [
|
||||
'AudioTrack.webidl',
|
||||
'AudioTrackList.webidl',
|
||||
'AutocompleteInfo.webidl',
|
||||
'AVInputPort.webidl',
|
||||
'BarProp.webidl',
|
||||
'BaseKeyframeTypes.webidl',
|
||||
'BatteryManager.webidl',
|
||||
@ -113,7 +112,6 @@ WEBIDL_FILES = [
|
||||
'DeviceStorage.webidl',
|
||||
'DeviceStorageAreaListener.webidl',
|
||||
'Directory.webidl',
|
||||
'DisplayPortInputPort.webidl',
|
||||
'Document.webidl',
|
||||
'DocumentFragment.webidl',
|
||||
'DocumentTimeline.webidl',
|
||||
@ -172,7 +170,6 @@ WEBIDL_FILES = [
|
||||
'GeometryUtils.webidl',
|
||||
'GetUserMediaRequest.webidl',
|
||||
'Grid.webidl',
|
||||
'HDMIInputPort.webidl',
|
||||
'Headers.webidl',
|
||||
'HeapSnapshot.webidl',
|
||||
'History.webidl',
|
||||
@ -275,8 +272,6 @@ WEBIDL_FILES = [
|
||||
'ImageDocument.webidl',
|
||||
'InputEvent.webidl',
|
||||
'InputMethod.webidl',
|
||||
'InputPort.webidl',
|
||||
'InputPortManager.webidl',
|
||||
'InspectorUtils.webidl',
|
||||
'IntersectionObserver.webidl',
|
||||
'IterableIterator.webidl',
|
||||
|
@ -201,11 +201,6 @@ static void Shutdown();
|
||||
|
||||
#include "nsIPresentationService.h"
|
||||
|
||||
#include "FakeInputPortService.h"
|
||||
#include "InputPortData.h"
|
||||
#include "InputPortServiceFactory.h"
|
||||
#include "nsIInputPortService.h"
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
#include "GonkGPSGeolocationProvider.h"
|
||||
#endif
|
||||
@ -340,9 +335,6 @@ NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIMediaManagerService,
|
||||
MediaManager::GetInstance)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(PresentationDeviceManager)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(TextInputProcessor)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(FakeInputPortService,
|
||||
InputPortServiceFactory::CreateFakeInputPortService)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(InputPortData)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIPresentationService,
|
||||
NS_CreatePresentationService)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(PresentationTCPSessionTransport)
|
||||
@ -788,9 +780,6 @@ NS_DEFINE_NAMED_CID(NS_SYNTHVOICEREGISTRY_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_ACCESSIBILITY_SERVICE_CID);
|
||||
#endif
|
||||
|
||||
NS_DEFINE_NAMED_CID(FAKE_INPUTPORT_SERVICE_CID);
|
||||
NS_DEFINE_NAMED_CID(INPUTPORT_DATA_CID);
|
||||
|
||||
NS_DEFINE_NAMED_CID(GECKO_MEDIA_PLUGIN_SERVICE_CID);
|
||||
|
||||
NS_DEFINE_NAMED_CID(PRESENTATION_SERVICE_CID);
|
||||
@ -1074,8 +1063,6 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
|
||||
{ &kPRESENTATION_DEVICE_MANAGER_CID, false, nullptr, PresentationDeviceManagerConstructor },
|
||||
{ &kPRESENTATION_TCP_SESSION_TRANSPORT_CID, false, nullptr, PresentationTCPSessionTransportConstructor },
|
||||
{ &kTEXT_INPUT_PROCESSOR_CID, false, nullptr, TextInputProcessorConstructor },
|
||||
{ &kFAKE_INPUTPORT_SERVICE_CID, false, nullptr, FakeInputPortServiceConstructor },
|
||||
{ &kINPUTPORT_DATA_CID, false, nullptr, InputPortDataConstructor },
|
||||
#ifdef MOZ_B2G
|
||||
{ &kNS_HARDWARE_KEY_HANDLER_CID, false, nullptr, nsIHardwareKeyHandlerConstructor },
|
||||
#endif
|
||||
@ -1223,8 +1210,6 @@ static const mozilla::Module::ContractIDEntry kLayoutContracts[] = {
|
||||
{ PRESENTATION_DEVICE_MANAGER_CONTRACTID, &kPRESENTATION_DEVICE_MANAGER_CID },
|
||||
{ PRESENTATION_TCP_SESSION_TRANSPORT_CONTRACTID, &kPRESENTATION_TCP_SESSION_TRANSPORT_CID },
|
||||
{ "@mozilla.org/text-input-processor;1", &kTEXT_INPUT_PROCESSOR_CID },
|
||||
{ FAKE_INPUTPORT_SERVICE_CONTRACTID, &kFAKE_INPUTPORT_SERVICE_CID },
|
||||
{ INPUTPORT_DATA_CONTRACTID, &kINPUTPORT_DATA_CID },
|
||||
#ifdef MOZ_B2G
|
||||
{ NS_HARDWARE_KEY_HANDLER_CONTRACTID, &kNS_HARDWARE_KEY_HANDLER_CID },
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user