Bug 1187151 (part 13) - Replace nsBaseHashtable::Enumerate() calls in dom/ with iterators. r=baku.

--HG--
extra : rebase_source : 9d3956d74a12649763c3da24e66f20b8013d87d2
This commit is contained in:
Nicholas Nethercote 2016-01-28 14:08:19 -08:00
Родитель 64812d4980
Коммит 4d79a620bf
1 изменённых файлов: 13 добавлений и 27 удалений

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

@ -411,38 +411,24 @@ SpeechDispatcherService::Setup()
//mInitialized = true;
}
struct VoiceTraverserData
{
SpeechDispatcherService* mService;
nsSynthVoiceRegistry* mRegistry;
};
// private methods
static PLDHashOperator
AddVoiceTraverser(const nsAString& aUri,
RefPtr<SpeechDispatcherVoice>& aVoice,
void* aUserArg)
{
VoiceTraverserData* data = static_cast<VoiceTraverserData*>(aUserArg);
// This service can only speak one utterance at a time, se we set
// aQueuesUtterances to true in order to track global state and schedule
// access to this service.
DebugOnly<nsresult> rv = data->mRegistry->AddVoice(data->mService, aUri,
aVoice->mName, aVoice->mLanguage,
aVoice->mName.EqualsLiteral("default"), true);
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to add voice");
return PL_DHASH_NEXT;
}
void
SpeechDispatcherService::RegisterVoices()
{
VoiceTraverserData data = { this, nsSynthVoiceRegistry::GetInstance() };
mVoices.Enumerate(AddVoiceTraverser, &data);
nsSynthVoiceRegistry* registry = nsSynthVoiceRegistry::GetInstance();
for (auto iter = mVoices.Iter(); !iter.Done(); iter.Next()) {
RefPtr<SpeechDispatcherVoice>& voice = iter.Data();
// This service can only speak one utterance at a time, so we set
// aQueuesUtterances to true in order to track global state and schedule
// access to this service.
DebugOnly<nsresult> rv =
registry->AddVoice(this, iter.Key(), voice->mName, voice->mLanguage,
voice->mName.EqualsLiteral("default"), true);
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to add voice");
}
mInitThread->Shutdown();
mInitThread = nullptr;