Bug 529544 - Avoid creating parser thread when HTML5 parser not enabled. (orange fix)

This commit is contained in:
Henri Sivonen 2009-11-19 13:53:32 +02:00
Родитель b56d1ae872
Коммит ccebf9941a
1 изменённых файлов: 11 добавлений и 3 удалений

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

@ -59,7 +59,6 @@ nsHtml5Module::InitializeStatics()
{
nsContentUtils::AddBoolPrefVarCache("html5.enable", &sEnabled);
nsContentUtils::AddBoolPrefVarCache("html5.offmainthread", &sOffMainThread);
NS_NewThread(&sStreamParserThread);
NS_GetMainThread(&sMainThread);
nsHtml5Atoms::AddRefAtoms();
nsHtml5AttributeName::initializeStatics();
@ -92,7 +91,9 @@ nsHtml5Module::ReleaseStatics()
nsHtml5Tokenizer::releaseStatics();
nsHtml5TreeBuilder::releaseStatics();
nsHtml5UTF16Buffer::releaseStatics();
sStreamParserThread->Shutdown();
if (sStreamParserThread) {
sStreamParserThread->Shutdown();
}
NS_IF_RELEASE(sStreamParserThread);
NS_IF_RELEASE(sMainThread);
}
@ -120,7 +121,14 @@ nsHtml5Module::Initialize(nsIParser* aParser, nsIDocument* aDoc, nsIURI* aURI, n
nsIThread*
nsHtml5Module::GetStreamParserThread()
{
return sOffMainThread ? sStreamParserThread : sMainThread;
if (sOffMainThread) {
if (!sStreamParserThread) {
NS_NewThread(&sStreamParserThread);
NS_ASSERTION(sStreamParserThread, "Thread creation failed!");
}
return sStreamParserThread;
}
return sMainThread;
}
#ifdef DEBUG