Bug 1607356 - Move OTS sanitization to background thread. r=KrisWright

Differential Revision: https://phabricator.services.mozilla.com/D65267

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Cameron McCormack 2020-03-04 18:25:08 +00:00
parent b0a48ef15b
commit a1ff54a54f
3 changed files with 7 additions and 23 deletions

View File

@ -705,11 +705,10 @@ bool gfxUserFontEntry::LoadPlatformFontSync(const uint8_t* aFontData,
std::move(messages));
}
void gfxUserFontEntry::StartPlatformFontLoadOnWorkerThread(
void gfxUserFontEntry::StartPlatformFontLoadOnBackgroundThread(
const uint8_t* aFontData, uint32_t aLength,
nsMainThreadPtrHandle<nsIFontLoadCompleteCallback> aCallback) {
MOZ_ASSERT(sFontLoadingThread);
MOZ_ASSERT(sFontLoadingThread->IsOnCurrentThread());
MOZ_ASSERT(!NS_IsMainThread());
uint32_t saneLen;
gfxUserFontType fontType;
@ -921,12 +920,6 @@ void gfxUserFontEntry::FontDataDownloadComplete(
void gfxUserFontEntry::LoadPlatformFontAsync(
const uint8_t* aFontData, uint32_t aLength,
nsIFontLoadCompleteCallback* aCallback) {
// Ensure the font loading thread is available.
if (!sFontLoadingThread) {
sFontLoadingThread =
new LazyIdleThread(5000, NS_LITERAL_CSTRING("FontLoader"));
}
nsMainThreadPtrHandle<nsIFontLoadCompleteCallback> cb(
new nsMainThreadPtrHolder<nsIFontLoadCompleteCallback>("FontLoader",
aCallback));
@ -943,11 +936,10 @@ void gfxUserFontEntry::LoadPlatformFontAsync(
nsCOMPtr<nsIRunnable> event =
NewRunnableMethod<const uint8_t*, uint32_t,
nsMainThreadPtrHandle<nsIFontLoadCompleteCallback>>(
"gfxUserFontEntry::StartPlatformFontLoadOnWorkerThread", this,
&gfxUserFontEntry::StartPlatformFontLoadOnWorkerThread, aFontData,
"gfxUserFontEntry::StartPlatformFontLoadOnBackgroundThread", this,
&gfxUserFontEntry::StartPlatformFontLoadOnBackgroundThread, aFontData,
aLength, cb);
MOZ_ALWAYS_SUCCEEDS(
sFontLoadingThread->Dispatch(event.forget(), NS_DISPATCH_NORMAL));
MOZ_ALWAYS_SUCCEEDS(NS_DispatchBackgroundTask(event.forget()));
}
void gfxUserFontEntry::ContinuePlatformFontLoadOnMainThread(
@ -1424,8 +1416,6 @@ gfxUserFontSet::UserFontCache::MemoryReporter::CollectReports(
return NS_OK;
}
StaticRefPtr<LazyIdleThread> gfxUserFontEntry::sFontLoadingThread;
#ifdef DEBUG_USERFONT_CACHE
void gfxUserFontSet::UserFontCache::Entry::Dump() {

View File

@ -641,8 +641,6 @@ class gfxUserFontEntry : public gfxFontEntry {
MOZ_ASSERT_UNREACHABLE("not meaningful for a userfont placeholder");
}
static void Shutdown() { sFontLoadingThread = nullptr; }
protected:
struct OTSMessage {
nsCString mMessage;
@ -679,8 +677,8 @@ class gfxUserFontEntry : public gfxFontEntry {
void LoadPlatformFontAsync(const uint8_t* aFontData, uint32_t aLength,
nsIFontLoadCompleteCallback* aCallback);
// helper method for LoadPlatformFontAsync; runs on the FontLoader thread
void StartPlatformFontLoadOnWorkerThread(
// helper method for LoadPlatformFontAsync; runs on a background thread
void StartPlatformFontLoadOnBackgroundThread(
const uint8_t* aFontData, uint32_t aLength,
nsMainThreadPtrHandle<nsIFontLoadCompleteCallback> aCallback);
@ -749,8 +747,6 @@ class gfxUserFontEntry : public gfxFontEntry {
gfxUserFontSet* MOZ_NON_OWNING_REF
mFontSet; // font-set which owns this userfont entry
RefPtr<gfxFontSrcPrincipal> mPrincipal;
static mozilla::StaticRefPtr<mozilla::LazyIdleThread> sFontLoadingThread;
};
#endif /* GFX_USER_FONT_SET_H */

View File

@ -416,6 +416,4 @@ void nsLayoutStatics::Shutdown() {
css::ImageLoader::Shutdown();
mozilla::net::UrlClassifierFeatureFactory::Shutdown();
gfxUserFontEntry::Shutdown();
}