mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1212702 - [Presentation WebAPI] Rename to PresentationConnection. Part 1 - WebIDL bindings. r=smaug
--HG-- rename : dom/presentation/PresentationSession.cpp => dom/presentation/PresentationConnection.cpp rename : dom/presentation/PresentationSession.h => dom/presentation/PresentationConnection.h rename : dom/webidl/PresentationSession.webidl => dom/webidl/PresentationConnection.webidl rename : dom/webidl/PresentationSessionConnectEvent.webidl => dom/webidl/PresentationConnectionAvailableEvent.webidl
This commit is contained in:
parent
23b7d3da85
commit
734f22b0e0
@ -723,6 +723,7 @@ GK_ATOM(onconfigurationchange, "onconfigurationchange")
|
||||
GK_ATOM(onconnect, "onconnect")
|
||||
GK_ATOM(onconnected, "onconnected")
|
||||
GK_ATOM(onconnecting, "onconnecting")
|
||||
GK_ATOM(onconnectionavailable, "onconnectionavailable")
|
||||
GK_ATOM(onconnectionstatechanged, "onconnectionstatechanged")
|
||||
GK_ATOM(oncontextmenu, "oncontextmenu")
|
||||
GK_ATOM(oncopy, "oncopy")
|
||||
@ -898,8 +899,6 @@ GK_ATOM(onselectionchange, "onselectionchange")
|
||||
GK_ATOM(onselectstart, "onselectstart")
|
||||
GK_ATOM(onsending, "onsending")
|
||||
GK_ATOM(onsent, "onsent")
|
||||
GK_ATOM(onsessionavailable, "onsessionavailable")
|
||||
GK_ATOM(onsessionconnect, "onsessionconnect")
|
||||
GK_ATOM(onset, "onset")
|
||||
GK_ATOM(onshow, "onshow")
|
||||
GK_ATOM(onshutter, "onshutter")
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "PresentationCallbacks.h"
|
||||
#include "PresentationRequest.h"
|
||||
#include "PresentationSession.h"
|
||||
#include "PresentationConnection.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@ -47,18 +47,18 @@ PresentationRequesterCallback::NotifySuccess()
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
// At the sender side, this function must get called after the transport
|
||||
// channel is ready. So we simply set the session state as connected.
|
||||
nsRefPtr<PresentationSession> session =
|
||||
PresentationSession::Create(mRequest->GetOwner(), mSessionId,
|
||||
PresentationSessionState::Connected);
|
||||
if (NS_WARN_IF(!session)) {
|
||||
// channel is ready. So we simply set the connection state as connected.
|
||||
nsRefPtr<PresentationConnection> connection =
|
||||
PresentationConnection::Create(mRequest->GetOwner(), mSessionId,
|
||||
PresentationConnectionState::Connected);
|
||||
if (NS_WARN_IF(!connection)) {
|
||||
mPromise->MaybeReject(NS_ERROR_DOM_OPERATION_ERR);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mPromise->MaybeResolve(session);
|
||||
mPromise->MaybeResolve(connection);
|
||||
|
||||
return mRequest->DispatchSessionConnectEvent(session);
|
||||
return mRequest->DispatchConnectionAvailableEvent(connection);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -10,52 +10,52 @@
|
||||
#include "nsIPresentationService.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsStringStream.h"
|
||||
#include "PresentationSession.h"
|
||||
#include "PresentationConnection.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(PresentationSession)
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(PresentationConnection)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(PresentationSession, DOMEventTargetHelper)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(PresentationConnection, DOMEventTargetHelper)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(PresentationSession, DOMEventTargetHelper)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(PresentationConnection, DOMEventTargetHelper)
|
||||
tmp->Shutdown();
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(PresentationSession, DOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(PresentationSession, DOMEventTargetHelper)
|
||||
NS_IMPL_ADDREF_INHERITED(PresentationConnection, DOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(PresentationConnection, DOMEventTargetHelper)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(PresentationSession)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(PresentationConnection)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIPresentationSessionListener)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
||||
|
||||
PresentationSession::PresentationSession(nsPIDOMWindow* aWindow,
|
||||
const nsAString& aId,
|
||||
PresentationSessionState aState)
|
||||
PresentationConnection::PresentationConnection(nsPIDOMWindow* aWindow,
|
||||
const nsAString& aId,
|
||||
PresentationConnectionState aState)
|
||||
: DOMEventTargetHelper(aWindow)
|
||||
, mId(aId)
|
||||
, mState(aState)
|
||||
{
|
||||
}
|
||||
|
||||
/* virtual */ PresentationSession::~PresentationSession()
|
||||
/* virtual */ PresentationConnection::~PresentationConnection()
|
||||
{
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<PresentationSession>
|
||||
PresentationSession::Create(nsPIDOMWindow* aWindow,
|
||||
const nsAString& aId,
|
||||
PresentationSessionState aState)
|
||||
/* static */ already_AddRefed<PresentationConnection>
|
||||
PresentationConnection::Create(nsPIDOMWindow* aWindow,
|
||||
const nsAString& aId,
|
||||
PresentationConnectionState aState)
|
||||
{
|
||||
nsRefPtr<PresentationSession> session =
|
||||
new PresentationSession(aWindow, aId, aState);
|
||||
return NS_WARN_IF(!session->Init()) ? nullptr : session.forget();
|
||||
nsRefPtr<PresentationConnection> connection =
|
||||
new PresentationConnection(aWindow, aId, aState);
|
||||
return NS_WARN_IF(!connection->Init()) ? nullptr : connection.forget();
|
||||
}
|
||||
|
||||
bool
|
||||
PresentationSession::Init()
|
||||
PresentationConnection::Init()
|
||||
{
|
||||
if (NS_WARN_IF(mId.IsEmpty())) {
|
||||
return false;
|
||||
@ -76,7 +76,7 @@ PresentationSession::Init()
|
||||
}
|
||||
|
||||
void
|
||||
PresentationSession::Shutdown()
|
||||
PresentationConnection::Shutdown()
|
||||
{
|
||||
nsCOMPtr<nsIPresentationService> service =
|
||||
do_GetService(PRESENTATION_SERVICE_CONTRACTID);
|
||||
@ -89,37 +89,37 @@ PresentationSession::Shutdown()
|
||||
}
|
||||
|
||||
/* virtual */ void
|
||||
PresentationSession::DisconnectFromOwner()
|
||||
PresentationConnection::DisconnectFromOwner()
|
||||
{
|
||||
Shutdown();
|
||||
DOMEventTargetHelper::DisconnectFromOwner();
|
||||
}
|
||||
|
||||
/* virtual */ JSObject*
|
||||
PresentationSession::WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto)
|
||||
PresentationConnection::WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
return PresentationSessionBinding::Wrap(aCx, this, aGivenProto);
|
||||
return PresentationConnectionBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
void
|
||||
PresentationSession::GetId(nsAString& aId) const
|
||||
PresentationConnection::GetId(nsAString& aId) const
|
||||
{
|
||||
aId = mId;
|
||||
}
|
||||
|
||||
PresentationSessionState
|
||||
PresentationSession::State() const
|
||||
PresentationConnectionState
|
||||
PresentationConnection::State() const
|
||||
{
|
||||
return mState;
|
||||
}
|
||||
|
||||
void
|
||||
PresentationSession::Send(const nsAString& aData,
|
||||
PresentationConnection::Send(const nsAString& aData,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
// Sending is not allowed if the session is not connected.
|
||||
if (NS_WARN_IF(mState != PresentationSessionState::Connected)) {
|
||||
if (NS_WARN_IF(mState != PresentationConnectionState::Connected)) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return;
|
||||
}
|
||||
@ -153,10 +153,10 @@ PresentationSession::Send(const nsAString& aData,
|
||||
}
|
||||
|
||||
void
|
||||
PresentationSession::Close(ErrorResult& aRv)
|
||||
PresentationConnection::Close(ErrorResult& aRv)
|
||||
{
|
||||
// It only works when the state is CONNECTED.
|
||||
if (NS_WARN_IF(mState != PresentationSessionState::Connected)) {
|
||||
if (NS_WARN_IF(mState != PresentationConnectionState::Connected)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -165,10 +165,10 @@ PresentationSession::Close(ErrorResult& aRv)
|
||||
}
|
||||
|
||||
void
|
||||
PresentationSession::Terminate(ErrorResult& aRv)
|
||||
PresentationConnection::Terminate(ErrorResult& aRv)
|
||||
{
|
||||
// It only works when the state is CONNECTED.
|
||||
if (NS_WARN_IF(mState != PresentationSessionState::Connected)) {
|
||||
if (NS_WARN_IF(mState != PresentationConnectionState::Connected)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -183,23 +183,23 @@ PresentationSession::Terminate(ErrorResult& aRv)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PresentationSession::NotifyStateChange(const nsAString& aSessionId,
|
||||
PresentationConnection::NotifyStateChange(const nsAString& aSessionId,
|
||||
uint16_t aState)
|
||||
{
|
||||
if (!aSessionId.Equals(mId)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
PresentationSessionState state;
|
||||
PresentationConnectionState state;
|
||||
switch (aState) {
|
||||
case nsIPresentationSessionListener::STATE_CONNECTED:
|
||||
state = PresentationSessionState::Connected;
|
||||
state = PresentationConnectionState::Connected;
|
||||
break;
|
||||
case nsIPresentationSessionListener::STATE_CLOSED:
|
||||
state = PresentationSessionState::Closed;
|
||||
state = PresentationConnectionState::Closed;
|
||||
break;
|
||||
case nsIPresentationSessionListener::STATE_TERMINATED:
|
||||
state = PresentationSessionState::Terminated;
|
||||
state = PresentationConnectionState::Terminated;
|
||||
break;
|
||||
default:
|
||||
NS_WARNING("Unknown presentation session state.");
|
||||
@ -213,7 +213,7 @@ PresentationSession::NotifyStateChange(const nsAString& aSessionId,
|
||||
mState = state;
|
||||
|
||||
// Unregister session listener if the session is no longer connected.
|
||||
if (mState == PresentationSessionState::Terminated) {
|
||||
if (mState == PresentationConnectionState::Terminated) {
|
||||
nsCOMPtr<nsIPresentationService> service =
|
||||
do_GetService(PRESENTATION_SERVICE_CONTRACTID);
|
||||
if (NS_WARN_IF(!service)) {
|
||||
@ -230,7 +230,7 @@ PresentationSession::NotifyStateChange(const nsAString& aSessionId,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PresentationSession::NotifyMessage(const nsAString& aSessionId,
|
||||
PresentationConnection::NotifyMessage(const nsAString& aSessionId,
|
||||
const nsACString& aData)
|
||||
{
|
||||
if (!aSessionId.Equals(mId)) {
|
||||
@ -238,7 +238,7 @@ PresentationSession::NotifyMessage(const nsAString& aSessionId,
|
||||
}
|
||||
|
||||
// No message should be expected when the session is not connected.
|
||||
if (NS_WARN_IF(mState != PresentationSessionState::Connected)) {
|
||||
if (NS_WARN_IF(mState != PresentationConnectionState::Connected)) {
|
||||
return NS_ERROR_DOM_INVALID_STATE_ERR;
|
||||
}
|
||||
|
||||
@ -258,7 +258,7 @@ PresentationSession::NotifyMessage(const nsAString& aSessionId,
|
||||
}
|
||||
|
||||
nsresult
|
||||
PresentationSession::DispatchStateChangeEvent()
|
||||
PresentationConnection::DispatchStateChangeEvent()
|
||||
{
|
||||
nsRefPtr<AsyncEventDispatcher> asyncDispatcher =
|
||||
new AsyncEventDispatcher(this, NS_LITERAL_STRING("statechange"), false);
|
||||
@ -266,7 +266,7 @@ PresentationSession::DispatchStateChangeEvent()
|
||||
}
|
||||
|
||||
nsresult
|
||||
PresentationSession::DispatchMessageEvent(JS::Handle<JS::Value> aData)
|
||||
PresentationConnection::DispatchMessageEvent(JS::Handle<JS::Value> aData)
|
||||
{
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetOwner());
|
||||
if (NS_WARN_IF(!global)) {
|
@ -4,28 +4,28 @@
|
||||
* 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_PresentationSession_h
|
||||
#define mozilla_dom_PresentationSession_h
|
||||
#ifndef mozilla_dom_PresentationConnection_h
|
||||
#define mozilla_dom_PresentationConnection_h
|
||||
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "mozilla/dom/PresentationSessionBinding.h"
|
||||
#include "mozilla/dom/PresentationConnectionBinding.h"
|
||||
#include "nsIPresentationListener.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class PresentationSession final : public DOMEventTargetHelper
|
||||
, public nsIPresentationSessionListener
|
||||
class PresentationConnection final : public DOMEventTargetHelper
|
||||
, public nsIPresentationSessionListener
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PresentationSession,
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PresentationConnection,
|
||||
DOMEventTargetHelper)
|
||||
NS_DECL_NSIPRESENTATIONSESSIONLISTENER
|
||||
|
||||
static already_AddRefed<PresentationSession> Create(nsPIDOMWindow* aWindow,
|
||||
const nsAString& aId,
|
||||
PresentationSessionState aState);
|
||||
static already_AddRefed<PresentationConnection> Create(nsPIDOMWindow* aWindow,
|
||||
const nsAString& aId,
|
||||
PresentationConnectionState aState);
|
||||
|
||||
virtual void DisconnectFromOwner() override;
|
||||
|
||||
@ -35,7 +35,7 @@ public:
|
||||
// WebIDL (public APIs)
|
||||
void GetId(nsAString& aId) const;
|
||||
|
||||
PresentationSessionState State() const;
|
||||
PresentationConnectionState State() const;
|
||||
|
||||
void Send(const nsAString& aData,
|
||||
ErrorResult& aRv);
|
||||
@ -48,11 +48,11 @@ public:
|
||||
IMPL_EVENT_HANDLER(message);
|
||||
|
||||
private:
|
||||
PresentationSession(nsPIDOMWindow* aWindow,
|
||||
const nsAString& aId,
|
||||
PresentationSessionState aState);
|
||||
PresentationConnection(nsPIDOMWindow* aWindow,
|
||||
const nsAString& aId,
|
||||
PresentationConnectionState aState);
|
||||
|
||||
~PresentationSession();
|
||||
~PresentationConnection();
|
||||
|
||||
bool Init();
|
||||
|
||||
@ -63,10 +63,10 @@ private:
|
||||
nsresult DispatchMessageEvent(JS::Handle<JS::Value> aData);
|
||||
|
||||
nsString mId;
|
||||
PresentationSessionState mState;
|
||||
PresentationConnectionState mState;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_PresentationSession_h
|
||||
#endif // mozilla_dom_PresentationConnection_h
|
@ -11,7 +11,7 @@
|
||||
#include "nsIPresentationService.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "PresentationReceiver.h"
|
||||
#include "PresentationSession.h"
|
||||
#include "PresentationConnection.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@ -19,14 +19,14 @@ using namespace mozilla::dom;
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(PresentationReceiver)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(PresentationReceiver, DOMEventTargetHelper)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSessions)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPendingGetSessionPromises)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mConnections)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPendingGetConnectionPromises)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(PresentationReceiver, DOMEventTargetHelper)
|
||||
tmp->Shutdown();
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSessions)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mPendingGetSessionPromises)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mConnections)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mPendingGetConnectionPromises)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(PresentationReceiver, DOMEventTargetHelper)
|
||||
@ -86,8 +86,8 @@ PresentationReceiver::Init(const nsAString& aSessionId)
|
||||
|
||||
void PresentationReceiver::Shutdown()
|
||||
{
|
||||
mSessions.Clear();
|
||||
mPendingGetSessionPromises.Clear();
|
||||
mConnections.Clear();
|
||||
mPendingGetConnectionPromises.Clear();
|
||||
|
||||
// Unregister listener for incoming sessions.
|
||||
nsCOMPtr<nsIPresentationService> service =
|
||||
@ -115,7 +115,7 @@ PresentationReceiver::WrapObject(JSContext* aCx,
|
||||
}
|
||||
|
||||
already_AddRefed<Promise>
|
||||
PresentationReceiver::GetSession(ErrorResult& aRv)
|
||||
PresentationReceiver::GetConnection(ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetOwner());
|
||||
if (NS_WARN_IF(!global)) {
|
||||
@ -128,20 +128,20 @@ PresentationReceiver::GetSession(ErrorResult& aRv)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// If there's no existing session, leave the promise pending until a
|
||||
// If there's no existing connection, leave the promise pending until a
|
||||
// connecting request arrives from the controlling browsing context (sender).
|
||||
// http://w3c.github.io/presentation-api/#dom-presentation-getsession
|
||||
if (!mSessions.IsEmpty()) {
|
||||
promise->MaybeResolve(mSessions[0]);
|
||||
// http://w3c.github.io/presentation-api/#dom-presentation-getconnection
|
||||
if (!mConnections.IsEmpty()) {
|
||||
promise->MaybeResolve(mConnections[0]);
|
||||
} else {
|
||||
mPendingGetSessionPromises.AppendElement(promise);
|
||||
mPendingGetConnectionPromises.AppendElement(promise);
|
||||
}
|
||||
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<Promise>
|
||||
PresentationReceiver::GetSessions(ErrorResult& aRv) const
|
||||
PresentationReceiver::GetConnections(ErrorResult& aRv) const
|
||||
{
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetOwner());
|
||||
if (NS_WARN_IF(!global)) {
|
||||
@ -154,7 +154,7 @@ PresentationReceiver::GetSessions(ErrorResult& aRv) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
promise->MaybeResolve(mSessions);
|
||||
promise->MaybeResolve(mConnections);
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
@ -166,29 +166,29 @@ PresentationReceiver::NotifySessionConnect(uint64_t aWindowId,
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
nsRefPtr<PresentationSession> session =
|
||||
PresentationSession::Create(GetOwner(), aSessionId,
|
||||
PresentationSessionState::Closed);
|
||||
if (NS_WARN_IF(!session)) {
|
||||
nsRefPtr<PresentationConnection> connection =
|
||||
PresentationConnection::Create(GetOwner(), aSessionId,
|
||||
PresentationConnectionState::Closed);
|
||||
if (NS_WARN_IF(!connection)) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
mSessions.AppendElement(session);
|
||||
mConnections.AppendElement(connection);
|
||||
|
||||
// Resolve pending |GetSession| promises if any.
|
||||
if (!mPendingGetSessionPromises.IsEmpty()) {
|
||||
for(uint32_t i = 0; i < mPendingGetSessionPromises.Length(); i++) {
|
||||
mPendingGetSessionPromises[i]->MaybeResolve(session);
|
||||
// Resolve pending |GetConnection| promises if any.
|
||||
if (!mPendingGetConnectionPromises.IsEmpty()) {
|
||||
for(uint32_t i = 0; i < mPendingGetConnectionPromises.Length(); i++) {
|
||||
mPendingGetConnectionPromises[i]->MaybeResolve(connection);
|
||||
}
|
||||
mPendingGetSessionPromises.Clear();
|
||||
mPendingGetConnectionPromises.Clear();
|
||||
}
|
||||
|
||||
return DispatchSessionAvailableEvent();
|
||||
return DispatchConnectionAvailableEvent();
|
||||
}
|
||||
|
||||
nsresult
|
||||
PresentationReceiver::DispatchSessionAvailableEvent()
|
||||
PresentationReceiver::DispatchConnectionAvailableEvent()
|
||||
{
|
||||
nsRefPtr<AsyncEventDispatcher> asyncDispatcher =
|
||||
new AsyncEventDispatcher(this, NS_LITERAL_STRING("sessionavailable"), false);
|
||||
new AsyncEventDispatcher(this, NS_LITERAL_STRING("connectionavailable"), false);
|
||||
return asyncDispatcher->PostDOMEvent();
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class Promise;
|
||||
class PresentationSession;
|
||||
class PresentationConnection;
|
||||
|
||||
class PresentationReceiver final : public DOMEventTargetHelper
|
||||
, public nsIPresentationRespondingListener
|
||||
@ -34,11 +34,11 @@ public:
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
// WebIDL (public APIs)
|
||||
already_AddRefed<Promise> GetSession(ErrorResult& aRv);
|
||||
already_AddRefed<Promise> GetConnection(ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<Promise> GetSessions(ErrorResult& aRv) const;
|
||||
already_AddRefed<Promise> GetConnections(ErrorResult& aRv) const;
|
||||
|
||||
IMPL_EVENT_HANDLER(sessionavailable);
|
||||
IMPL_EVENT_HANDLER(connectionavailable);
|
||||
|
||||
private:
|
||||
explicit PresentationReceiver(nsPIDOMWindow* aWindow);
|
||||
@ -49,14 +49,14 @@ private:
|
||||
|
||||
void Shutdown();
|
||||
|
||||
nsresult DispatchSessionAvailableEvent();
|
||||
nsresult DispatchConnectionAvailableEvent();
|
||||
|
||||
// Store the inner window ID for |UnregisterRespondingListener| call in
|
||||
// |Shutdown| since the inner window may not exist at that moment.
|
||||
uint64_t mWindowId;
|
||||
|
||||
nsTArray<nsRefPtr<PresentationSession>> mSessions;
|
||||
nsTArray<nsRefPtr<Promise>> mPendingGetSessionPromises;
|
||||
nsTArray<nsRefPtr<PresentationConnection>> mConnections;
|
||||
nsTArray<nsRefPtr<Promise>> mPendingGetConnectionPromises;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
@ -5,7 +5,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/PresentationRequestBinding.h"
|
||||
#include "mozilla/dom/PresentationSessionConnectEvent.h"
|
||||
#include "mozilla/dom/PresentationConnectionAvailableEvent.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "mozIThirdPartyUtil.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
@ -151,15 +151,15 @@ PresentationRequest::GetAvailability(ErrorResult& aRv)
|
||||
}
|
||||
|
||||
nsresult
|
||||
PresentationRequest::DispatchSessionConnectEvent(PresentationSession* aSession)
|
||||
PresentationRequest::DispatchConnectionAvailableEvent(PresentationConnection* aConnection)
|
||||
{
|
||||
PresentationSessionConnectEventInit init;
|
||||
init.mSession = aSession;
|
||||
PresentationConnectionAvailableEventInit init;
|
||||
init.mConnection = aConnection;
|
||||
|
||||
nsRefPtr<PresentationSessionConnectEvent> event =
|
||||
PresentationSessionConnectEvent::Constructor(this,
|
||||
NS_LITERAL_STRING("sessionconnect"),
|
||||
init);
|
||||
nsRefPtr<PresentationConnectionAvailableEvent> event =
|
||||
PresentationConnectionAvailableEvent::Constructor(this,
|
||||
NS_LITERAL_STRING("connectionavailable"),
|
||||
init);
|
||||
if (NS_WARN_IF(!event)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ namespace dom {
|
||||
|
||||
class Promise;
|
||||
class PresentationAvailability;
|
||||
class PresentationSession;
|
||||
class PresentationConnection;
|
||||
|
||||
class PresentationRequest final : public DOMEventTargetHelper
|
||||
{
|
||||
@ -35,9 +35,9 @@ public:
|
||||
|
||||
already_AddRefed<Promise> GetAvailability(ErrorResult& aRv);
|
||||
|
||||
IMPL_EVENT_HANDLER(sessionconnect);
|
||||
IMPL_EVENT_HANDLER(connectionavailable);
|
||||
|
||||
nsresult DispatchSessionConnectEvent(PresentationSession* aSession);
|
||||
nsresult DispatchConnectionAvailableEvent(PresentationConnection* aConnection);
|
||||
|
||||
private:
|
||||
PresentationRequest(nsPIDOMWindow* aWindow,
|
||||
|
@ -16,11 +16,11 @@ EXPORTS.mozilla.dom += [
|
||||
'Presentation.h',
|
||||
'PresentationAvailability.h',
|
||||
'PresentationCallbacks.h',
|
||||
'PresentationConnection.h',
|
||||
'PresentationDeviceManager.h',
|
||||
'PresentationReceiver.h',
|
||||
'PresentationRequest.h',
|
||||
'PresentationService.h',
|
||||
'PresentationSession.h',
|
||||
'PresentationSessionInfo.h',
|
||||
'PresentationSessionTransport.h',
|
||||
]
|
||||
@ -32,11 +32,11 @@ UNIFIED_SOURCES += [
|
||||
'Presentation.cpp',
|
||||
'PresentationAvailability.cpp',
|
||||
'PresentationCallbacks.cpp',
|
||||
'PresentationConnection.cpp',
|
||||
'PresentationDeviceManager.cpp',
|
||||
'PresentationReceiver.cpp',
|
||||
'PresentationRequest.cpp',
|
||||
'PresentationService.cpp',
|
||||
'PresentationSession.cpp',
|
||||
'PresentationSessionInfo.cpp',
|
||||
'PresentationSessionRequest.cpp',
|
||||
'PresentationSessionTransport.cpp',
|
||||
|
@ -9,8 +9,8 @@
|
||||
interface Presentation : EventTarget {
|
||||
/*
|
||||
* This should be used by the UA as the default presentation request for the
|
||||
* controller. When the UA wishes to initiate a PresentationSession on the
|
||||
* controller's behalf, it MUST start a presentation session using the default
|
||||
* controller. When the UA wishes to initiate a PresentationConnection on the
|
||||
* controller's behalf, it MUST start a presentation connection using the default
|
||||
* presentation request (as if the controller had called |defaultRequest.start()|).
|
||||
*
|
||||
* Only used by controlling browsing context (senders).
|
||||
|
@ -4,7 +4,7 @@
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
enum PresentationSessionState
|
||||
enum PresentationConnectionState
|
||||
{
|
||||
// Existing presentation, and the communication channel is active.
|
||||
"connected",
|
||||
@ -19,9 +19,9 @@ enum PresentationSessionState
|
||||
|
||||
[Pref="dom.presentation.enabled",
|
||||
CheckAnyPermissions="presentation"]
|
||||
interface PresentationSession : EventTarget {
|
||||
interface PresentationConnection : EventTarget {
|
||||
/*
|
||||
* Unique id for all existing sessions.
|
||||
* Unique id for all existing connections.
|
||||
*/
|
||||
[Constant]
|
||||
readonly attribute DOMString id;
|
||||
@ -29,10 +29,10 @@ interface PresentationSession : EventTarget {
|
||||
/*
|
||||
* @value "connected", "closed", or "terminated".
|
||||
*/
|
||||
readonly attribute PresentationSessionState state;
|
||||
readonly attribute PresentationConnectionState state;
|
||||
|
||||
/*
|
||||
* It is called when session state changes.
|
||||
* It is called when connection state changes.
|
||||
*/
|
||||
attribute EventHandler onstatechange;
|
||||
|
||||
@ -55,8 +55,8 @@ interface PresentationSession : EventTarget {
|
||||
attribute EventHandler onmessage;
|
||||
|
||||
/*
|
||||
* Both the controlling and receving browsing context can close the session.
|
||||
* Then, the session state should turn into "closed".
|
||||
* Both the controlling and receiving browsing context can close the
|
||||
* connection. Then the connection state should turn into "closed".
|
||||
*
|
||||
* This function only works when the state is not "connected".
|
||||
*/
|
||||
@ -65,8 +65,8 @@ interface PresentationSession : EventTarget {
|
||||
// void close();
|
||||
|
||||
/*
|
||||
* Both the controlling and receving browsing context can terminate the session.
|
||||
* Then the session state should turn into "terminated".
|
||||
* Both the controlling and receiving browsing context can terminate the
|
||||
* connection. Then the connection state should turn into "terminated".
|
||||
*
|
||||
* This function only works when the state is not "connected".
|
||||
*/
|
@ -5,16 +5,16 @@
|
||||
*/
|
||||
|
||||
[Constructor(DOMString type,
|
||||
optional PresentationSessionConnectEventInit eventInitDict),
|
||||
optional PresentationConnectionAvailableEventInit eventInitDict),
|
||||
Pref="dom.presentation.enabled",
|
||||
CheckAnyPermissions="presentation"]
|
||||
interface PresentationSessionConnectEvent : Event
|
||||
interface PresentationConnectionAvailableEvent : Event
|
||||
{
|
||||
[SameObject]
|
||||
readonly attribute PresentationSession session;
|
||||
readonly attribute PresentationConnection connection;
|
||||
};
|
||||
|
||||
dictionary PresentationSessionConnectEventInit : EventInit
|
||||
dictionary PresentationConnectionAvailableEventInit : EventInit
|
||||
{
|
||||
required PresentationSession session;
|
||||
required PresentationConnection connection;
|
||||
};
|
@ -8,20 +8,20 @@
|
||||
CheckAnyPermissions="presentation"]
|
||||
interface PresentationReceiver : EventTarget {
|
||||
/*
|
||||
* Get the first connected presentation session in a receiving browsing
|
||||
* Get the first connected presentation connection in a receiving browsing
|
||||
* context.
|
||||
*/
|
||||
[Throws]
|
||||
Promise<PresentationSession> getSession();
|
||||
Promise<PresentationConnection> getConnection();
|
||||
|
||||
/*
|
||||
* Get all connected presentation sessions in a receiving browsing context.
|
||||
* Get all connected presentation connections in a receiving browsing context.
|
||||
*/
|
||||
[Throws]
|
||||
Promise<sequence<PresentationSession>> getSessions();
|
||||
Promise<sequence<PresentationConnection>> getConnections();
|
||||
|
||||
/*
|
||||
* It is called when an incoming session is connecting.
|
||||
* It is called when an incoming connection is connecting.
|
||||
*/
|
||||
attribute EventHandler onsessionavailable;
|
||||
attribute EventHandler onconnectionavailable;
|
||||
};
|
||||
|
@ -9,13 +9,13 @@
|
||||
CheckAnyPermissions="presentation"]
|
||||
interface PresentationRequest : EventTarget {
|
||||
/*
|
||||
* A requesting page use start() to start a new session, and the session will
|
||||
* be returned with the promise. UA may show a prompt box with a list of
|
||||
* A requesting page use start() to start a new connection, and it will be
|
||||
* returned with the promise. UA may show a prompt box with a list of
|
||||
* available devices and ask the user to grant permission, choose a device, or
|
||||
* cancel the operation.
|
||||
*
|
||||
* The promise is resolved when the presenting page is successfully loaded and
|
||||
* the communication channel is established, i.e., the session state is
|
||||
* the communication channel is established, i.e., the connection state is
|
||||
* "connected".
|
||||
*
|
||||
* The promise may be rejected duo to one of the following reasons:
|
||||
@ -26,7 +26,7 @@ interface PresentationRequest : EventTarget {
|
||||
* - "TimeoutError": Presenting page takes too long to load.
|
||||
*/
|
||||
[Throws]
|
||||
Promise<PresentationSession> start();
|
||||
Promise<PresentationConnection> start();
|
||||
|
||||
/*
|
||||
* UA triggers device discovery mechanism periodically and monitor device
|
||||
@ -39,8 +39,8 @@ interface PresentationRequest : EventTarget {
|
||||
Promise<PresentationAvailability> getAvailability();
|
||||
|
||||
/*
|
||||
* It is called when a session associated with a PresentationRequest is created.
|
||||
* The event is fired for all sessions that are created for the controller.
|
||||
* It is called when a connection associated with a PresentationRequest is created.
|
||||
* The event is fired for all connections that are created for the controller.
|
||||
*/
|
||||
attribute EventHandler onsessionconnect;
|
||||
attribute EventHandler onconnectionavailable;
|
||||
};
|
||||
|
@ -374,10 +374,10 @@ WEBIDL_FILES = [
|
||||
'PositionError.webidl',
|
||||
'Presentation.webidl',
|
||||
'PresentationAvailability.webidl',
|
||||
'PresentationConnection.webidl',
|
||||
'PresentationDeviceInfoManager.webidl',
|
||||
'PresentationReceiver.webidl',
|
||||
'PresentationRequest.webidl',
|
||||
'PresentationSession.webidl',
|
||||
'ProcessingInstruction.webidl',
|
||||
'ProfileTimelineMarker.webidl',
|
||||
'Promise.webidl',
|
||||
@ -801,7 +801,7 @@ GENERATED_EVENTS_WEBIDL_FILES = [
|
||||
'PluginCrashedEvent.webidl',
|
||||
'PopStateEvent.webidl',
|
||||
'PopupBlockedEvent.webidl',
|
||||
'PresentationSessionConnectEvent.webidl',
|
||||
'PresentationConnectionAvailableEvent.webidl',
|
||||
'ProgressEvent.webidl',
|
||||
'RecordErrorEvent.webidl',
|
||||
'ScrollViewChangeEvent.webidl',
|
||||
|
Loading…
Reference in New Issue
Block a user