зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1192101 - Part 3 - Support PresentationRequest / PresentationAvailability / getSession(s). Part 3 - Adjust errors. r=smaug
This commit is contained in:
Родитель
97f0121975
Коммит
2484876e88
|
@ -52,7 +52,7 @@ PresentationRequesterCallback::NotifySuccess()
|
|||
PresentationSession::Create(mRequest->GetOwner(), mSessionId,
|
||||
PresentationSessionState::Connected);
|
||||
if (NS_WARN_IF(!session)) {
|
||||
mPromise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
|
||||
mPromise->MaybeReject(NS_ERROR_DOM_OPERATION_ERR);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -108,13 +108,13 @@ PresentationDeviceRequest::Select(nsIPresentationDevice* aDevice)
|
|||
nsCOMPtr<nsIPresentationControlChannel> ctrlChannel;
|
||||
nsresult rv = aDevice->EstablishControlChannel(mRequestUrl, mId, getter_AddRefs(ctrlChannel));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return info->ReplyError(NS_ERROR_DOM_NETWORK_ERR);
|
||||
return info->ReplyError(NS_ERROR_DOM_OPERATION_ERR);
|
||||
}
|
||||
|
||||
// Initialize the session info with the control channel.
|
||||
rv = info->Init(ctrlChannel);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return info->ReplyError(NS_ERROR_DOM_NETWORK_ERR);
|
||||
return info->ReplyError(NS_ERROR_DOM_OPERATION_ERR);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -135,7 +135,7 @@ PresentationDeviceRequest::Cancel()
|
|||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
return info->ReplyError(NS_ERROR_DOM_PROP_ACCESS_DENIED);
|
||||
return info->ReplyError(NS_ERROR_DOM_ABORT_ERR);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -267,21 +267,21 @@ PresentationService::HandleSessionRequest(nsIPresentationSessionRequest* aReques
|
|||
nsAutoString url;
|
||||
rv = aRequest->GetUrl(url);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
ctrlChannel->Close(NS_ERROR_DOM_ABORT_ERR);
|
||||
ctrlChannel->Close(rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsAutoString sessionId;
|
||||
rv = aRequest->GetPresentationId(sessionId);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
ctrlChannel->Close(NS_ERROR_DOM_ABORT_ERR);
|
||||
ctrlChannel->Close(rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresentationDevice> device;
|
||||
rv = aRequest->GetDevice(getter_AddRefs(device));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
ctrlChannel->Close(NS_ERROR_DOM_ABORT_ERR);
|
||||
ctrlChannel->Close(rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -297,7 +297,7 @@ PresentationService::HandleSessionRequest(nsIPresentationSessionRequest* aReques
|
|||
bool isApp;
|
||||
rv = uri->SchemeIs("app", &isApp);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
ctrlChannel->Close(NS_ERROR_DOM_ABORT_ERR);
|
||||
ctrlChannel->Close(rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -310,15 +310,15 @@ PresentationService::HandleSessionRequest(nsIPresentationSessionRequest* aReques
|
|||
// Create or reuse session info.
|
||||
nsRefPtr<PresentationSessionInfo> info = GetSessionInfo(sessionId);
|
||||
if (NS_WARN_IF(info)) {
|
||||
// TODO Update here after session resumption becomes supported.
|
||||
ctrlChannel->Close(NS_ERROR_DOM_ABORT_ERR);
|
||||
// TODO Bug 1195605. Update here after session join/resume becomes supported.
|
||||
ctrlChannel->Close(NS_ERROR_DOM_OPERATION_ERR);
|
||||
return NS_ERROR_DOM_ABORT_ERR;
|
||||
}
|
||||
|
||||
info = new PresentationResponderInfo(url, sessionId, device);
|
||||
rv = info->Init(ctrlChannel);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
ctrlChannel->Close(NS_ERROR_DOM_ABORT_ERR);
|
||||
ctrlChannel->Close(rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -328,14 +328,14 @@ PresentationService::HandleSessionRequest(nsIPresentationSessionRequest* aReques
|
|||
nsCOMPtr<nsIPresentationRequestUIGlue> glue =
|
||||
do_CreateInstance(PRESENTATION_REQUEST_UI_GLUE_CONTRACTID);
|
||||
if (NS_WARN_IF(!glue)) {
|
||||
ctrlChannel->Close(NS_ERROR_DOM_ABORT_ERR);
|
||||
return info->ReplyError(NS_ERROR_NOT_AVAILABLE);
|
||||
ctrlChannel->Close(NS_ERROR_DOM_OPERATION_ERR);
|
||||
return info->ReplyError(NS_ERROR_DOM_OPERATION_ERR);
|
||||
}
|
||||
nsCOMPtr<nsISupports> promise;
|
||||
rv = glue->SendRequest(url, sessionId, getter_AddRefs(promise));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
ctrlChannel->Close(NS_ERROR_DOM_ABORT_ERR);
|
||||
return info->ReplyError(rv);
|
||||
ctrlChannel->Close(rv);
|
||||
return info->ReplyError(NS_ERROR_DOM_OPERATION_ERR);
|
||||
}
|
||||
nsCOMPtr<Promise> realPromise = do_QueryInterface(promise);
|
||||
static_cast<PresentationResponderInfo*>(info.get())->SetPromise(realPromise);
|
||||
|
@ -400,13 +400,13 @@ PresentationService::StartSession(const nsAString& aUrl,
|
|||
nsCOMPtr<nsIPresentationDevicePrompt> prompt =
|
||||
do_GetService(PRESENTATION_DEVICE_PROMPT_CONTRACTID);
|
||||
if (NS_WARN_IF(!prompt)) {
|
||||
return info->ReplyError(NS_ERROR_DOM_ABORT_ERR);
|
||||
return info->ReplyError(NS_ERROR_DOM_OPERATION_ERR);
|
||||
}
|
||||
nsCOMPtr<nsIPresentationDeviceRequest> request =
|
||||
new PresentationDeviceRequest(aUrl, aSessionId, aOrigin);
|
||||
nsresult rv = prompt->PromptDeviceSelection(request);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return info->ReplyError(NS_ERROR_DOM_ABORT_ERR);
|
||||
return info->ReplyError(NS_ERROR_DOM_OPERATION_ERR);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -142,6 +142,8 @@ PresentationSessionInfo::Init(nsIPresentationControlChannel* aControlChannel)
|
|||
/* virtual */ void
|
||||
PresentationSessionInfo::Shutdown(nsresult aReason)
|
||||
{
|
||||
NS_WARN_IF(NS_FAILED(aReason));
|
||||
|
||||
// Close the control channel if any.
|
||||
if (mControlChannel) {
|
||||
NS_WARN_IF(NS_FAILED(mControlChannel->Close(aReason)));
|
||||
|
@ -298,9 +300,9 @@ PresentationSessionInfo::NotifyTransportClosed(nsresult aReason)
|
|||
mTransport->SetCallback(nullptr);
|
||||
mTransport = nullptr;
|
||||
|
||||
if (!IsSessionReady()) {
|
||||
if (NS_WARN_IF(!IsSessionReady())) {
|
||||
// It happens before the session is ready. Reply the callback.
|
||||
return ReplyError(aReason);
|
||||
return ReplyError(NS_ERROR_DOM_OPERATION_ERR);
|
||||
}
|
||||
|
||||
// Unset |mIsTransportReady| here so it won't affect |IsSessionReady()| above.
|
||||
|
@ -375,7 +377,7 @@ PresentationRequesterInfo::Init(nsIPresentationControlChannel* aControlChannel)
|
|||
// use |this| as the listener.
|
||||
mServerSocket = do_CreateInstance(NS_SERVERSOCKET_CONTRACTID);
|
||||
if (NS_WARN_IF(!mServerSocket)) {
|
||||
return ReplyError(NS_ERROR_NOT_AVAILABLE);
|
||||
return ReplyError(NS_ERROR_DOM_OPERATION_ERR);
|
||||
}
|
||||
|
||||
nsresult rv = mServerSocket->Init(-1, false, -1);
|
||||
|
@ -464,7 +466,7 @@ PresentationRequesterInfo::OnAnswer(nsIPresentationChannelDescription* aDescript
|
|||
// Close the control channel since it's no longer needed.
|
||||
nsresult rv = mControlChannel->Close(NS_OK);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return ReplyError(rv);
|
||||
return ReplyError(NS_ERROR_DOM_OPERATION_ERR);
|
||||
}
|
||||
|
||||
// Session might not be ready at this moment (waiting for the establishment of
|
||||
|
@ -515,7 +517,7 @@ PresentationRequesterInfo::NotifyClosed(nsresult aReason)
|
|||
}
|
||||
|
||||
// Reply error for an abnormal close.
|
||||
return ReplyError(aReason);
|
||||
return ReplyError(NS_ERROR_DOM_OPERATION_ERR);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -531,7 +533,7 @@ PresentationRequesterInfo::OnSocketAccepted(nsIServerSocket* aServerSocket,
|
|||
// Initialize |mTransport| and use |this| as the callback.
|
||||
mTransport = do_CreateInstance(PRESENTATION_SESSION_TRANSPORT_CONTRACTID);
|
||||
if (NS_WARN_IF(!mTransport)) {
|
||||
return ReplyError(NS_ERROR_NOT_AVAILABLE);
|
||||
return ReplyError(NS_ERROR_DOM_OPERATION_ERR);
|
||||
}
|
||||
|
||||
nsresult rv = mTransport->InitWithSocketTransport(aTransport, this);
|
||||
|
@ -559,9 +561,9 @@ PresentationRequesterInfo::OnStopListening(nsIServerSocket* aServerSocket,
|
|||
|
||||
Shutdown(aStatus);
|
||||
|
||||
if (!IsSessionReady()) {
|
||||
if (NS_WARN_IF(!IsSessionReady())) {
|
||||
// It happens before the session is ready. Reply the callback.
|
||||
return ReplyError(aStatus);
|
||||
return ReplyError(NS_ERROR_DOM_OPERATION_ERR);
|
||||
}
|
||||
|
||||
// It happens after the session is ready. Notify session state change.
|
||||
|
@ -720,7 +722,7 @@ PresentationResponderInfo::NotifyResponderReady()
|
|||
if (mRequesterDescription) {
|
||||
nsresult rv = InitTransportAndSendAnswer();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return ReplyError(rv);
|
||||
return ReplyError(NS_ERROR_DOM_OPERATION_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -732,7 +734,7 @@ NS_IMETHODIMP
|
|||
PresentationResponderInfo::OnOffer(nsIPresentationChannelDescription* aDescription)
|
||||
{
|
||||
if (NS_WARN_IF(!aDescription)) {
|
||||
return ReplyError(NS_ERROR_INVALID_ARG);
|
||||
return ReplyError(NS_ERROR_DOM_OPERATION_ERR);
|
||||
}
|
||||
|
||||
mRequesterDescription = aDescription;
|
||||
|
@ -742,7 +744,7 @@ PresentationResponderInfo::OnOffer(nsIPresentationChannelDescription* aDescripti
|
|||
if (mIsResponderReady) {
|
||||
nsresult rv = InitTransportAndSendAnswer();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return ReplyError(rv);
|
||||
return ReplyError(NS_ERROR_DOM_OPERATION_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -781,7 +783,7 @@ PresentationResponderInfo::NotifyClosed(nsresult aReason)
|
|||
}
|
||||
|
||||
// Reply error for an abnormal close.
|
||||
return ReplyError(aReason);
|
||||
return ReplyError(NS_ERROR_DOM_OPERATION_ERR);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -806,13 +808,13 @@ PresentationResponderInfo::ResolvedCallback(JSContext* aCx,
|
|||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (NS_WARN_IF(!aValue.isObject())) {
|
||||
ReplyError(NS_ERROR_NOT_AVAILABLE);
|
||||
ReplyError(NS_ERROR_DOM_OPERATION_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> obj(aCx, &aValue.toObject());
|
||||
if (NS_WARN_IF(!obj)) {
|
||||
ReplyError(NS_ERROR_NOT_AVAILABLE);
|
||||
ReplyError(NS_ERROR_DOM_OPERATION_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -820,20 +822,20 @@ PresentationResponderInfo::ResolvedCallback(JSContext* aCx,
|
|||
HTMLIFrameElement* frame = nullptr;
|
||||
nsresult rv = UNWRAP_OBJECT(HTMLIFrameElement, obj, frame);
|
||||
if (NS_WARN_IF(!frame)) {
|
||||
ReplyError(NS_ERROR_NOT_AVAILABLE);
|
||||
ReplyError(NS_ERROR_DOM_OPERATION_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFrameLoaderOwner> owner = do_QueryInterface((nsIFrameLoaderOwner*) frame);
|
||||
if (NS_WARN_IF(!owner)) {
|
||||
ReplyError(NS_ERROR_NOT_AVAILABLE);
|
||||
ReplyError(NS_ERROR_DOM_OPERATION_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFrameLoader> frameLoader;
|
||||
rv = owner->GetFrameLoader(getter_AddRefs(frameLoader));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
ReplyError(rv);
|
||||
ReplyError(NS_ERROR_DOM_OPERATION_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -849,7 +851,7 @@ PresentationResponderInfo::ResolvedCallback(JSContext* aCx,
|
|||
nsCOMPtr<nsIDocShell> docShell;
|
||||
rv = frameLoader->GetDocShell(getter_AddRefs(docShell));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
ReplyError(rv);
|
||||
ReplyError(NS_ERROR_DOM_OPERATION_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -857,7 +859,7 @@ PresentationResponderInfo::ResolvedCallback(JSContext* aCx,
|
|||
mLoadingCallback = new PresentationResponderLoadingCallback(mSessionId);
|
||||
rv = mLoadingCallback->Init(docShell);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
ReplyError(rv);
|
||||
ReplyError(NS_ERROR_DOM_OPERATION_ERR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -875,5 +877,5 @@ PresentationResponderInfo::RejectedCallback(JSContext* aCx,
|
|||
mTimer = nullptr;
|
||||
}
|
||||
|
||||
ReplyError(NS_ERROR_DOM_ABORT_ERR);
|
||||
ReplyError(NS_ERROR_DOM_OPERATION_ERR);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче