зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1522417 - Add diagnostics. r=jwatt
I haven't managed to find a way stuff should unexpectedly die around these functions, so add a few diagnostics to catch this hopefully, before papering over the bug / backing out / adding a kungfudeathgrip. Differential Revision: https://phabricator.services.mozilla.com/D17514 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
cbd7c81aa7
Коммит
f2065bb0b0
|
@ -12,6 +12,7 @@
|
||||||
#include "nsFontFaceLoader.h"
|
#include "nsFontFaceLoader.h"
|
||||||
|
|
||||||
#include "nsError.h"
|
#include "nsError.h"
|
||||||
|
#include "mozilla/AutoRestore.h"
|
||||||
#include "mozilla/Preferences.h"
|
#include "mozilla/Preferences.h"
|
||||||
#include "mozilla/StaticPrefs.h"
|
#include "mozilla/StaticPrefs.h"
|
||||||
#include "mozilla/Telemetry.h"
|
#include "mozilla/Telemetry.h"
|
||||||
|
@ -59,6 +60,8 @@ nsFontFaceLoader::nsFontFaceLoader(gfxUserFontEntry* aUserFontEntry,
|
||||||
}
|
}
|
||||||
|
|
||||||
nsFontFaceLoader::~nsFontFaceLoader() {
|
nsFontFaceLoader::~nsFontFaceLoader() {
|
||||||
|
MOZ_DIAGNOSTIC_ASSERT(!mInLoadTimerCallback);
|
||||||
|
MOZ_DIAGNOSTIC_ASSERT(!mInStreamComplete);
|
||||||
if (mUserFontEntry) {
|
if (mUserFontEntry) {
|
||||||
mUserFontEntry->mLoader = nullptr;
|
mUserFontEntry->mLoader = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -96,6 +99,11 @@ void nsFontFaceLoader::StartedLoading(nsIStreamLoader* aStreamLoader) {
|
||||||
void* aClosure) {
|
void* aClosure) {
|
||||||
nsFontFaceLoader* loader = static_cast<nsFontFaceLoader*>(aClosure);
|
nsFontFaceLoader* loader = static_cast<nsFontFaceLoader*>(aClosure);
|
||||||
|
|
||||||
|
MOZ_DIAGNOSTIC_ASSERT(!loader->mInLoadTimerCallback);
|
||||||
|
MOZ_DIAGNOSTIC_ASSERT(!loader->mInStreamComplete);
|
||||||
|
AutoRestore<bool> scope { loader->mInLoadTimerCallback };
|
||||||
|
loader->mInLoadTimerCallback = true;
|
||||||
|
|
||||||
if (!loader->mFontFaceSet) {
|
if (!loader->mFontFaceSet) {
|
||||||
// We've been canceled
|
// We've been canceled
|
||||||
return;
|
return;
|
||||||
|
@ -190,6 +198,11 @@ nsFontFaceLoader::OnStreamComplete(nsIStreamLoader* aLoader,
|
||||||
uint32_t aStringLen,
|
uint32_t aStringLen,
|
||||||
const uint8_t* aString) {
|
const uint8_t* aString) {
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
MOZ_DIAGNOSTIC_ASSERT(!mInLoadTimerCallback);
|
||||||
|
MOZ_DIAGNOSTIC_ASSERT(!mInStreamComplete);
|
||||||
|
|
||||||
|
AutoRestore<bool> scope { mInStreamComplete };
|
||||||
|
mInStreamComplete = true;
|
||||||
|
|
||||||
DropChannel();
|
DropChannel();
|
||||||
|
|
||||||
|
@ -198,8 +211,6 @@ nsFontFaceLoader::OnStreamComplete(nsIStreamLoader* aLoader,
|
||||||
return aStatus;
|
return aStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
mFontFaceSet->RemoveLoader(this);
|
|
||||||
|
|
||||||
TimeStamp doneTime = TimeStamp::Now();
|
TimeStamp doneTime = TimeStamp::Now();
|
||||||
TimeDuration downloadTime = doneTime - mStartTime;
|
TimeDuration downloadTime = doneTime - mStartTime;
|
||||||
uint32_t downloadTimeMS = uint32_t(downloadTime.ToMilliseconds());
|
uint32_t downloadTimeMS = uint32_t(downloadTime.ToMilliseconds());
|
||||||
|
@ -272,6 +283,8 @@ nsFontFaceLoader::OnStreamComplete(nsIStreamLoader* aLoader,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MOZ_DIAGNOSTIC_ASSERT(mFontFaceSet);
|
||||||
|
mFontFaceSet->RemoveLoader(this);
|
||||||
// done with font set
|
// done with font set
|
||||||
mFontFaceSet = nullptr;
|
mFontFaceSet = nullptr;
|
||||||
if (mLoadTimer) {
|
if (mLoadTimer) {
|
||||||
|
@ -305,6 +318,10 @@ nsFontFaceLoader::OnStopRequest(nsIRequest* aRequest, nsISupports* aContext,
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsFontFaceLoader::Cancel() {
|
void nsFontFaceLoader::Cancel() {
|
||||||
|
MOZ_DIAGNOSTIC_ASSERT(!mInLoadTimerCallback);
|
||||||
|
MOZ_DIAGNOSTIC_ASSERT(!mInStreamComplete);
|
||||||
|
MOZ_DIAGNOSTIC_ASSERT(mFontFaceSet);
|
||||||
|
|
||||||
mUserFontEntry->LoadCanceled();
|
mUserFontEntry->LoadCanceled();
|
||||||
mFontFaceSet = nullptr;
|
mFontFaceSet = nullptr;
|
||||||
if (mLoadTimer) {
|
if (mLoadTimer) {
|
||||||
|
|
|
@ -61,6 +61,8 @@ class nsFontFaceLoader final : public nsIStreamLoaderObserver,
|
||||||
nsCOMPtr<nsITimer> mLoadTimer;
|
nsCOMPtr<nsITimer> mLoadTimer;
|
||||||
mozilla::TimeStamp mStartTime;
|
mozilla::TimeStamp mStartTime;
|
||||||
nsIStreamLoader* mStreamLoader;
|
nsIStreamLoader* mStreamLoader;
|
||||||
|
bool mInStreamComplete = false;
|
||||||
|
bool mInLoadTimerCallback = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* !defined(nsFontFaceLoader_h_) */
|
#endif /* !defined(nsFontFaceLoader_h_) */
|
||||||
|
|
Загрузка…
Ссылка в новой задаче