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

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

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

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

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

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

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

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

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

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

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

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

@ -79,6 +79,11 @@ public:
mDevice = aDevice;
}
void SetBuilder(nsIPresentationSessionTransportBuilder* aBuilder)
{
mBuilder = aBuilder;
}
already_AddRefed<nsIPresentationDevice> GetDevice() const
{
nsCOMPtr<nsIPresentationDevice> device = mDevice;
@ -108,12 +113,6 @@ public:
virtual bool IsAccessible(base::ProcessId aProcessId);
void SetTransportBuilderConstructor(
nsIPresentationTransportBuilderConstructor* aBuilderConstructor)
{
mBuilderConstructor = aBuilderConstructor;
}
protected:
virtual ~PresentationSessionInfo()
{
@ -150,11 +149,6 @@ protected:
void ContinueTermination();
void ResetBuilder()
{
mBuilder = nullptr;
}
// Should be nsIPresentationChannelDescription::TYPE_TCP/TYPE_DATACHANNEL
uint8_t mTransportType = 0;
@ -175,7 +169,6 @@ protected:
nsCOMPtr<nsIPresentationSessionTransport> mTransport;
nsCOMPtr<nsIPresentationControlChannel> mControlChannel;
nsCOMPtr<nsIPresentationSessionTransportBuilder> mBuilder;
nsCOMPtr<nsIPresentationTransportBuilderConstructor> mBuilderConstructor;
};
// 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 nsIPresentationRespondingListener;
interface nsIPresentationSessionListener;
interface nsIPresentationTransportBuilderConstructor;
%{C++
#define PRESENTATION_SERVICE_CID \
@ -73,7 +72,6 @@ interface nsIPresentationService : nsISupports
* NotifySuccess() is called with |id| if a session is
* established successfully with the selected device.
* Otherwise, NotifyError() is called with a error message.
* @param constructor: The constructor for creating a transport builder.
*/
[noscript] void startSession(in URLArrayRef urls,
in DOMString sessionId,
@ -81,8 +79,7 @@ interface nsIPresentationService : nsISupports
in DOMString deviceId,
in unsigned long long windowId,
in nsIDOMEventTarget eventTarget,
in nsIPresentationServiceCallback callback,
in nsIPresentationTransportBuilderConstructor constructor);
in nsIPresentationServiceCallback callback);
/*
* Send the message to the session.
@ -184,12 +181,10 @@ interface nsIPresentationService : nsISupports
* @param windowId The inner window ID associated with the presentation
* session.
* @param isLoading true if receiver page is loading successfully.
* @param constructor: The constructor for creating a transport builder.
*/
void notifyReceiverReady(in DOMString sessionId,
in unsigned long long windowId,
in boolean isLoading,
in nsIPresentationTransportBuilderConstructor constructor);
in boolean isLoading);
/*
* 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
*/

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

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

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

@ -9,78 +9,13 @@
#include "mozilla/ipc/InputStreamUtils.h"
#include "mozilla/Unused.h"
#include "nsIPresentationDeviceManager.h"
#include "nsIPresentationSessionTransport.h"
#include "nsIPresentationSessionTransportBuilder.h"
#include "nsServiceManagerUtils.h"
#include "PresentationBuilderParent.h"
#include "PresentationParent.h"
#include "PresentationService.h"
#include "PresentationSessionInfo.h"
namespace mozilla {
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
using namespace mozilla::dom;
/*
* Implementation of PresentationParent
@ -282,6 +217,19 @@ PresentationParent::RecvUnregisterRespondingHandler(const uint64_t& aWindowId)
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
PresentationParent::NotifyAvailableChange(bool aAvailable)
{
@ -342,12 +290,10 @@ PresentationParent::RecvNotifyReceiverReady(const nsString& aSessionId,
{
MOZ_ASSERT(mService);
nsCOMPtr<nsIPresentationTransportBuilderConstructor> constructor =
new PresentationTransportBuilderConstructorIPC(this);
RegisterTransportBuilder(aSessionId, nsIPresentationService::ROLE_RECEIVER);
Unused << NS_WARN_IF(NS_FAILED(mService->NotifyReceiverReady(aSessionId,
aWindowId,
aIsLoading,
constructor)));
aIsLoading)));
return true;
}
@ -392,7 +338,7 @@ nsresult
PresentationRequestParent::DoRequest(const StartSessionRequest& aRequest)
{
MOZ_ASSERT(mService);
mNeedRegisterBuilder = true;
mSessionId = aRequest.sessionId();
nsCOMPtr<nsIDOMEventTarget> eventTarget;
@ -402,13 +348,10 @@ PresentationRequestParent::DoRequest(const StartSessionRequest& aRequest)
if (tp) {
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(),
aRequest.origin(), aRequest.deviceId(),
aRequest.windowId(), eventTarget, this, constructor);
aRequest.windowId(), eventTarget, this);
}
nsresult
@ -487,6 +430,7 @@ PresentationRequestParent::DoRequest(const ReconnectSessionRequest& aRequest)
return SendResponse(NS_ERROR_DOM_NOT_FOUND_ERR);
}
mNeedRegisterBuilder = true;
mSessionId = aRequest.sessionId();
return mService->ReconnectSession(aRequest.urls(),
aRequest.sessionId(),
@ -516,6 +460,13 @@ PresentationRequestParent::DoRequest(const BuildTransportRequest& aRequest)
NS_IMETHODIMP
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));
return SendResponse(NS_OK);
}
@ -535,6 +486,3 @@ PresentationRequestParent::SendResponse(nsresult aResult)
return NS_OK;
}
} // namespace dom
} // namespace mozilla

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

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

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

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