Bug 1766122 - Make PeerConnectionImpl::Chain return an already_AddRefed<Promise>. r=bwc
Differential Revision: https://phabricator.services.mozilla.com/D144511
This commit is contained in:
@@ -1172,27 +1172,29 @@ RefPtr<dom::Promise> PeerConnectionImpl::JSOperation::CallImpl() {
|
|||||||
return op->Call();
|
return op->Call();
|
||||||
}
|
}
|
||||||
|
|
||||||
dom::Promise* PeerConnectionImpl::Chain(dom::ChainedOperation& aOperation) {
|
already_AddRefed<dom::Promise> PeerConnectionImpl::Chain(
|
||||||
|
dom::ChainedOperation& aOperation) {
|
||||||
MOZ_RELEASE_ASSERT(!mChainingOperation);
|
MOZ_RELEASE_ASSERT(!mChainingOperation);
|
||||||
mChainingOperation = true;
|
mChainingOperation = true;
|
||||||
RefPtr<Operation> operation = new JSOperation(this, aOperation);
|
RefPtr<Operation> operation = new JSOperation(this, aOperation);
|
||||||
auto* promise = Chain(operation);
|
RefPtr<Promise> promise = Chain(operation);
|
||||||
mChainingOperation = false;
|
mChainingOperation = false;
|
||||||
return promise;
|
return promise.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is kinda complicated, but it is what the spec requires us to do. The
|
// This is kinda complicated, but it is what the spec requires us to do. The
|
||||||
// core of what makes this complicated is the requirement that |aOperation| be
|
// core of what makes this complicated is the requirement that |aOperation| be
|
||||||
// run _immediately_ (without any Promise.Then!) if the operations chain is
|
// run _immediately_ (without any Promise.Then!) if the operations chain is
|
||||||
// empty.
|
// empty.
|
||||||
dom::Promise* PeerConnectionImpl::Chain(const RefPtr<Operation>& aOperation) {
|
already_AddRefed<dom::Promise> PeerConnectionImpl::Chain(
|
||||||
|
const RefPtr<Operation>& aOperation) {
|
||||||
// If connection.[[IsClosed]] is true, return a promise rejected with a newly
|
// If connection.[[IsClosed]] is true, return a promise rejected with a newly
|
||||||
// created InvalidStateError.
|
// created InvalidStateError.
|
||||||
if (IsClosed()) {
|
if (IsClosed()) {
|
||||||
CSFLogDebug(LOGTAG, "%s:%d: Peer connection is closed", __FILE__, __LINE__);
|
CSFLogDebug(LOGTAG, "%s:%d: Peer connection is closed", __FILE__, __LINE__);
|
||||||
RefPtr<dom::Promise> error = MakePromise();
|
RefPtr<dom::Promise> error = MakePromise();
|
||||||
error->MaybeRejectWithInvalidStateError("Peer connection is closed");
|
error->MaybeRejectWithInvalidStateError("Peer connection is closed");
|
||||||
return error;
|
return error.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append operation to [[Operations]].
|
// Append operation to [[Operations]].
|
||||||
@@ -1204,7 +1206,7 @@ dom::Promise* PeerConnectionImpl::Chain(const RefPtr<Operation>& aOperation) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This is the promise p from https://w3c.github.io/webrtc-pc/#dfn-chain
|
// This is the promise p from https://w3c.github.io/webrtc-pc/#dfn-chain
|
||||||
return aOperation->GetPromise();
|
return do_AddRef(aOperation->GetPromise());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerConnectionImpl::RunNextOperation() {
|
void PeerConnectionImpl::RunNextOperation() {
|
||||||
|
|||||||
@@ -440,9 +440,9 @@ class PeerConnectionImpl final
|
|||||||
};
|
};
|
||||||
|
|
||||||
MOZ_CAN_RUN_SCRIPT
|
MOZ_CAN_RUN_SCRIPT
|
||||||
dom::Promise* Chain(dom::ChainedOperation& aOperation);
|
already_AddRefed<dom::Promise> Chain(dom::ChainedOperation& aOperation);
|
||||||
MOZ_CAN_RUN_SCRIPT
|
MOZ_CAN_RUN_SCRIPT
|
||||||
dom::Promise* Chain(const RefPtr<Operation>& aOperation);
|
already_AddRefed<dom::Promise> Chain(const RefPtr<Operation>& aOperation);
|
||||||
already_AddRefed<dom::Promise> MakePromise() const;
|
already_AddRefed<dom::Promise> MakePromise() const;
|
||||||
|
|
||||||
void UpdateNegotiationNeeded();
|
void UpdateNegotiationNeeded();
|
||||||
|
|||||||
@@ -600,7 +600,7 @@ already_AddRefed<dom::Promise> RTCRtpSender::ReplaceTrack(
|
|||||||
new ReplaceTrackOperation(mPc, mTransceiverImpl, aWithTrack);
|
new ReplaceTrackOperation(mPc, mTransceiverImpl, aWithTrack);
|
||||||
// Static analysis forces us to use a temporary.
|
// Static analysis forces us to use a temporary.
|
||||||
auto pc = mPc;
|
auto pc = mPc;
|
||||||
return do_AddRef(pc->Chain(op));
|
return pc->Chain(op);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsPIDOMWindowInner* RTCRtpSender::GetParentObject() const { return mWindow; }
|
nsPIDOMWindowInner* RTCRtpSender::GetParentObject() const { return mWindow; }
|
||||||
|
|||||||
Reference in New Issue
Block a user