Backed out changeset e684bf18e5d9 (bug 1299040) for bad implicit conversion constructor bustage

CLOSED TREE
This commit is contained in:
Phil Ringnalda 2016-09-15 19:31:32 -07:00
Родитель abbb996008
Коммит 069b27b0aa
15 изменённых файлов: 152 добавлений и 378 удалений

Просмотреть файл

@ -10,11 +10,10 @@
#include "nsIPresentationService.h" #include "nsIPresentationService.h"
#include "nsIWebProgress.h" #include "nsIWebProgress.h"
#include "nsServiceManagerUtils.h" #include "nsServiceManagerUtils.h"
#include "nsThreadUtils.h"
#include "PresentationCallbacks.h" #include "PresentationCallbacks.h"
#include "PresentationRequest.h" #include "PresentationRequest.h"
#include "PresentationConnection.h" #include "PresentationConnection.h"
#include "PresentationTransportBuilderConstructor.h" #include "nsThreadUtils.h"
using namespace mozilla; using namespace mozilla;
using namespace mozilla::dom; using namespace mozilla::dom;
@ -202,11 +201,7 @@ PresentationResponderLoadingCallback::NotifyReceiverReady(bool aIsLoading)
return NS_ERROR_NOT_AVAILABLE; return NS_ERROR_NOT_AVAILABLE;
} }
nsCOMPtr<nsIPresentationTransportBuilderConstructor> constructor = return service->NotifyReceiverReady(mSessionId, windowId, aIsLoading);
PresentationTransportBuilderConstructor::Create();
return service->NotifyReceiverReady(mSessionId,
windowId,aIsLoading,
constructor);
} }
// nsIWebProgressListener // nsIWebProgressListener

Просмотреть файл

@ -48,8 +48,7 @@ function PresentationTransportBuilder() {
PresentationTransportBuilder.prototype = { PresentationTransportBuilder.prototype = {
classID: PRESENTATIONTRANSPORTBUILDER_CID, classID: PRESENTATIONTRANSPORTBUILDER_CID,
contractID: PRESENTATIONTRANSPORTBUILDER_CONTRACTID, contractID: PRESENTATIONTRANSPORTBUILDER_CONTRACTID,
QueryInterface: XPCOMUtils.generateQI([Ci.nsIPresentationSessionTransportBuilder, QueryInterface: XPCOMUtils.generateQI([Ci.nsIPresentationDataChannelSessionTransportBuilder,
Ci.nsIPresentationDataChannelSessionTransportBuilder,
Ci.nsITimerCallback]), Ci.nsITimerCallback]),
buildDataChannelTransport: function(aRole, aWindow, aListener) { buildDataChannelTransport: function(aRole, aWindow, aListener) {

Просмотреть файл

@ -26,7 +26,6 @@
#include "PresentationAvailability.h" #include "PresentationAvailability.h"
#include "PresentationCallbacks.h" #include "PresentationCallbacks.h"
#include "PresentationLog.h" #include "PresentationLog.h"
#include "PresentationTransportBuilderConstructor.h"
using namespace mozilla; using namespace mozilla;
using namespace mozilla::dom; using namespace mozilla::dom;
@ -208,16 +207,7 @@ PresentationRequest::StartWithDevice(const nsAString& aDeviceId,
do_QueryInterface(GetOwner()->GetChromeEventHandler()); do_QueryInterface(GetOwner()->GetChromeEventHandler());
nsCOMPtr<nsIPresentationServiceCallback> callback = nsCOMPtr<nsIPresentationServiceCallback> callback =
new PresentationRequesterCallback(this, id, promise); new PresentationRequesterCallback(this, id, promise);
nsCOMPtr<nsIPresentationTransportBuilderConstructor> constructor = rv = service->StartSession(mUrls, id, origin, aDeviceId, GetOwner()->WindowID(), handler, callback);
PresentationTransportBuilderConstructor::Create();
rv = service->StartSession(mUrls,
id,
origin,
aDeviceId,
GetOwner()->WindowID(),
handler,
callback,
constructor);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
promise->MaybeReject(NS_ERROR_DOM_OPERATION_ERR); promise->MaybeReject(NS_ERROR_DOM_OPERATION_ERR);
} }

Просмотреть файл

@ -107,14 +107,12 @@ public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSIPRESENTATIONDEVICEREQUEST NS_DECL_NSIPRESENTATIONDEVICEREQUEST
PresentationDeviceRequest( PresentationDeviceRequest(const nsTArray<nsString>& aUrls,
const nsTArray<nsString>& aUrls,
const nsAString& aId, const nsAString& aId,
const nsAString& aOrigin, const nsAString& aOrigin,
uint64_t aWindowId, uint64_t aWindowId,
nsIDOMEventTarget* aEventTarget, nsIDOMEventTarget* aEventTarget,
nsIPresentationServiceCallback* aCallback, nsIPresentationServiceCallback* aCallback);
nsIPresentationTransportBuilderConstructor* aBuilderConstructor);
private: private:
virtual ~PresentationDeviceRequest() = default; virtual ~PresentationDeviceRequest() = default;
@ -127,7 +125,6 @@ private:
uint64_t mWindowId; uint64_t mWindowId;
nsWeakPtr mChromeEventHandler; nsWeakPtr mChromeEventHandler;
nsCOMPtr<nsIPresentationServiceCallback> mCallback; nsCOMPtr<nsIPresentationServiceCallback> mCallback;
nsCOMPtr<nsIPresentationTransportBuilderConstructor> mBuilderConstructor;
}; };
LazyLogModule gPresentationLog("Presentation"); LazyLogModule gPresentationLog("Presentation");
@ -143,21 +140,18 @@ PresentationDeviceRequest::PresentationDeviceRequest(
const nsAString& aOrigin, const nsAString& aOrigin,
uint64_t aWindowId, uint64_t aWindowId,
nsIDOMEventTarget* aEventTarget, nsIDOMEventTarget* aEventTarget,
nsIPresentationServiceCallback* aCallback, nsIPresentationServiceCallback* aCallback)
nsIPresentationTransportBuilderConstructor* aBuilderConstructor)
: mRequestUrls(aUrls) : mRequestUrls(aUrls)
, mId(aId) , mId(aId)
, mOrigin(aOrigin) , mOrigin(aOrigin)
, mWindowId(aWindowId) , mWindowId(aWindowId)
, mChromeEventHandler(do_GetWeakReference(aEventTarget)) , mChromeEventHandler(do_GetWeakReference(aEventTarget))
, mCallback(aCallback) , mCallback(aCallback)
, mBuilderConstructor(aBuilderConstructor)
{ {
MOZ_ASSERT(!mRequestUrls.IsEmpty()); MOZ_ASSERT(!mRequestUrls.IsEmpty());
MOZ_ASSERT(!mId.IsEmpty()); MOZ_ASSERT(!mId.IsEmpty());
MOZ_ASSERT(!mOrigin.IsEmpty()); MOZ_ASSERT(!mOrigin.IsEmpty());
MOZ_ASSERT(mCallback); MOZ_ASSERT(mCallback);
MOZ_ASSERT(mBuilderConstructor);
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -247,7 +241,6 @@ PresentationDeviceRequest::CreateSessionInfo(
return info->ReplyError(NS_ERROR_DOM_OPERATION_ERR); return info->ReplyError(NS_ERROR_DOM_OPERATION_ERR);
} }
info->SetTransportBuilderConstructor(mBuilderConstructor);
return NS_OK; return NS_OK;
} }
@ -649,15 +642,13 @@ PresentationService::IsAppInstalled(nsIURI* aUri)
} }
NS_IMETHODIMP NS_IMETHODIMP
PresentationService::StartSession( PresentationService::StartSession(const nsTArray<nsString>& aUrls,
const nsTArray<nsString>& aUrls,
const nsAString& aSessionId, const nsAString& aSessionId,
const nsAString& aOrigin, const nsAString& aOrigin,
const nsAString& aDeviceId, const nsAString& aDeviceId,
uint64_t aWindowId, uint64_t aWindowId,
nsIDOMEventTarget* aEventTarget, nsIDOMEventTarget* aEventTarget,
nsIPresentationServiceCallback* aCallback, nsIPresentationServiceCallback* aCallback)
nsIPresentationTransportBuilderConstructor* aBuilderConstructor)
{ {
PRES_DEBUG("%s:id[%s]\n", __func__, NS_ConvertUTF16toUTF8(aSessionId).get()); PRES_DEBUG("%s:id[%s]\n", __func__, NS_ConvertUTF16toUTF8(aSessionId).get());
@ -672,8 +663,7 @@ PresentationService::StartSession(
aOrigin, aOrigin,
aWindowId, aWindowId,
aEventTarget, aEventTarget,
aCallback, aCallback);
aBuilderConstructor);
if (aDeviceId.IsVoid()) { if (aDeviceId.IsVoid()) {
// Pop up a prompt and ask user to select a device. // Pop up a prompt and ask user to select a device.
@ -955,6 +945,28 @@ PresentationService::UnregisterSessionListener(const nsAString& aSessionId,
return NS_OK; return NS_OK;
} }
nsresult
PresentationService::RegisterTransportBuilder(const nsAString& aSessionId,
uint8_t aRole,
nsIPresentationSessionTransportBuilder* aBuilder)
{
PRES_DEBUG("%s:id[%s], role[%d]\n", __func__,
NS_ConvertUTF16toUTF8(aSessionId).get(), aRole);
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aBuilder);
MOZ_ASSERT(aRole == nsIPresentationService::ROLE_CONTROLLER ||
aRole == nsIPresentationService::ROLE_RECEIVER);
RefPtr<PresentationSessionInfo> info = GetSessionInfo(aSessionId, aRole);
if (NS_WARN_IF(!info)) {
return NS_ERROR_NOT_AVAILABLE;
}
info->SetBuilder(aBuilder);
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
PresentationService::RegisterRespondingListener( PresentationService::RegisterRespondingListener(
uint64_t aWindowId, uint64_t aWindowId,
@ -997,11 +1009,9 @@ PresentationService::UnregisterRespondingListener(uint64_t aWindowId)
} }
NS_IMETHODIMP NS_IMETHODIMP
PresentationService::NotifyReceiverReady( PresentationService::NotifyReceiverReady(const nsAString& aSessionId,
const nsAString& aSessionId,
uint64_t aWindowId, uint64_t aWindowId,
bool aIsLoading, bool aIsLoading)
nsIPresentationTransportBuilderConstructor* aBuilderConstructor)
{ {
PRES_DEBUG("%s:id[%s], windowId[%lld], loading[%d]\n", __func__, PRES_DEBUG("%s:id[%s], windowId[%lld], loading[%d]\n", __func__,
NS_ConvertUTF16toUTF8(aSessionId).get(), aWindowId, aIsLoading); NS_ConvertUTF16toUTF8(aSessionId).get(), aWindowId, aIsLoading);
@ -1029,7 +1039,6 @@ PresentationService::NotifyReceiverReady(
} }
} }
info->SetTransportBuilderConstructor(aBuilderConstructor);
return static_cast<PresentationPresentingInfo*>(info.get())->NotifyResponderReady(); return static_cast<PresentationPresentingInfo*>(info.get())->NotifyResponderReady();
} }

Просмотреть файл

@ -56,6 +56,10 @@ public:
const uint8_t aRole, const uint8_t aRole,
base::ProcessId aProcessId); base::ProcessId aProcessId);
nsresult RegisterTransportBuilder(const nsAString& aSessionId,
uint8_t aRole,
nsIPresentationSessionTransportBuilder* aBuilder);
private: private:
friend class PresentationDeviceRequest; friend class PresentationDeviceRequest;

Просмотреть файл

@ -241,7 +241,7 @@ PresentationSessionInfo::Shutdown(nsresult aReason)
mIsResponderReady = false; mIsResponderReady = false;
mIsOnTerminating = false; mIsOnTerminating = false;
ResetBuilder(); SetBuilder(nullptr);
} }
nsresult nsresult
@ -379,12 +379,7 @@ PresentationSessionInfo::GetWindow()
return nullptr; return nullptr;
} }
auto window = nsGlobalWindow::GetInnerWindowWithId(windowId); return nsGlobalWindow::GetInnerWindowWithId(windowId)->AsInner();
if (!window) {
return nullptr;
}
return window->AsInner();
} }
/* virtual */ bool /* virtual */ bool
@ -497,7 +492,7 @@ PresentationSessionInfo::OnSessionTransport(nsIPresentationSessionTransport* tra
PRES_DEBUG("%s:id[%s], role[%d], state[%d]\n", __func__, PRES_DEBUG("%s:id[%s], role[%d], state[%d]\n", __func__,
NS_ConvertUTF16toUTF8(mSessionId).get(), mRole, mState); NS_ConvertUTF16toUTF8(mSessionId).get(), mRole, mState);
ResetBuilder(); SetBuilder(nullptr);
if (mState != nsIPresentationSessionListener::STATE_CONNECTING) { if (mState != nsIPresentationSessionListener::STATE_CONNECTING) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -528,7 +523,7 @@ PresentationSessionInfo::OnError(nsresult aReason)
PRES_DEBUG("%s:id[%s], reason[%x], role[%d]\n", __func__, PRES_DEBUG("%s:id[%s], reason[%x], role[%d]\n", __func__,
NS_ConvertUTF16toUTF8(mSessionId).get(), aReason, mRole); NS_ConvertUTF16toUTF8(mSessionId).get(), aReason, mRole);
ResetBuilder(); SetBuilder(nullptr);
return ReplyError(aReason); return ReplyError(aReason);
} }
@ -832,44 +827,45 @@ PresentationControllingInfo::BuildTransport()
return NS_OK; return NS_OK;
} }
if (NS_WARN_IF(!mBuilderConstructor)) {
return NS_ERROR_NOT_AVAILABLE;
}
if (!Preferences::GetBool("dom.presentation.session_transport.data_channel.enable")) { if (!Preferences::GetBool("dom.presentation.session_transport.data_channel.enable")) {
// Build TCP session transport // Build TCP session transport
return GetAddress(); return GetAddress();
} }
nsPIDOMWindowInner* window = nullptr;
/** /**
* Generally transport is maintained by the chrome process. However, data * Generally transport is maintained by the chrome process. However, data
* channel should be live with the DOM , which implies RTCDataChannel in an OOP * channel should be live with the DOM , which implies RTCDataChannel in an OOP
* page should be establish in the content process. * page should be establish in the content process.
* *
* |mBuilderConstructor| is responsible for creating a builder, which is for * In OOP data channel transport case, |mBuilder| is hooked when the content
* building a data channel transport. * process is ready to build a data channel transport, trigger by:
* 1. PresentationIPCService::StartSession (sender)
* 2. PresentationIPCService::NotifyReceiverReady (receiver).
* *
* In the OOP case, |mBuilderConstructor| would create a builder which is * In this case, |mBuilder| would be an object of |PresentationBuilderParent|
* an object of |PresentationBuilderParent|. So, |BuildDataChannelTransport| * and set previously. Therefore, |BuildDataChannelTransport| triggers an IPC
* triggers an IPC call to make content process establish a RTCDataChannel * call to make content process establish a RTCDataChannel transport.
* transport.
*/ */
// in-process case
mTransportType = nsIPresentationChannelDescription::TYPE_DATACHANNEL; if (!mBuilder) {
if (NS_WARN_IF(NS_FAILED( nsCOMPtr<nsIPresentationDataChannelSessionTransportBuilder> builder =
mBuilderConstructor->CreateTransportBuilder(mTransportType, do_CreateInstance("@mozilla.org/presentation/datachanneltransportbuilder;1");
getter_AddRefs(mBuilder))))) { if (NS_WARN_IF(!builder)) {
return NS_ERROR_NOT_AVAILABLE; return NS_ERROR_NOT_AVAILABLE;
} }
SetBuilder(builder);
// OOP window would be set from content process
window = GetWindow();
}
// OOP case
mTransportType = nsIPresentationChannelDescription::TYPE_DATACHANNEL;
nsCOMPtr<nsIPresentationDataChannelSessionTransportBuilder> nsCOMPtr<nsIPresentationDataChannelSessionTransportBuilder>
dataChannelBuilder(do_QueryInterface(mBuilder)); dataChannelBuilder(do_QueryInterface(mBuilder));
if (NS_WARN_IF(!dataChannelBuilder)) { if (NS_WARN_IF(!dataChannelBuilder)) {
return NS_ERROR_NOT_AVAILABLE; return NS_ERROR_NOT_AVAILABLE;
} }
// OOP window would be set from content process
nsPIDOMWindowInner* window = GetWindow();
nsresult rv = dataChannelBuilder-> nsresult rv = dataChannelBuilder->
BuildDataChannelTransport(nsIPresentationService::ROLE_CONTROLLER, BuildDataChannelTransport(nsIPresentationService::ROLE_CONTROLLER,
window, window,
@ -877,7 +873,6 @@ PresentationControllingInfo::BuildTransport()
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }
return NS_OK; return NS_OK;
} }
@ -928,18 +923,9 @@ PresentationControllingInfo::OnSocketAccepted(nsIServerSocket* aServerSocket,
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
if (NS_WARN_IF(!mBuilderConstructor)) {
return ReplyError(NS_ERROR_DOM_OPERATION_ERR);
}
// Initialize session transport builder and use |this| as the callback. // Initialize session transport builder and use |this| as the callback.
nsCOMPtr<nsIPresentationTCPSessionTransportBuilder> builder; nsCOMPtr<nsIPresentationTCPSessionTransportBuilder> builder =
if (NS_SUCCEEDED(mBuilderConstructor->CreateTransportBuilder( do_CreateInstance(PRESENTATION_TCP_SESSION_TRANSPORT_CONTRACTID);
nsIPresentationChannelDescription::TYPE_TCP,
getter_AddRefs(mBuilder)))) {
builder = do_QueryInterface(mBuilder);
}
if (NS_WARN_IF(!builder)) { if (NS_WARN_IF(!builder)) {
return ReplyError(NS_ERROR_DOM_OPERATION_ERR); return ReplyError(NS_ERROR_DOM_OPERATION_ERR);
} }
@ -1149,7 +1135,6 @@ PresentationPresentingInfo::Shutdown(nsresult aReason)
mRequesterDescription = nullptr; mRequesterDescription = nullptr;
mPendingCandidates.Clear(); mPendingCandidates.Clear();
mPromise = nullptr; mPromise = nullptr;
mHasFlushPendingEvents = false;
} }
// nsIPresentationSessionTransportBuilderListener // nsIPresentationSessionTransportBuilderListener
@ -1227,25 +1212,16 @@ PresentationPresentingInfo::InitTransportAndSendAnswer()
return rv; return rv;
} }
if (NS_WARN_IF(!mBuilderConstructor)) {
return ReplyError(NS_ERROR_DOM_OPERATION_ERR);
}
if (NS_WARN_IF(NS_FAILED(
mBuilderConstructor->CreateTransportBuilder(type,
getter_AddRefs(mBuilder))))) {
return NS_ERROR_NOT_AVAILABLE;
}
if (type == nsIPresentationChannelDescription::TYPE_TCP) { if (type == nsIPresentationChannelDescription::TYPE_TCP) {
// Establish a data transport channel |mTransport| to the sender and use // Establish a data transport channel |mTransport| to the sender and use
// |this| as the callback. // |this| as the callback.
nsCOMPtr<nsIPresentationTCPSessionTransportBuilder> builder = nsCOMPtr<nsIPresentationTCPSessionTransportBuilder> builder =
do_QueryInterface(mBuilder); do_CreateInstance(PRESENTATION_TCP_SESSION_TRANSPORT_CONTRACTID);
if (NS_WARN_IF(!builder)) { if (NS_WARN_IF(!builder)) {
return NS_ERROR_NOT_AVAILABLE; return NS_ERROR_NOT_AVAILABLE;
} }
SetBuilder(builder);
mTransportType = nsIPresentationChannelDescription::TYPE_TCP; mTransportType = nsIPresentationChannelDescription::TYPE_TCP;
return builder->BuildTCPReceiverTransport(mRequesterDescription, this); return builder->BuildTCPReceiverTransport(mRequesterDescription, this);
} }
@ -1254,30 +1230,43 @@ PresentationPresentingInfo::InitTransportAndSendAnswer()
if (!Preferences::GetBool("dom.presentation.session_transport.data_channel.enable")) { if (!Preferences::GetBool("dom.presentation.session_transport.data_channel.enable")) {
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
nsPIDOMWindowInner* window = nullptr;
/** /**
* Generally transport is maintained by the chrome process. However, data * Generally transport is maintained by the chrome process. However, data
* channel should be live with the DOM , which implies RTCDataChannel in an OOP * channel should be live with the DOM , which implies RTCDataChannel in an OOP
* page should be establish in the content process. * page should be establish in the content process.
* *
* |mBuilderConstructor| is responsible for creating a builder, which is for * In OOP data channel transport case, |mBuilder| is hooked when the content
* building a data channel transport. * process is ready to build a data channel transport, trigger by:
* 1. PresentationIPCService::StartSession (sender)
* 2. PresentationIPCService::NotifyReceiverReady (receiver).
* *
* In the OOP case, |mBuilderConstructor| would create a builder which is * In this case, |mBuilder| would be an object of |PresentationBuilderParent|
* an object of |PresentationBuilderParent|. So, |BuildDataChannelTransport| * and set previously. Therefore, |BuildDataChannelTransport| triggers an IPC
* triggers an IPC call to make content process establish a RTCDataChannel * call to make content process establish a RTCDataChannel transport.
* transport.
*/ */
// in-process case
if (!mBuilder) {
nsCOMPtr<nsIPresentationDataChannelSessionTransportBuilder> builder =
do_CreateInstance("@mozilla.org/presentation/datachanneltransportbuilder;1");
mTransportType = nsIPresentationChannelDescription::TYPE_DATACHANNEL; if (NS_WARN_IF(!builder)) {
nsCOMPtr<nsIPresentationDataChannelSessionTransportBuilder> dataChannelBuilder =
do_QueryInterface(mBuilder);
if (NS_WARN_IF(!dataChannelBuilder)) {
return NS_ERROR_NOT_AVAILABLE; return NS_ERROR_NOT_AVAILABLE;
} }
nsPIDOMWindowInner* window = GetWindow(); SetBuilder(builder);
// OOP window would be set from content process
window = GetWindow();
}
mTransportType = nsIPresentationChannelDescription::TYPE_DATACHANNEL;
nsCOMPtr<nsIPresentationDataChannelSessionTransportBuilder>
dataChannelBuilder(do_QueryInterface(mBuilder));
if (NS_WARN_IF(!dataChannelBuilder)) {
return NS_ERROR_NOT_AVAILABLE;
}
rv = dataChannelBuilder-> rv = dataChannelBuilder->
BuildDataChannelTransport(nsIPresentationService::ROLE_RECEIVER, BuildDataChannelTransport(nsIPresentationService::ROLE_RECEIVER,
window, window,
@ -1286,11 +1275,11 @@ PresentationPresentingInfo::InitTransportAndSendAnswer()
return rv; return rv;
} }
rv = FlushPendingEvents(dataChannelBuilder);
rv = this->FlushPendingEvents(dataChannelBuilder);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -79,6 +79,11 @@ public:
mDevice = aDevice; mDevice = aDevice;
} }
void SetBuilder(nsIPresentationSessionTransportBuilder* aBuilder)
{
mBuilder = aBuilder;
}
already_AddRefed<nsIPresentationDevice> GetDevice() const already_AddRefed<nsIPresentationDevice> GetDevice() const
{ {
nsCOMPtr<nsIPresentationDevice> device = mDevice; nsCOMPtr<nsIPresentationDevice> device = mDevice;
@ -108,12 +113,6 @@ public:
virtual bool IsAccessible(base::ProcessId aProcessId); virtual bool IsAccessible(base::ProcessId aProcessId);
void SetTransportBuilderConstructor(
nsIPresentationTransportBuilderConstructor* aBuilderConstructor)
{
mBuilderConstructor = aBuilderConstructor;
}
protected: protected:
virtual ~PresentationSessionInfo() virtual ~PresentationSessionInfo()
{ {
@ -150,11 +149,6 @@ protected:
void ContinueTermination(); void ContinueTermination();
void ResetBuilder()
{
mBuilder = nullptr;
}
// Should be nsIPresentationChannelDescription::TYPE_TCP/TYPE_DATACHANNEL // Should be nsIPresentationChannelDescription::TYPE_TCP/TYPE_DATACHANNEL
uint8_t mTransportType = 0; uint8_t mTransportType = 0;
@ -175,7 +169,6 @@ protected:
nsCOMPtr<nsIPresentationSessionTransport> mTransport; nsCOMPtr<nsIPresentationSessionTransport> mTransport;
nsCOMPtr<nsIPresentationControlChannel> mControlChannel; nsCOMPtr<nsIPresentationControlChannel> mControlChannel;
nsCOMPtr<nsIPresentationSessionTransportBuilder> mBuilder; nsCOMPtr<nsIPresentationSessionTransportBuilder> mBuilder;
nsCOMPtr<nsIPresentationTransportBuilderConstructor> mBuilderConstructor;
}; };
// Session info with controlling browsing context (sender side) behaviors. // Session info with controlling browsing context (sender side) behaviors.

Просмотреть файл

@ -1,85 +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 "PresentationTransportBuilderConstructor.h"
#include "nsComponentManagerUtils.h"
#include "nsIPresentationControlChannel.h"
#include "nsIPresentationSessionTransport.h"
#include "nsXULAppAPI.h"
namespace mozilla {
namespace dom {
NS_IMPL_ISUPPORTS(DummyPresentationTransportBuilderConstructor,
nsIPresentationTransportBuilderConstructor)
NS_IMETHODIMP
DummyPresentationTransportBuilderConstructor::CreateTransportBuilder(
uint8_t aType,
nsIPresentationSessionTransportBuilder** aRetval)
{
MOZ_ASSERT(false, "Unexpected to be invoked.");
return NS_OK;
}
NS_IMPL_ISUPPORTS_INHERITED0(PresentationTransportBuilderConstructor,
DummyPresentationTransportBuilderConstructor)
/* static */ already_AddRefed<nsIPresentationTransportBuilderConstructor>
PresentationTransportBuilderConstructor::Create()
{
nsCOMPtr<nsIPresentationTransportBuilderConstructor> constructor;
if (XRE_IsContentProcess()) {
constructor = new DummyPresentationTransportBuilderConstructor();
} else {
constructor = new PresentationTransportBuilderConstructor();
}
return constructor.forget();
}
NS_IMETHODIMP
PresentationTransportBuilderConstructor::CreateTransportBuilder(
uint8_t aType,
nsIPresentationSessionTransportBuilder** aRetval)
{
if (NS_WARN_IF(!aRetval)) {
return NS_ERROR_INVALID_ARG;
}
*aRetval = nullptr;
if (NS_WARN_IF(aType != nsIPresentationChannelDescription::TYPE_TCP &&
aType != nsIPresentationChannelDescription::TYPE_DATACHANNEL)) {
return NS_ERROR_INVALID_ARG;
}
if (XRE_IsContentProcess()) {
MOZ_ASSERT(false,
"CreateTransportBuilder can only be invoked in parent process.");
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIPresentationSessionTransportBuilder> builder;
if (aType == nsIPresentationChannelDescription::TYPE_TCP) {
builder =
do_CreateInstance(PRESENTATION_TCP_SESSION_TRANSPORT_CONTRACTID);
} else {
builder =
do_CreateInstance("@mozilla.org/presentation/datachanneltransportbuilder;1");
}
if (NS_WARN_IF(!builder)) {
return NS_ERROR_DOM_OPERATION_ERR;
}
builder.forget(aRetval);
return NS_OK;
}
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -1,48 +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_PresentationTransportBuilderConstructor_h
#define mozilla_dom_PresentationTransportBuilderConstructor_h
#include "nsCOMPtr.h"
#include "nsIPresentationSessionTransportBuilder.h"
#include "nsISupportsImpl.h"
namespace mozilla {
namespace dom {
class DummyPresentationTransportBuilderConstructor :
public nsIPresentationTransportBuilderConstructor
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIPRESENTATIONTRANSPORTBUILDERCONSTRUCTOR
DummyPresentationTransportBuilderConstructor() = default;
protected:
virtual ~DummyPresentationTransportBuilderConstructor() = default;
};
class PresentationTransportBuilderConstructor final :
public DummyPresentationTransportBuilderConstructor
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIPRESENTATIONTRANSPORTBUILDERCONSTRUCTOR
static already_AddRefed<nsIPresentationTransportBuilderConstructor>
Create();
private:
PresentationTransportBuilderConstructor() = default;
virtual ~PresentationTransportBuilderConstructor() = default;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_PresentationTransportBuilderConstructor_h

Просмотреть файл

@ -9,7 +9,6 @@ interface nsIInputStream;
interface nsIPresentationAvailabilityListener; interface nsIPresentationAvailabilityListener;
interface nsIPresentationRespondingListener; interface nsIPresentationRespondingListener;
interface nsIPresentationSessionListener; interface nsIPresentationSessionListener;
interface nsIPresentationTransportBuilderConstructor;
%{C++ %{C++
#define PRESENTATION_SERVICE_CID \ #define PRESENTATION_SERVICE_CID \
@ -73,7 +72,6 @@ interface nsIPresentationService : nsISupports
* NotifySuccess() is called with |id| if a session is * NotifySuccess() is called with |id| if a session is
* established successfully with the selected device. * established successfully with the selected device.
* Otherwise, NotifyError() is called with a error message. * Otherwise, NotifyError() is called with a error message.
* @param constructor: The constructor for creating a transport builder.
*/ */
[noscript] void startSession(in URLArrayRef urls, [noscript] void startSession(in URLArrayRef urls,
in DOMString sessionId, in DOMString sessionId,
@ -81,8 +79,7 @@ interface nsIPresentationService : nsISupports
in DOMString deviceId, in DOMString deviceId,
in unsigned long long windowId, in unsigned long long windowId,
in nsIDOMEventTarget eventTarget, in nsIDOMEventTarget eventTarget,
in nsIPresentationServiceCallback callback, in nsIPresentationServiceCallback callback);
in nsIPresentationTransportBuilderConstructor constructor);
/* /*
* Send the message to the session. * Send the message to the session.
@ -184,12 +181,10 @@ interface nsIPresentationService : nsISupports
* @param windowId The inner window ID associated with the presentation * @param windowId The inner window ID associated with the presentation
* session. * session.
* @param isLoading true if receiver page is loading successfully. * @param isLoading true if receiver page is loading successfully.
* @param constructor: The constructor for creating a transport builder.
*/ */
void notifyReceiverReady(in DOMString sessionId, void notifyReceiverReady(in DOMString sessionId,
in unsigned long long windowId, in unsigned long long windowId,
in boolean isLoading, in boolean isLoading);
in nsIPresentationTransportBuilderConstructor constructor);
/* /*
* Notify the transport is closed * Notify the transport is closed

Просмотреть файл

@ -28,15 +28,6 @@ interface nsIPresentationSessionTransportBuilder : nsISupports
{ {
}; };
/**
* The constructor for creating a transport builder.
*/
[scriptable, uuid(706482b2-1b51-4bed-a21d-785a9cfcfac7)]
interface nsIPresentationTransportBuilderConstructor : nsISupports
{
nsIPresentationSessionTransportBuilder createTransportBuilder(in uint8_t type);
};
/** /**
* Builder for TCP session transport * Builder for TCP session transport
*/ */

Просмотреть файл

@ -54,15 +54,13 @@ PresentationIPCService::~PresentationIPCService()
} }
NS_IMETHODIMP NS_IMETHODIMP
PresentationIPCService::StartSession( PresentationIPCService::StartSession(const nsTArray<nsString>& aUrls,
const nsTArray<nsString>& aUrls,
const nsAString& aSessionId, const nsAString& aSessionId,
const nsAString& aOrigin, const nsAString& aOrigin,
const nsAString& aDeviceId, const nsAString& aDeviceId,
uint64_t aWindowId, uint64_t aWindowId,
nsIDOMEventTarget* aEventTarget, nsIDOMEventTarget* aEventTarget,
nsIPresentationServiceCallback* aCallback, nsIPresentationServiceCallback* aCallback)
nsIPresentationTransportBuilderConstructor* aBuilderConstructor)
{ {
if (aWindowId != 0) { if (aWindowId != 0) {
AddRespondingSessionId(aWindowId, AddRespondingSessionId(aWindowId,
@ -380,11 +378,9 @@ PresentationIPCService::NotifyAvailableChange(bool aAvailable)
} }
NS_IMETHODIMP NS_IMETHODIMP
PresentationIPCService::NotifyReceiverReady( PresentationIPCService::NotifyReceiverReady(const nsAString& aSessionId,
const nsAString& aSessionId,
uint64_t aWindowId, uint64_t aWindowId,
bool aIsLoading, bool aIsLoading)
nsIPresentationTransportBuilderConstructor* aBuilderConstructor)
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());

Просмотреть файл

@ -9,78 +9,13 @@
#include "mozilla/ipc/InputStreamUtils.h" #include "mozilla/ipc/InputStreamUtils.h"
#include "mozilla/Unused.h" #include "mozilla/Unused.h"
#include "nsIPresentationDeviceManager.h" #include "nsIPresentationDeviceManager.h"
#include "nsIPresentationSessionTransport.h"
#include "nsIPresentationSessionTransportBuilder.h"
#include "nsServiceManagerUtils.h" #include "nsServiceManagerUtils.h"
#include "PresentationBuilderParent.h" #include "PresentationBuilderParent.h"
#include "PresentationParent.h" #include "PresentationParent.h"
#include "PresentationService.h" #include "PresentationService.h"
#include "PresentationSessionInfo.h" #include "PresentationSessionInfo.h"
namespace mozilla { using namespace mozilla::dom;
namespace dom {
namespace {
class PresentationTransportBuilderConstructorIPC final :
public nsIPresentationTransportBuilderConstructor
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIPRESENTATIONTRANSPORTBUILDERCONSTRUCTOR
PresentationTransportBuilderConstructorIPC(PresentationParent* aParent)
: mParent(aParent)
{
}
private:
virtual ~PresentationTransportBuilderConstructorIPC() = default;
RefPtr<PresentationParent> mParent;
};
NS_IMPL_ISUPPORTS(PresentationTransportBuilderConstructorIPC,
nsIPresentationTransportBuilderConstructor)
NS_IMETHODIMP
PresentationTransportBuilderConstructorIPC::CreateTransportBuilder(
uint8_t aType,
nsIPresentationSessionTransportBuilder** aRetval)
{
if (NS_WARN_IF(!aRetval)) {
return NS_ERROR_INVALID_ARG;
}
*aRetval = nullptr;
if (NS_WARN_IF(aType != nsIPresentationChannelDescription::TYPE_TCP &&
aType != nsIPresentationChannelDescription::TYPE_DATACHANNEL)) {
return NS_ERROR_INVALID_ARG;
}
if (XRE_IsContentProcess()) {
MOZ_ASSERT(false,
"CreateTransportBuilder can only be invoked in parent process.");
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIPresentationSessionTransportBuilder> builder;
if (aType == nsIPresentationChannelDescription::TYPE_TCP) {
builder = do_CreateInstance(PRESENTATION_TCP_SESSION_TRANSPORT_CONTRACTID);
} else {
builder = new PresentationBuilderParent(mParent);
}
if (NS_WARN_IF(!builder)) {
return NS_ERROR_DOM_OPERATION_ERR;
}
builder.forget(aRetval);
return NS_OK;
}
} // anonymous namespace
/* /*
* Implementation of PresentationParent * Implementation of PresentationParent
@ -282,6 +217,19 @@ PresentationParent::RecvUnregisterRespondingHandler(const uint64_t& aWindowId)
return true; return true;
} }
bool
PresentationParent::RegisterTransportBuilder(const nsString& aSessionId,
const uint8_t& aRole)
{
MOZ_ASSERT(mService);
nsCOMPtr<nsIPresentationSessionTransportBuilder> builder =
new PresentationBuilderParent(this);
Unused << NS_WARN_IF(NS_FAILED(static_cast<PresentationService*>(mService.get())->
RegisterTransportBuilder(aSessionId, aRole, builder)));
return true;
}
NS_IMETHODIMP NS_IMETHODIMP
PresentationParent::NotifyAvailableChange(bool aAvailable) PresentationParent::NotifyAvailableChange(bool aAvailable)
{ {
@ -342,12 +290,10 @@ PresentationParent::RecvNotifyReceiverReady(const nsString& aSessionId,
{ {
MOZ_ASSERT(mService); MOZ_ASSERT(mService);
nsCOMPtr<nsIPresentationTransportBuilderConstructor> constructor = RegisterTransportBuilder(aSessionId, nsIPresentationService::ROLE_RECEIVER);
new PresentationTransportBuilderConstructorIPC(this);
Unused << NS_WARN_IF(NS_FAILED(mService->NotifyReceiverReady(aSessionId, Unused << NS_WARN_IF(NS_FAILED(mService->NotifyReceiverReady(aSessionId,
aWindowId, aWindowId,
aIsLoading, aIsLoading)));
constructor)));
return true; return true;
} }
@ -392,7 +338,7 @@ nsresult
PresentationRequestParent::DoRequest(const StartSessionRequest& aRequest) PresentationRequestParent::DoRequest(const StartSessionRequest& aRequest)
{ {
MOZ_ASSERT(mService); MOZ_ASSERT(mService);
mNeedRegisterBuilder = true;
mSessionId = aRequest.sessionId(); mSessionId = aRequest.sessionId();
nsCOMPtr<nsIDOMEventTarget> eventTarget; nsCOMPtr<nsIDOMEventTarget> eventTarget;
@ -403,12 +349,9 @@ PresentationRequestParent::DoRequest(const StartSessionRequest& aRequest)
eventTarget = do_QueryInterface(tp->GetOwnerElement()); eventTarget = do_QueryInterface(tp->GetOwnerElement());
} }
RefPtr<PresentationParent> parent = static_cast<PresentationParent*>(Manager());
nsCOMPtr<nsIPresentationTransportBuilderConstructor> constructor =
new PresentationTransportBuilderConstructorIPC(parent);
return mService->StartSession(aRequest.urls(), aRequest.sessionId(), return mService->StartSession(aRequest.urls(), aRequest.sessionId(),
aRequest.origin(), aRequest.deviceId(), aRequest.origin(), aRequest.deviceId(),
aRequest.windowId(), eventTarget, this, constructor); aRequest.windowId(), eventTarget, this);
} }
nsresult nsresult
@ -487,6 +430,7 @@ PresentationRequestParent::DoRequest(const ReconnectSessionRequest& aRequest)
return SendResponse(NS_ERROR_DOM_NOT_FOUND_ERR); return SendResponse(NS_ERROR_DOM_NOT_FOUND_ERR);
} }
mNeedRegisterBuilder = true;
mSessionId = aRequest.sessionId(); mSessionId = aRequest.sessionId();
return mService->ReconnectSession(aRequest.urls(), return mService->ReconnectSession(aRequest.urls(),
aRequest.sessionId(), aRequest.sessionId(),
@ -516,6 +460,13 @@ PresentationRequestParent::DoRequest(const BuildTransportRequest& aRequest)
NS_IMETHODIMP NS_IMETHODIMP
PresentationRequestParent::NotifySuccess(const nsAString& aUrl) PresentationRequestParent::NotifySuccess(const nsAString& aUrl)
{ {
if (mNeedRegisterBuilder) {
RefPtr<PresentationParent> parent = static_cast<PresentationParent*>(Manager());
Unused << NS_WARN_IF(!parent->RegisterTransportBuilder(
mSessionId,
nsIPresentationService::ROLE_CONTROLLER));
}
Unused << SendNotifyRequestUrlSelected(nsString(aUrl)); Unused << SendNotifyRequestUrlSelected(nsString(aUrl));
return SendResponse(NS_OK); return SendResponse(NS_OK);
} }
@ -535,6 +486,3 @@ PresentationRequestParent::SendResponse(nsresult aResult)
return NS_OK; return NS_OK;
} }
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -55,7 +55,6 @@ UNIFIED_SOURCES += [
'PresentationSessionRequest.cpp', 'PresentationSessionRequest.cpp',
'PresentationTCPSessionTransport.cpp', 'PresentationTCPSessionTransport.cpp',
'PresentationTerminateRequest.cpp', 'PresentationTerminateRequest.cpp',
'PresentationTransportBuilderConstructor.cpp'
] ]
EXTRA_COMPONENTS += [ EXTRA_COMPONENTS += [

Просмотреть файл

@ -220,7 +220,6 @@ const mockedDevicePrompt = {
const mockedSessionTransport = { const mockedSessionTransport = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIPresentationSessionTransport, QueryInterface: XPCOMUtils.generateQI([Ci.nsIPresentationSessionTransport,
Ci.nsIPresentationSessionTransportBuilder,
Ci.nsIPresentationTCPSessionTransportBuilder, Ci.nsIPresentationTCPSessionTransportBuilder,
Ci.nsIPresentationDataChannelSessionTransportBuilder, Ci.nsIPresentationDataChannelSessionTransportBuilder,
Ci.nsIPresentationControlChannelListener, Ci.nsIPresentationControlChannelListener,