Bug 1212702 - [Presentation WebAPI] Rename to PresentationConnection. Part 1 - WebIDL bindings. r=smaug
authorSean Lin <selin@mozilla.com>
Mon, 12 Oct 2015 10:36:31 +0800
changeset 300663 c230adf1f8795a0c407e1da663f4d44da116b2f7
parent 300662 f6261091eca7b9d3b471ed8544d15433018a5551
child 300664 906f76d5adcfb2f43aedd33eb793733a3fbb1f30
push id5392
push userraliiev@mozilla.com
push dateMon, 14 Dec 2015 20:08:23 +0000
treeherdermozilla-beta@16ce8562a975 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1212702
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1212702 - [Presentation WebAPI] Rename to PresentationConnection. Part 1 - WebIDL bindings. r=smaug
dom/base/nsGkAtomList.h
dom/presentation/PresentationCallbacks.cpp
dom/presentation/PresentationConnection.cpp
dom/presentation/PresentationConnection.h
dom/presentation/PresentationReceiver.cpp
dom/presentation/PresentationReceiver.h
dom/presentation/PresentationRequest.cpp
dom/presentation/PresentationRequest.h
dom/presentation/PresentationSession.cpp
dom/presentation/PresentationSession.h
dom/presentation/moz.build
dom/webidl/Presentation.webidl
dom/webidl/PresentationConnection.webidl
dom/webidl/PresentationConnectionAvailableEvent.webidl
dom/webidl/PresentationReceiver.webidl
dom/webidl/PresentationRequest.webidl
dom/webidl/PresentationSession.webidl
dom/webidl/PresentationSessionConnectEvent.webidl
dom/webidl/moz.build
--- a/dom/base/nsGkAtomList.h
+++ b/dom/base/nsGkAtomList.h
@@ -718,16 +718,17 @@ GK_ATOM(oncommandupdate, "oncommandupdat
 GK_ATOM(oncomplete, "oncomplete")
 GK_ATOM(oncompositionend, "oncompositionend")
 GK_ATOM(oncompositionstart, "oncompositionstart")
 GK_ATOM(oncompositionupdate, "oncompositionupdate")
 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")
 GK_ATOM(oncurrentchannelchanged, "oncurrentchannelchanged")
 GK_ATOM(oncurrentsourcechanged, "oncurrentsourcechanged")
 GK_ATOM(oncut, "oncut")
 GK_ATOM(ondatachange, "ondatachange")
 GK_ATOM(ondataerror, "ondataerror")
@@ -893,18 +894,16 @@ GK_ATOM(onrtchange, "onrtchange")
 GK_ATOM(onscanningstatechanged, "onscanningstatechanged")
 GK_ATOM(onscostatuschanged, "onscostatuschanged")
 GK_ATOM(onscroll, "onscroll")
 GK_ATOM(onselect, "onselect")
 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")
 GK_ATOM(onstatechange, "onstatechange")
 GK_ATOM(onstatuschanged, "onstatuschanged")
 GK_ATOM(onstkcommand, "onstkcommand")
 GK_ATOM(onstksessionend, "onstksessionend")
 GK_ATOM(onstorageareachanged, "onstorageareachanged")
--- a/dom/presentation/PresentationCallbacks.cpp
+++ b/dom/presentation/PresentationCallbacks.cpp
@@ -7,17 +7,17 @@
 #include "mozilla/dom/Promise.h"
 #include "nsIDocShell.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIPresentationService.h"
 #include "nsIWebProgress.h"
 #include "nsServiceManagerUtils.h"
 #include "PresentationCallbacks.h"
 #include "PresentationRequest.h"
-#include "PresentationSession.h"
+#include "PresentationConnection.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 /*
  * Implementation of PresentationRequesterCallback
  */
 
@@ -42,28 +42,28 @@ PresentationRequesterCallback::~Presenta
 
 // nsIPresentationServiceCallback
 NS_IMETHODIMP
 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
 PresentationRequesterCallback::NotifyError(nsresult aError)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   mPromise->MaybeReject(aError);
rename from dom/presentation/PresentationSession.cpp
rename to dom/presentation/PresentationConnection.cpp
--- a/dom/presentation/PresentationSession.cpp
+++ b/dom/presentation/PresentationConnection.cpp
@@ -5,62 +5,62 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/AsyncEventDispatcher.h"
 #include "mozilla/dom/MessageEvent.h"
 #include "nsCycleCollectionParticipant.h"
 #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;
   }
 
   nsCOMPtr<nsIPresentationService> service =
     do_GetService(PRESENTATION_SERVICE_CONTRACTID);
   if(NS_WARN_IF(!service)) {
@@ -71,60 +71,60 @@ PresentationSession::Init()
   if(NS_WARN_IF(NS_FAILED(rv))) {
     return false;
   }
 
   return true;
 }
 
 void
-PresentationSession::Shutdown()
+PresentationConnection::Shutdown()
 {
   nsCOMPtr<nsIPresentationService> service =
     do_GetService(PRESENTATION_SERVICE_CONTRACTID);
   if (NS_WARN_IF(!service)) {
     return;
   }
 
   nsresult rv = service->UnregisterSessionListener(mId);
   NS_WARN_IF(NS_FAILED(rv));
 }
 
 /* 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;
   }
 
   nsresult rv;
   nsCOMPtr<nsIStringInputStream> stream =
     do_CreateInstance(NS_STRINGINPUTSTREAM_CONTRACTID, &rv);
   if(NS_WARN_IF(NS_FAILED(rv))) {
@@ -148,102 +148,102 @@ PresentationSession::Send(const nsAStrin
 
   rv = service->SendSessionMessage(mId, stream);
   if(NS_WARN_IF(NS_FAILED(rv))) {
     aRv.Throw(NS_ERROR_DOM_OPERATION_ERR);
   }
 }
 
 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;
   }
 
   // TODO Bug 1210340 - Support close semantics.
   aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
 }
 
 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;
   }
 
   nsCOMPtr<nsIPresentationService> service =
     do_GetService(PRESENTATION_SERVICE_CONTRACTID);
   if(NS_WARN_IF(!service)) {
     aRv.Throw(NS_ERROR_DOM_OPERATION_ERR);
     return;
   }
 
   NS_WARN_IF(NS_FAILED(service->TerminateSession(mId)));
 }
 
 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.");
       return NS_ERROR_INVALID_ARG;
   }
 
   if (mState == state) {
     return NS_OK;
   }
 
   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)) {
       return NS_ERROR_NOT_AVAILABLE;
     }
 
     nsresult rv = service->UnregisterSessionListener(mId);
     if(NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   }
 
   return DispatchStateChangeEvent();
 }
 
 NS_IMETHODIMP
-PresentationSession::NotifyMessage(const nsAString& aSessionId,
+PresentationConnection::NotifyMessage(const nsAString& aSessionId,
                                    const nsACString& aData)
 {
   if (!aSessionId.Equals(mId)) {
     return NS_ERROR_INVALID_ARG;
   }
 
   // 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;
   }
 
   // Transform the data.
   AutoJSAPI jsapi;
   if (!jsapi.Init(GetOwner())) {
     return NS_ERROR_FAILURE;
   }
@@ -253,25 +253,25 @@ PresentationSession::NotifyMessage(const
   if(NS_WARN_IF(!ToJSValue(cx, utf16Data, &jsData))) {
     return NS_ERROR_FAILURE;
   }
 
   return DispatchMessageEvent(jsData);
 }
 
 nsresult
-PresentationSession::DispatchStateChangeEvent()
+PresentationConnection::DispatchStateChangeEvent()
 {
   nsRefPtr<AsyncEventDispatcher> asyncDispatcher =
     new AsyncEventDispatcher(this, NS_LITERAL_STRING("statechange"), false);
   return asyncDispatcher->PostDOMEvent();
 }
 
 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)) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   // Get the origin.
   nsAutoString origin;
rename from dom/presentation/PresentationSession.h
rename to dom/presentation/PresentationConnection.h
--- a/dom/presentation/PresentationSession.h
+++ b/dom/presentation/PresentationConnection.h
@@ -1,72 +1,72 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* 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_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;
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aGivenProto) override;
 
   // WebIDL (public APIs)
   void GetId(nsAString& aId) const;
 
-  PresentationSessionState State() const;
+  PresentationConnectionState State() const;
 
   void Send(const nsAString& aData,
             ErrorResult& aRv);
 
   void Close(ErrorResult& aRv);
 
   void Terminate(ErrorResult& aRv);
 
   IMPL_EVENT_HANDLER(statechange);
   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();
 
   void Shutdown();
 
   nsresult DispatchStateChangeEvent();
 
   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
--- a/dom/presentation/PresentationReceiver.cpp
+++ b/dom/presentation/PresentationReceiver.cpp
@@ -6,32 +6,32 @@
 
 #include "mozilla/AsyncEventDispatcher.h"
 #include "mozilla/dom/PresentationReceiverBinding.h"
 #include "mozilla/dom/Promise.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsIPresentationService.h"
 #include "nsServiceManagerUtils.h"
 #include "PresentationReceiver.h"
-#include "PresentationSession.h"
+#include "PresentationConnection.h"
 
 using namespace mozilla;
 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)
 NS_IMPL_RELEASE_INHERITED(PresentationReceiver, DOMEventTargetHelper)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(PresentationReceiver)
   NS_INTERFACE_MAP_ENTRY(nsIPresentationRespondingListener)
 NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
@@ -81,18 +81,18 @@ PresentationReceiver::Init(const nsAStri
     return false;
   }
 
   return true;
 }
 
 void PresentationReceiver::Shutdown()
 {
-  mSessions.Clear();
-  mPendingGetSessionPromises.Clear();
+  mConnections.Clear();
+  mPendingGetConnectionPromises.Clear();
 
   // Unregister listener for incoming sessions.
   nsCOMPtr<nsIPresentationService> service =
     do_GetService(PRESENTATION_SERVICE_CONTRACTID);
   if (NS_WARN_IF(!service)) {
     return;
   }
 
@@ -110,85 +110,85 @@ PresentationReceiver::DisconnectFromOwne
 /* virtual */ JSObject*
 PresentationReceiver::WrapObject(JSContext* aCx,
                                  JS::Handle<JSObject*> aGivenProto)
 {
   return PresentationReceiverBinding::Wrap(aCx, this, aGivenProto);
 }
 
 already_AddRefed<Promise>
-PresentationReceiver::GetSession(ErrorResult& aRv)
+PresentationReceiver::GetConnection(ErrorResult& aRv)
 {
   nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetOwner());
   if (NS_WARN_IF(!global)) {
     aRv.Throw(NS_ERROR_UNEXPECTED);
     return nullptr;
   }
 
   nsRefPtr<Promise> promise = Promise::Create(global, aRv);
   if (NS_WARN_IF(aRv.Failed())) {
     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)) {
     aRv.Throw(NS_ERROR_UNEXPECTED);
     return nullptr;
   }
 
   nsRefPtr<Promise> promise = Promise::Create(global, aRv);
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
 
-  promise->MaybeResolve(mSessions);
+  promise->MaybeResolve(mConnections);
   return promise.forget();
 }
 
 NS_IMETHODIMP
 PresentationReceiver::NotifySessionConnect(uint64_t aWindowId,
                                            const nsAString& aSessionId)
 {
   if (NS_WARN_IF(aWindowId != GetOwner()->WindowID())) {
     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();
 }
--- a/dom/presentation/PresentationReceiver.h
+++ b/dom/presentation/PresentationReceiver.h
@@ -9,17 +9,17 @@
 
 #include "mozilla/DOMEventTargetHelper.h"
 #include "nsIPresentationListener.h"
 
 namespace mozilla {
 namespace dom {
 
 class Promise;
-class PresentationSession;
+class PresentationConnection;
 
 class PresentationReceiver final : public DOMEventTargetHelper
                                  , public nsIPresentationRespondingListener
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PresentationReceiver,
                                            DOMEventTargetHelper)
@@ -29,37 +29,37 @@ public:
                                                        const nsAString& aSessionId);
 
   virtual void DisconnectFromOwner() override;
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                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);
 
   ~PresentationReceiver();
 
   bool Init(const nsAString& aSessionId);
 
   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
 } // namespace mozilla
 
 #endif // mozilla_dom_PresentationReceiver_h
--- a/dom/presentation/PresentationRequest.cpp
+++ b/dom/presentation/PresentationRequest.cpp
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* 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/PresentationRequestBinding.h"
-#include "mozilla/dom/PresentationSessionConnectEvent.h"
+#include "mozilla/dom/PresentationConnectionAvailableEvent.h"
 #include "mozilla/dom/Promise.h"
 #include "mozIThirdPartyUtil.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsIPresentationService.h"
 #include "nsIUUIDGenerator.h"
 #include "nsServiceManagerUtils.h"
 #include "PresentationAvailability.h"
 #include "PresentationCallbacks.h"
@@ -146,25 +146,25 @@ PresentationRequest::GetAvailability(Err
     return nullptr;
   }
 
   promise->MaybeResolve(mAvailability);
   return promise.forget();
 }
 
 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;
   }
   event->SetTrusted(true);
 
   nsRefPtr<AsyncEventDispatcher> asyncDispatcher =
     new AsyncEventDispatcher(this, event);
   return asyncDispatcher->PostDOMEvent();
--- a/dom/presentation/PresentationRequest.h
+++ b/dom/presentation/PresentationRequest.h
@@ -9,17 +9,17 @@
 
 #include "mozilla/DOMEventTargetHelper.h"
 
 namespace mozilla {
 namespace dom {
 
 class Promise;
 class PresentationAvailability;
-class PresentationSession;
+class PresentationConnection;
 
 class PresentationRequest final : public DOMEventTargetHelper
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PresentationRequest,
                                            DOMEventTargetHelper)
 
@@ -30,19 +30,19 @@ public:
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aGivenProto) override;
 
   // WebIDL (public APIs)
   already_AddRefed<Promise> Start(ErrorResult& aRv);
 
   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,
                       const nsAString& aUrl);
 
   ~PresentationRequest();
 
   bool Init();
--- a/dom/presentation/moz.build
+++ b/dom/presentation/moz.build
@@ -11,37 +11,37 @@ MOCHITEST_MANIFESTS += ['tests/mochitest
 
 EXPORTS.mozilla.dom += [
     'ipc/PresentationChild.h',
     'ipc/PresentationIPCService.h',
     'ipc/PresentationParent.h',
     'Presentation.h',
     'PresentationAvailability.h',
     'PresentationCallbacks.h',
+    'PresentationConnection.h',
     'PresentationDeviceManager.h',
     'PresentationReceiver.h',
     'PresentationRequest.h',
     'PresentationService.h',
-    'PresentationSession.h',
     'PresentationSessionInfo.h',
     'PresentationSessionTransport.h',
 ]
 
 UNIFIED_SOURCES += [
     'ipc/PresentationChild.cpp',
     'ipc/PresentationIPCService.cpp',
     'ipc/PresentationParent.cpp',
     'Presentation.cpp',
     'PresentationAvailability.cpp',
     'PresentationCallbacks.cpp',
+    'PresentationConnection.cpp',
     'PresentationDeviceManager.cpp',
     'PresentationReceiver.cpp',
     'PresentationRequest.cpp',
     'PresentationService.cpp',
-    'PresentationSession.cpp',
     'PresentationSessionInfo.cpp',
     'PresentationSessionRequest.cpp',
     'PresentationSessionTransport.cpp',
 ]
 
 EXTRA_COMPONENTS += [
     'PresentationDeviceInfoManager.js',
     'PresentationDeviceInfoManager.manifest',
--- a/dom/webidl/Presentation.webidl
+++ b/dom/webidl/Presentation.webidl
@@ -4,18 +4,18 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
 [Pref="dom.presentation.enabled",
  CheckAnyPermissions="presentation"]
 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).
   */
   attribute PresentationRequest? defaultRequest;
 
   /*
    * This should be available on the receiving browsing context in order to
rename from dom/webidl/PresentationSession.webidl
rename to dom/webidl/PresentationConnection.webidl
--- a/dom/webidl/PresentationSession.webidl
+++ b/dom/webidl/PresentationConnection.webidl
@@ -1,43 +1,43 @@
 /* -*- 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/.
  */
 
-enum PresentationSessionState
+enum PresentationConnectionState
 {
   // Existing presentation, and the communication channel is active.
   "connected",
 
   // Existing presentation, but the communication channel is inactive.
   "closed",
 
   // The presentation is nonexistent anymore. It could be terminated manually,
   // or either controlling or receiving browsing context is no longer available.
   "terminated"
 };
 
 [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;
 
   /*
    * @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;
 
   /*
    * After a communication channel has been established between the controlling
    * and receiving context, this function is called to send message out, and the
    * event handler "onmessage" will be invoked at the remote side.
    *
@@ -50,26 +50,26 @@ interface PresentationSession : EventTar
   void send(DOMString data);
 
   /*
    * It is triggered when receiving messages.
    */
   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".
    */
   // TODO Bug 1210340 - Support close semantics.
   // [Throws]
   // 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".
    */
    [Throws]
    void terminate();
 };
rename from dom/webidl/PresentationSessionConnectEvent.webidl
rename to dom/webidl/PresentationConnectionAvailableEvent.webidl
--- a/dom/webidl/PresentationSessionConnectEvent.webidl
+++ b/dom/webidl/PresentationConnectionAvailableEvent.webidl
@@ -1,20 +1,20 @@
 /* -*- 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/.
  */
 
 [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;
 };
--- a/dom/webidl/PresentationReceiver.webidl
+++ b/dom/webidl/PresentationReceiver.webidl
@@ -3,25 +3,25 @@
  * 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.presentation.enabled",
  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;
 };
--- a/dom/webidl/PresentationRequest.webidl
+++ b/dom/webidl/PresentationRequest.webidl
@@ -4,43 +4,43 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
 [Constructor(DOMString url),
  Pref="dom.presentation.enabled",
  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:
    * - "OperationError": Unexpected error occurs.
    * - "NotFoundError":  No available device.
    * - "AbortError":     User dismiss/cancel the device prompt box.
    * - "NetworkError":   Failed to establish the control channel or data channel.
    * - "TimeoutError":   Presenting page takes too long to load.
    */
   [Throws]
-  Promise<PresentationSession> start();
+  Promise<PresentationConnection> start();
 
  /*
   * UA triggers device discovery mechanism periodically and monitor device
   * availability.
   *
   * The promise may be rejected duo to one of the following reasons:
   * - "NotSupportedError": Unable to continuously monitor the availability.
   */
   [Throws]
   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;
 };
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -369,20 +369,20 @@ WEBIDL_FILES = [
     'Plugin.webidl',
     'PluginArray.webidl',
     'PointerEvent.webidl',
     'PopupBoxObject.webidl',
     'Position.webidl',
     'PositionError.webidl',
     'Presentation.webidl',
     'PresentationAvailability.webidl',
+    'PresentationConnection.webidl',
     'PresentationDeviceInfoManager.webidl',
     'PresentationReceiver.webidl',
     'PresentationRequest.webidl',
-    'PresentationSession.webidl',
     'ProcessingInstruction.webidl',
     'ProfileTimelineMarker.webidl',
     'Promise.webidl',
     'PromiseDebugging.webidl',
     'RadioNodeList.webidl',
     'Range.webidl',
     'Rect.webidl',
     'Request.webidl',
@@ -796,17 +796,17 @@ GENERATED_EVENTS_WEBIDL_FILES = [
     'MozSmsEvent.webidl',
     'MozStkCommandEvent.webidl',
     'MozVoicemailEvent.webidl',
     'PageTransitionEvent.webidl',
     'PerformanceEntryEvent.webidl',
     'PluginCrashedEvent.webidl',
     'PopStateEvent.webidl',
     'PopupBlockedEvent.webidl',
-    'PresentationSessionConnectEvent.webidl',
+    'PresentationConnectionAvailableEvent.webidl',
     'ProgressEvent.webidl',
     'RecordErrorEvent.webidl',
     'ScrollViewChangeEvent.webidl',
     'SelectionStateChangedEvent.webidl',
     'StyleRuleChangeEvent.webidl',
     'StyleSheetApplicableStateChangeEvent.webidl',
     'StyleSheetChangeEvent.webidl',
     'TCPServerSocketEvent.webidl',