mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 505385 - Part 5: Expose pointers to the imgRequest and Image on imgStatusTracker. r=joe
This will help us decouple imgRequest and imgRequestProxy.
This commit is contained in:
parent
5150ce1dfa
commit
67a6f4a027
@ -21,7 +21,7 @@ Image::Image(imgStatusTracker* aStatusTracker) :
|
||||
mStatusTracker = aStatusTracker;
|
||||
mStatusTracker->SetImage(this);
|
||||
} else {
|
||||
mStatusTracker = new imgStatusTracker(this);
|
||||
mStatusTracker = new imgStatusTracker(this, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ nsresult imgRequest::Init(nsIURI *aURI,
|
||||
|
||||
mProperties = do_CreateInstance("@mozilla.org/properties;1");
|
||||
|
||||
mStatusTracker = new imgStatusTracker(nullptr);
|
||||
mStatusTracker = new imgStatusTracker(nullptr, this);
|
||||
|
||||
mURI = aURI;
|
||||
mCurrentURI = aCurrentURI;
|
||||
@ -995,7 +995,7 @@ imgRequest::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctxt,
|
||||
// our own any more.
|
||||
if (mResniffMimeType) {
|
||||
NS_ABORT_IF_FALSE(mIsMultiPartChannel, "Resniffing a non-multipart image");
|
||||
imgStatusTracker* freshTracker = new imgStatusTracker(nullptr);
|
||||
imgStatusTracker* freshTracker = new imgStatusTracker(nullptr, this);
|
||||
freshTracker->AdoptConsumers(mStatusTracker);
|
||||
mStatusTracker = freshTracker;
|
||||
}
|
||||
|
@ -28,8 +28,9 @@ GetResultFromImageStatus(uint32_t aStatus)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
imgStatusTracker::imgStatusTracker(Image* aImage)
|
||||
imgStatusTracker::imgStatusTracker(Image* aImage, imgRequest* aRequest)
|
||||
: mImage(aImage),
|
||||
mRequest(aRequest),
|
||||
mState(0),
|
||||
mImageStatus(imgIRequest::STATUS_NONE),
|
||||
mHadLastPart(false)
|
||||
@ -37,6 +38,7 @@ imgStatusTracker::imgStatusTracker(Image* aImage)
|
||||
|
||||
imgStatusTracker::imgStatusTracker(const imgStatusTracker& aOther)
|
||||
: mImage(aOther.mImage),
|
||||
mRequest(aOther.mRequest),
|
||||
mState(aOther.mState),
|
||||
mImageStatus(aOther.mImageStatus),
|
||||
mHadLastPart(aOther.mHadLastPart)
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
// aImage is the image that this status tracker will pass to the
|
||||
// imgRequestProxys in SyncNotify() and EmulateRequestFinished(), and must be
|
||||
// alive as long as this instance is, because we hold a weak reference to it.
|
||||
imgStatusTracker(mozilla::image::Image* aImage);
|
||||
imgStatusTracker(mozilla::image::Image* aImage, imgRequest* aRequest);
|
||||
imgStatusTracker(const imgStatusTracker& aOther);
|
||||
|
||||
// Image-setter, for imgStatusTrackers created by imgRequest::Init, which
|
||||
@ -167,15 +167,20 @@ public:
|
||||
void RecordUnblockOnload();
|
||||
void SendUnblockOnload(imgRequestProxy* aProxy);
|
||||
|
||||
// Weak pointer getters - no AddRefs.
|
||||
inline mozilla::image::Image* GetImage() const { return mImage; };
|
||||
inline imgRequest* GetRequest() const { return mRequest; };
|
||||
|
||||
private:
|
||||
friend class imgStatusNotifyRunnable;
|
||||
friend class imgRequestNotifyRunnable;
|
||||
|
||||
nsCOMPtr<nsIRunnable> mRequestRunnable;
|
||||
|
||||
// A weak pointer to the Image, because it owns us, and we
|
||||
// can't create a cycle.
|
||||
// Weak pointers to the image and request. The request owns the image, and
|
||||
// the image (or the request, if there's no image) owns the status tracker.
|
||||
mozilla::image::Image* mImage;
|
||||
imgRequest* mRequest;
|
||||
uint32_t mState;
|
||||
uint32_t mImageStatus;
|
||||
bool mHadLastPart;
|
||||
|
Loading…
Reference in New Issue
Block a user