Bug 937581 - Remove imgStatusTrackerNotifyingObserver. r=seth
--- a/image/src/imgStatusTracker.cpp
+++ b/image/src/imgStatusTracker.cpp
@@ -14,213 +14,16 @@
#include "nsNetUtil.h"
#include "nsIObserverService.h"
#include "mozilla/Assertions.h"
#include "mozilla/Services.h"
using namespace mozilla::image;
-class imgStatusTrackerNotifyingObserver : public imgDecoderObserver
-{
-public:
- imgStatusTrackerNotifyingObserver(imgStatusTracker* aTracker)
- : mTracker(aTracker)
- {
- MOZ_ASSERT(aTracker);
- }
-
- virtual ~imgStatusTrackerNotifyingObserver() {}
-
- void SetTracker(imgStatusTracker* aTracker)
- {
- MOZ_ASSERT(aTracker);
- mTracker = aTracker;
- }
-
- /** imgDecoderObserver methods **/
-
- virtual void OnStartDecode()
- {
- MOZ_ASSERT(NS_IsMainThread(),
- "Use imgStatusTracker::mConsumers on main thread only");
- LOG_SCOPE(GetImgLog(), "imgStatusTrackerNotifyingObserver::OnStartDecode");
- NS_ABORT_IF_FALSE(mTracker->HasImage(),
- "OnStartDecode callback before we've created our image");
-
- mTracker->RecordStartDecode();
-
- nsTObserverArray<imgRequestProxy*>::ForwardIterator iter(mTracker->mConsumers);
- while (iter.HasMore()) {
- mTracker->SendStartDecode(iter.GetNext());
- }
-
- if (!mTracker->IsMultipart()) {
- mTracker->RecordBlockOnload();
-
- nsTObserverArray<imgRequestProxy*>::ForwardIterator iter(mTracker->mConsumers);
- while (iter.HasMore()) {
- mTracker->SendBlockOnload(iter.GetNext());
- }
- }
- }
-
- virtual void OnStartRequest()
- {
- NS_NOTREACHED("imgStatusTrackerNotifyingObserver(imgDecoderObserver)::OnStartRequest");
- }
-
- virtual void OnStartContainer()
- {
- MOZ_ASSERT(NS_IsMainThread(),
- "Use imgStatusTracker::mConsumers on main thread only");
- LOG_SCOPE(GetImgLog(), "imgStatusTrackerNotifyingObserver::OnStartContainer");
-
- NS_ABORT_IF_FALSE(mTracker->HasImage(),
- "OnStartContainer callback before we've created our image");
- {
- nsRefPtr<Image> image = mTracker->GetImage();
- mTracker->RecordStartContainer(image);
- }
-
- nsTObserverArray<imgRequestProxy*>::ForwardIterator iter(mTracker->mConsumers);
- while (iter.HasMore()) {
- mTracker->SendStartContainer(iter.GetNext());
- }
- }
-
- virtual void OnStartFrame()
- {
- LOG_SCOPE(GetImgLog(), "imgStatusTrackerNotifyingObserver::OnStartFrame");
- NS_ABORT_IF_FALSE(mTracker->HasImage(),
- "OnStartFrame callback before we've created our image");
-
- mTracker->RecordStartFrame();
-
- // This is not observed below the imgStatusTracker level, so we don't need
- // to SendStartFrame.
- }
-
- virtual void FrameChanged(const nsIntRect* dirtyRect)
- {
- MOZ_ASSERT(NS_IsMainThread(),
- "Use imgStatusTracker::mConsumers on main thread only");
- LOG_SCOPE(GetImgLog(), "imgStatusTrackerNotifyingObserver::FrameChanged");
- NS_ABORT_IF_FALSE(mTracker->HasImage(),
- "FrameChanged callback before we've created our image");
-
- mTracker->RecordFrameChanged(dirtyRect);
-
- nsTObserverArray<imgRequestProxy*>::ForwardIterator iter(mTracker->mConsumers);
- while (iter.HasMore()) {
- mTracker->SendFrameChanged(iter.GetNext(), dirtyRect);
- }
- }
-
- virtual void OnStopFrame()
- {
- MOZ_ASSERT(NS_IsMainThread(),
- "Use imgStatusTracker::mConsumers on main thread only");
- LOG_SCOPE(GetImgLog(), "imgStatusTrackerNotifyingObserver::OnStopFrame");
- NS_ABORT_IF_FALSE(mTracker->HasImage(),
- "OnStopFrame callback before we've created our image");
-
- mTracker->RecordStopFrame();
-
- nsTObserverArray<imgRequestProxy*>::ForwardIterator iter(mTracker->mConsumers);
- while (iter.HasMore()) {
- mTracker->SendStopFrame(iter.GetNext());
- }
-
- mTracker->MaybeUnblockOnload();
- }
-
- virtual void OnStopDecode(nsresult aStatus)
- {
- MOZ_ASSERT(NS_IsMainThread(),
- "Use imgStatusTracker::mConsumers on main thread only");
- LOG_SCOPE(GetImgLog(), "imgStatusTrackerNotifyingObserver::OnStopDecode");
- NS_ABORT_IF_FALSE(mTracker->HasImage(),
- "OnStopDecode callback before we've created our image");
-
- bool preexistingError = mTracker->GetImageStatus() == imgIRequest::STATUS_ERROR;
-
- mTracker->RecordStopDecode(aStatus);
-
- nsTObserverArray<imgRequestProxy*>::ForwardIterator iter(mTracker->mConsumers);
- while (iter.HasMore()) {
- mTracker->SendStopDecode(iter.GetNext(), aStatus);
- }
-
- // This is really hacky. We need to handle the case where we start decoding,
- // block onload, but then hit an error before we get to our first frame.
- mTracker->MaybeUnblockOnload();
-
- if (NS_FAILED(aStatus) && !preexistingError) {
- mTracker->FireFailureNotification();
- }
- }
-
- virtual void OnStopRequest(bool aLastPart, nsresult aStatus)
- {
- NS_NOTREACHED("imgStatusTrackerNotifyingObserver(imgDecoderObserver)::OnStopRequest");
- }
-
- virtual void OnDiscard()
- {
- MOZ_ASSERT(NS_IsMainThread(),
- "Use imgStatusTracker::mConsumers on main thread only");
- NS_ABORT_IF_FALSE(mTracker->HasImage(),
- "OnDiscard callback before we've created our image");
-
- mTracker->RecordDiscard();
-
- nsTObserverArray<imgRequestProxy*>::ForwardIterator iter(mTracker->mConsumers);
- while (iter.HasMore()) {
- mTracker->SendDiscard(iter.GetNext());
- }
- }
-
- virtual void OnUnlockedDraw()
- {
- MOZ_ASSERT(NS_IsMainThread(),
- "Use imgStatusTracker::mConsumers on main thread only");
- NS_ABORT_IF_FALSE(mTracker->HasImage(),
- "OnUnlockedDraw callback before we've created our image");
- mTracker->RecordUnlockedDraw();
-
- nsTObserverArray<imgRequestProxy*>::ForwardIterator iter(mTracker->mConsumers);
- while (iter.HasMore()) {
- mTracker->SendUnlockedDraw(iter.GetNext());
- }
- }
-
- virtual void OnImageIsAnimated()
- {
- MOZ_ASSERT(NS_IsMainThread(),
- "Use imgStatusTracker::mConsumers on main thread only");
- NS_ABORT_IF_FALSE(mTracker->HasImage(),
- "OnImageIsAnimated callback before we've created our image");
- mTracker->RecordImageIsAnimated();
-
- nsTObserverArray<imgRequestProxy*>::ForwardIterator iter(mTracker->mConsumers);
- while (iter.HasMore()) {
- mTracker->SendImageIsAnimated(iter.GetNext());
- }
- }
-
- virtual void OnError()
- {
- mTracker->RecordError();
- }
-
-private:
- nsRefPtr<imgStatusTracker> mTracker;
-};
-
class imgStatusTrackerObserver : public imgDecoderObserver
{
public:
imgStatusTrackerObserver(imgStatusTracker* aTracker)
: mTracker(aTracker->asWeakPtr())
{
MOZ_ASSERT(aTracker);
}
--- a/image/src/imgStatusTracker.h
+++ b/image/src/imgStatusTracker.h
@@ -8,17 +8,16 @@
#define imgStatusTracker_h__
class imgDecoderObserver;
class imgIContainer;
class imgRequestProxy;
class imgStatusNotifyRunnable;
class imgRequestNotifyRunnable;
class imgStatusTrackerObserver;
-class imgStatusTrackerNotifyingObserver;
class nsIRunnable;
#include "mozilla/RefPtr.h"
#include "mozilla/WeakPtr.h"
#include "nsCOMPtr.h"
#include "nsTObserverArray.h"
#include "nsThreadUtils.h"
#include "nsRect.h"
@@ -294,17 +293,16 @@ public:
void SyncNotifyDifference(const mozilla::image::ImageStatusDiff& aDiff);
nsIntRect GetInvalidRect() const { return mInvalidRect; }
private:
friend class imgStatusNotifyRunnable;
friend class imgRequestNotifyRunnable;
friend class imgStatusTrackerObserver;
- friend class imgStatusTrackerNotifyingObserver;
friend class imgStatusTrackerInit;
imgStatusTracker(const imgStatusTracker& aOther);
// Main thread only because it deals with the observer service.
void FireFailureNotification();
// Main thread only, since imgRequestProxy calls are expected on the main
// thread, and mConsumers is not threadsafe.