зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1097432 (Part 1) - Remove imgStatusTracker::Send* methods and clean up. r=tn
This commit is contained in:
Родитель
fa82ef9bdd
Коммит
63584f5ba5
|
@ -225,13 +225,13 @@ imgStatusTracker::NotifyCurrentState(imgRequestProxy* proxy)
|
|||
NS_DispatchToCurrentThread(ev);
|
||||
}
|
||||
|
||||
#define NOTIFY_IMAGE_OBSERVERS(func) \
|
||||
#define NOTIFY_IMAGE_OBSERVERS(PROXIES, FUNC) \
|
||||
do { \
|
||||
ProxyArray::ForwardIterator iter(aProxies); \
|
||||
ProxyArray::ForwardIterator iter(PROXIES); \
|
||||
while (iter.HasMore()) { \
|
||||
nsRefPtr<imgRequestProxy> proxy = iter.GetNext().get(); \
|
||||
if (proxy && !proxy->NotificationsDeferred()) { \
|
||||
proxy->func; \
|
||||
proxy->FUNC; \
|
||||
} \
|
||||
} \
|
||||
} while (false);
|
||||
|
@ -244,19 +244,19 @@ imgStatusTracker::SyncNotifyState(ProxyArray& aProxies,
|
|||
MOZ_ASSERT(NS_IsMainThread());
|
||||
// OnStartRequest
|
||||
if (aState & FLAG_REQUEST_STARTED)
|
||||
NOTIFY_IMAGE_OBSERVERS(OnStartRequest());
|
||||
NOTIFY_IMAGE_OBSERVERS(aProxies, OnStartRequest());
|
||||
|
||||
// OnStartContainer
|
||||
if (aState & FLAG_HAS_SIZE)
|
||||
NOTIFY_IMAGE_OBSERVERS(OnStartContainer());
|
||||
NOTIFY_IMAGE_OBSERVERS(aProxies, OnStartContainer());
|
||||
|
||||
// OnStartDecode
|
||||
if (aState & FLAG_DECODE_STARTED)
|
||||
NOTIFY_IMAGE_OBSERVERS(OnStartDecode());
|
||||
NOTIFY_IMAGE_OBSERVERS(aProxies, OnStartDecode());
|
||||
|
||||
// BlockOnload
|
||||
if (aState & FLAG_ONLOAD_BLOCKED)
|
||||
NOTIFY_IMAGE_OBSERVERS(BlockOnload());
|
||||
NOTIFY_IMAGE_OBSERVERS(aProxies, BlockOnload());
|
||||
|
||||
if (aHasImage) {
|
||||
// OnFrameUpdate
|
||||
|
@ -264,30 +264,31 @@ imgStatusTracker::SyncNotifyState(ProxyArray& aProxies,
|
|||
// vector images, true for raster images that have decoded at
|
||||
// least one frame) then send OnFrameUpdate.
|
||||
if (!aDirtyRect.IsEmpty())
|
||||
NOTIFY_IMAGE_OBSERVERS(OnFrameUpdate(&aDirtyRect));
|
||||
NOTIFY_IMAGE_OBSERVERS(aProxies, OnFrameUpdate(&aDirtyRect));
|
||||
|
||||
if (aState & FLAG_FRAME_STOPPED)
|
||||
NOTIFY_IMAGE_OBSERVERS(OnStopFrame());
|
||||
NOTIFY_IMAGE_OBSERVERS(aProxies, OnStopFrame());
|
||||
|
||||
// OnImageIsAnimated
|
||||
if (aState & FLAG_IS_ANIMATED)
|
||||
NOTIFY_IMAGE_OBSERVERS(OnImageIsAnimated());
|
||||
NOTIFY_IMAGE_OBSERVERS(aProxies, OnImageIsAnimated());
|
||||
}
|
||||
|
||||
// Send UnblockOnload before OnStopDecode and OnStopRequest. This allows
|
||||
// observers that can fire events when they receive those notifications to do
|
||||
// so then, instead of being forced to wait for UnblockOnload.
|
||||
if (aState & FLAG_ONLOAD_UNBLOCKED) {
|
||||
NOTIFY_IMAGE_OBSERVERS(UnblockOnload());
|
||||
NOTIFY_IMAGE_OBSERVERS(aProxies, UnblockOnload());
|
||||
}
|
||||
|
||||
if (aState & FLAG_DECODE_STOPPED) {
|
||||
MOZ_ASSERT(aHasImage, "Stopped decoding without ever having an image?");
|
||||
NOTIFY_IMAGE_OBSERVERS(OnStopDecode());
|
||||
NOTIFY_IMAGE_OBSERVERS(aProxies, OnStopDecode());
|
||||
}
|
||||
|
||||
if (aState & FLAG_REQUEST_STOPPED) {
|
||||
NOTIFY_IMAGE_OBSERVERS(OnStopRequest(aState & FLAG_MULTIPART_STOPPED));
|
||||
NOTIFY_IMAGE_OBSERVERS(aProxies,
|
||||
OnStopRequest(aState & FLAG_MULTIPART_STOPPED));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -422,84 +423,11 @@ imgStatusTracker::RecordError()
|
|||
mState |= FLAG_HAS_ERROR;
|
||||
}
|
||||
|
||||
void
|
||||
imgStatusTracker::SendStartDecode(imgRequestProxy* aProxy)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (!aProxy->NotificationsDeferred())
|
||||
aProxy->OnStartDecode();
|
||||
}
|
||||
|
||||
void
|
||||
imgStatusTracker::SendStartContainer(imgRequestProxy* aProxy)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (!aProxy->NotificationsDeferred())
|
||||
aProxy->OnStartContainer();
|
||||
}
|
||||
|
||||
void
|
||||
imgStatusTracker::SendStopFrame(imgRequestProxy* aProxy)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (!aProxy->NotificationsDeferred())
|
||||
aProxy->OnStopFrame();
|
||||
}
|
||||
|
||||
void
|
||||
imgStatusTracker::SendStopDecode(imgRequestProxy* aProxy,
|
||||
nsresult aStatus)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (!aProxy->NotificationsDeferred())
|
||||
aProxy->OnStopDecode();
|
||||
}
|
||||
|
||||
void
|
||||
imgStatusTracker::SendDiscard(imgRequestProxy* aProxy)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (!aProxy->NotificationsDeferred())
|
||||
aProxy->OnDiscard();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
imgStatusTracker::SendImageIsAnimated(imgRequestProxy* aProxy)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (!aProxy->NotificationsDeferred())
|
||||
aProxy->OnImageIsAnimated();
|
||||
}
|
||||
|
||||
void
|
||||
imgStatusTracker::SendUnlockedDraw(imgRequestProxy* aProxy)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (!aProxy->NotificationsDeferred())
|
||||
aProxy->OnUnlockedDraw();
|
||||
}
|
||||
|
||||
void
|
||||
imgStatusTracker::OnUnlockedDraw()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
ProxyArray::ForwardIterator iter(mConsumers);
|
||||
while (iter.HasMore()) {
|
||||
nsRefPtr<imgRequestProxy> proxy = iter.GetNext().get();
|
||||
if (proxy) {
|
||||
SendUnlockedDraw(proxy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* non-virtual sort-of-nsIRequestObserver methods */
|
||||
void
|
||||
imgStatusTracker::SendStartRequest(imgRequestProxy* aProxy)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (!aProxy->NotificationsDeferred())
|
||||
aProxy->OnStartRequest();
|
||||
NOTIFY_IMAGE_OBSERVERS(mConsumers, OnUnlockedDraw());
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -512,39 +440,14 @@ imgStatusTracker::OnStartRequest()
|
|||
mState &= FLAG_IS_MULTIPART | FLAG_HAS_ERROR;
|
||||
mState |= FLAG_REQUEST_STARTED;
|
||||
|
||||
ProxyArray::ForwardIterator iter(mConsumers);
|
||||
while (iter.HasMore()) {
|
||||
nsRefPtr<imgRequestProxy> proxy = iter.GetNext().get();
|
||||
if (proxy) {
|
||||
SendStartRequest(proxy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
imgStatusTracker::SendStopRequest(imgRequestProxy* aProxy,
|
||||
bool aLastPart,
|
||||
nsresult aStatus)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (!aProxy->NotificationsDeferred()) {
|
||||
aProxy->OnStopRequest(aLastPart);
|
||||
}
|
||||
NOTIFY_IMAGE_OBSERVERS(mConsumers, OnStartRequest());
|
||||
}
|
||||
|
||||
void
|
||||
imgStatusTracker::OnDiscard()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
/* notify the kids */
|
||||
ProxyArray::ForwardIterator iter(mConsumers);
|
||||
while (iter.HasMore()) {
|
||||
nsRefPtr<imgRequestProxy> proxy = iter.GetNext().get();
|
||||
if (proxy) {
|
||||
SendDiscard(proxy);
|
||||
}
|
||||
}
|
||||
NOTIFY_IMAGE_OBSERVERS(mConsumers, OnDiscard());
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -558,32 +461,8 @@ imgStatusTracker::OnDataAvailable()
|
|||
NS_NewRunnableMethod(this, &imgStatusTracker::OnDataAvailable));
|
||||
return;
|
||||
}
|
||||
// Notify any imgRequestProxys that are observing us that we have an Image.
|
||||
ProxyArray::ForwardIterator iter(mConsumers);
|
||||
while (iter.HasMore()) {
|
||||
nsRefPtr<imgRequestProxy> proxy = iter.GetNext().get();
|
||||
if (proxy) {
|
||||
proxy->SetHasImage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
imgStatusTracker::SendBlockOnload(imgRequestProxy* aProxy)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (!aProxy->NotificationsDeferred()) {
|
||||
aProxy->BlockOnload();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
imgStatusTracker::SendUnblockOnload(imgRequestProxy* aProxy)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (!aProxy->NotificationsDeferred()) {
|
||||
aProxy->UnblockOnload();
|
||||
}
|
||||
NOTIFY_IMAGE_OBSERVERS(mConsumers, SetHasImage());
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -594,19 +473,14 @@ imgStatusTracker::MaybeUnblockOnload()
|
|||
NS_NewRunnableMethod(this, &imgStatusTracker::MaybeUnblockOnload));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(mState & FLAG_ONLOAD_BLOCKED) || (mState & FLAG_ONLOAD_UNBLOCKED)) {
|
||||
return;
|
||||
}
|
||||
|
||||
mState |= FLAG_ONLOAD_UNBLOCKED;
|
||||
|
||||
ProxyArray::ForwardIterator iter(mConsumers);
|
||||
while (iter.HasMore()) {
|
||||
nsRefPtr<imgRequestProxy> proxy = iter.GetNext().get();
|
||||
if (proxy) {
|
||||
SendUnblockOnload(proxy);
|
||||
}
|
||||
}
|
||||
NOTIFY_IMAGE_OBSERVERS(mConsumers, UnblockOnload());
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -180,24 +180,8 @@ public:
|
|||
// Get the current image status (as in imgIRequest).
|
||||
uint32_t GetImageStatus() const;
|
||||
|
||||
// Functions with prefix Send- are main thread only, since they contain calls
|
||||
// to imgRequestProxy functions, which are expected on the main thread.
|
||||
void SendStartDecode(imgRequestProxy* aProxy);
|
||||
void SendStartContainer(imgRequestProxy* aProxy);
|
||||
void SendStopFrame(imgRequestProxy* aProxy);
|
||||
void SendStopDecode(imgRequestProxy* aProxy, nsresult aStatus);
|
||||
void SendDiscard(imgRequestProxy* aProxy);
|
||||
void SendUnlockedDraw(imgRequestProxy* aProxy);
|
||||
void SendImageIsAnimated(imgRequestProxy *aProxy);
|
||||
|
||||
/* non-virtual sort-of-nsIRequestObserver methods */
|
||||
// Functions with prefix Send- are main thread only, since they contain calls
|
||||
// to imgRequestProxy functions, which are expected on the main thread.
|
||||
void SendStartRequest(imgRequestProxy* aProxy);
|
||||
void SendStopRequest(imgRequestProxy* aProxy, bool aLastPart, nsresult aStatus);
|
||||
|
||||
// All main thread only because they call functions (like SendStartRequest)
|
||||
// which are expected to be called on the main thread.
|
||||
// All main thread only because they call functions which are expected to be
|
||||
// called on the main thread.
|
||||
void OnStartRequest();
|
||||
// OnDataAvailable will dispatch a call to itself onto the main thread if not
|
||||
// called there.
|
||||
|
@ -205,13 +189,6 @@ public:
|
|||
void OnDiscard();
|
||||
void OnUnlockedDraw();
|
||||
|
||||
/* non-virtual imgIOnloadBlocker methods */
|
||||
// NB: If UnblockOnload is sent, and then we are asked to replay the
|
||||
// notifications, we will not send a BlockOnload/UnblockOnload pair. This
|
||||
// is different from all the other notifications.
|
||||
void SendBlockOnload(imgRequestProxy* aProxy);
|
||||
void SendUnblockOnload(imgRequestProxy* aProxy);
|
||||
|
||||
// Main thread only because mConsumers is not threadsafe.
|
||||
void MaybeUnblockOnload();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче