Bug 1451405: Notify debug-only image observers off a script-runner. r=bz

MozReview-Commit-ID: ARn8d2Rxp13
This commit is contained in:
Emilio Cobos Álvarez 2018-04-03 19:33:18 +02:00
parent 112dc4a070
commit 3c69ce8551

View File

@ -6,6 +6,7 @@
#include "Image.h"
#include "Layers.h" // for LayerManager
#include "nsRefreshDriver.h"
#include "nsContentUtils.h"
#include "mozilla/SizeOfState.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/Tuple.h" // for Tie
@ -403,14 +404,17 @@ ImageResource::NotifyDrawingObservers()
}
// Record the image drawing for startup performance testing.
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
NS_WARNING_ASSERTION(obs, "Can't get an observer service handle");
if (obs) {
nsCOMPtr<nsIURI> imageURI = mURI->ToIURI();
nsAutoCString spec;
imageURI->GetSpec(spec);
obs->NotifyObservers(nullptr, "image-drawing", NS_ConvertUTF8toUTF16(spec).get());
}
nsCOMPtr<nsIURI> uri = mURI->ToIURI();
nsContentUtils::AddScriptRunner(NS_NewRunnableFunction(
"image::ImageResource::NotifyDrawingObservers", [uri]() {
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
NS_WARNING_ASSERTION(obs, "Can't get an observer service handle");
if (obs) {
nsAutoCString spec;
uri->GetSpec(spec);
obs->NotifyObservers(nullptr, "image-drawing", NS_ConvertUTF8toUTF16(spec).get());
}
}));
}
#endif