Bug 1540189 - LSNG: Result of SendReady call is not checked; r=asuth

Differential Revision: https://phabricator.services.mozilla.com/D25423
This commit is contained in:
Jan Varga 2019-03-29 17:58:46 +01:00
parent 16b6c300a5
commit 78e96d22bc

View File

@ -2170,8 +2170,12 @@ class LSRequestBase : public DatastoreOperationBase,
private:
void SendReadyMessage();
nsresult SendReadyMessageInternal();
void Finish();
void FinishInternal();
void SendResults();
protected:
@ -5703,27 +5707,49 @@ void LSRequestBase::SendReadyMessage() {
MaybeSetFailureCode(NS_ERROR_FAILURE);
}
if (MayProceed()) {
Unused << SendReady();
nsresult rv = SendReadyMessageInternal();
if (NS_WARN_IF(NS_FAILED(rv))) {
MaybeSetFailureCode(rv);
mState = State::WaitingForFinish;
mWaitingForFinish = true;
} else {
Cleanup();
mState = State::Completed;
FinishInternal();
}
}
nsresult LSRequestBase::SendReadyMessageInternal() {
AssertIsOnOwningThread();
MOZ_ASSERT(mState == State::SendingReadyMessage);
if (!MayProceed()) {
return NS_ERROR_FAILURE;
}
if (NS_WARN_IF(!SendReady())) {
return NS_ERROR_FAILURE;
}
mState = State::WaitingForFinish;
mWaitingForFinish = true;
return NS_OK;
}
void LSRequestBase::Finish() {
AssertIsOnOwningThread();
MOZ_ASSERT(mState == State::WaitingForFinish);
mState = State::SendingResults;
mWaitingForFinish = false;
FinishInternal();
}
void LSRequestBase::FinishInternal() {
AssertIsOnOwningThread();
MOZ_ASSERT(mState == State::SendingReadyMessage ||
mState == State::WaitingForFinish);
mState = State::SendingResults;
// This LSRequestBase can only be held alive by the IPDL. Run() can end up
// with clearing that last reference. So we need to add a self reference here.
RefPtr<LSRequestBase> kungFuDeathGrip = this;