Bug 1230428 - Part 1. Check mTask since end event is posted asynchronized. r=eeejay

This commit is contained in:
Makoto Kato 2015-12-10 13:45:26 -05:00
Родитель 7edc2a1cc9
Коммит 2f8f4466aa
2 изменённых файлов: 26 добавлений и 0 удалений

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

@ -79,6 +79,11 @@ SpeechTaskCallback::OnPause()
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
[mSpeechSynthesizer pauseSpeakingAtBoundary:NSSpeechImmediateBoundary];
if (!mTask) {
// When calling pause() on child porcess, it may not receive end event
// from chrome process yet.
return NS_ERROR_FAILURE;
}
mTask->DispatchPause(GetTimeDurationFromStart(), mCurrentIndex);
return NS_OK;
@ -91,6 +96,11 @@ SpeechTaskCallback::OnResume()
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
[mSpeechSynthesizer continueSpeaking];
if (!mTask) {
// When calling resume() on child porcess, it may not receive end event
// from chrome process yet.
return NS_ERROR_FAILURE;
}
mTask->DispatchResume(GetTimeDurationFromStart(), mCurrentIndex);
return NS_OK;
@ -120,6 +130,9 @@ void
SpeechTaskCallback::OnWillSpeakWord(uint32_t aIndex)
{
mCurrentIndex = aIndex;
if (!mTask) {
return;
}
mTask->DispatchBoundary(NS_LITERAL_STRING("word"),
GetTimeDurationFromStart(), mCurrentIndex);
}
@ -127,6 +140,9 @@ SpeechTaskCallback::OnWillSpeakWord(uint32_t aIndex)
void
SpeechTaskCallback::OnError(uint32_t aIndex)
{
if (!mTask) {
return;
}
mTask->DispatchError(GetTimeDurationFromStart(), aIndex);
}

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

@ -76,6 +76,11 @@ SapiCallback::OnPause()
if (FAILED(mSapiClient->Pause())) {
return NS_ERROR_FAILURE;
}
if (!mTask) {
// When calling pause() on child porcess, it may not receive end event
// from chrome process yet.
return NS_ERROR_FAILURE;
}
mTask->DispatchPause(GetTickCount() - mStartingTime, mCurrentIndex);
return NS_OK;
}
@ -86,6 +91,11 @@ SapiCallback::OnResume()
if (FAILED(mSapiClient->Resume())) {
return NS_ERROR_FAILURE;
}
if (!mTask) {
// When calling resume() on child porcess, it may not receive end event
// from chrome process yet.
return NS_ERROR_FAILURE;
}
mTask->DispatchResume(GetTickCount() - mStartingTime, mCurrentIndex);
return NS_OK;
}