зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 5f97bf645c13 (bug 1157343) for tp crashes.
This commit is contained in:
Родитель
96062ef95d
Коммит
61750cf7e7
|
@ -87,7 +87,6 @@ CheckProgressConsistency(Progress aProgress)
|
|||
void
|
||||
ProgressTracker::SetImage(Image* aImage)
|
||||
{
|
||||
MutexAutoLock lock(mImageMutex);
|
||||
MOZ_ASSERT(aImage, "Setting null image");
|
||||
MOZ_ASSERT(!mImage, "Setting image when we already have one");
|
||||
mImage = aImage;
|
||||
|
@ -96,7 +95,6 @@ ProgressTracker::SetImage(Image* aImage)
|
|||
void
|
||||
ProgressTracker::ResetImage()
|
||||
{
|
||||
MutexAutoLock lock(mImageMutex);
|
||||
MOZ_ASSERT(mImage, "Resetting image when it's already null!");
|
||||
mImage = nullptr;
|
||||
}
|
||||
|
@ -185,9 +183,8 @@ ProgressTracker::Notify(IProgressObserver* aObserver)
|
|||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
nsRefPtr<Image> image = GetImage();
|
||||
if (image && image->GetURI()) {
|
||||
nsRefPtr<ImageURL> uri(image->GetURI());
|
||||
if (mImage && mImage->GetURI()) {
|
||||
nsRefPtr<ImageURL> uri(mImage->GetURI());
|
||||
nsAutoCString spec;
|
||||
uri->GetSpec(spec);
|
||||
LOG_FUNC_WITH_PARAM(GetImgLog(),
|
||||
|
@ -254,10 +251,9 @@ ProgressTracker::NotifyCurrentState(IProgressObserver* aObserver)
|
|||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
nsRefPtr<Image> image = GetImage();
|
||||
nsAutoCString spec;
|
||||
if (image && image->GetURI()) {
|
||||
image->GetURI()->GetSpec(spec);
|
||||
if (mImage && mImage->GetURI()) {
|
||||
mImage->GetURI()->GetSpec(spec);
|
||||
}
|
||||
LOG_FUNC_WITH_PARAM(GetImgLog(),
|
||||
"ProgressTracker::NotifyCurrentState", "uri", spec.get());
|
||||
|
@ -371,7 +367,7 @@ ProgressTracker::SyncNotifyProgress(Progress aProgress,
|
|||
CheckProgressConsistency(mProgress);
|
||||
|
||||
// Send notifications.
|
||||
SyncNotifyInternal(mObservers, HasImage(), progress, aInvalidRect);
|
||||
SyncNotifyInternal(mObservers, !!mImage, progress, aInvalidRect);
|
||||
|
||||
if (progress & FLAG_HAS_ERROR) {
|
||||
FireFailureNotification();
|
||||
|
@ -383,21 +379,19 @@ ProgressTracker::SyncNotify(IProgressObserver* aObserver)
|
|||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
nsRefPtr<Image> image = GetImage();
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
nsAutoCString spec;
|
||||
if (image && image->GetURI()) {
|
||||
image->GetURI()->GetSpec(spec);
|
||||
if (mImage && mImage->GetURI()) {
|
||||
mImage->GetURI()->GetSpec(spec);
|
||||
}
|
||||
LOG_SCOPE_WITH_PARAM(GetImgLog(),
|
||||
"ProgressTracker::SyncNotify", "uri", spec.get());
|
||||
#endif
|
||||
|
||||
nsIntRect rect;
|
||||
if (image) {
|
||||
if (NS_FAILED(image->GetWidth(&rect.width)) ||
|
||||
NS_FAILED(image->GetHeight(&rect.height))) {
|
||||
if (mImage) {
|
||||
if (NS_FAILED(mImage->GetWidth(&rect.width)) ||
|
||||
NS_FAILED(mImage->GetHeight(&rect.height))) {
|
||||
// Either the image has no intrinsic size, or it has an error.
|
||||
rect = GetMaxSizedIntRect();
|
||||
}
|
||||
|
@ -405,7 +399,7 @@ ProgressTracker::SyncNotify(IProgressObserver* aObserver)
|
|||
|
||||
ObserverArray array;
|
||||
array.AppendElement(aObserver);
|
||||
SyncNotifyInternal(array, !!image, mProgress, rect);
|
||||
SyncNotifyInternal(array, !!mImage, mProgress, rect);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -517,12 +511,11 @@ ProgressTracker::FireFailureNotification()
|
|||
|
||||
// Some kind of problem has happened with image decoding.
|
||||
// Report the URI to net:failed-to-process-uri-conent observers.
|
||||
nsRefPtr<Image> image = GetImage();
|
||||
if (image) {
|
||||
if (mImage) {
|
||||
// Should be on main thread, so ok to create a new nsIURI.
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
{
|
||||
nsRefPtr<ImageURL> threadsafeUriData = image->GetURI();
|
||||
nsRefPtr<ImageURL> threadsafeUriData = mImage->GetURI();
|
||||
uri = threadsafeUriData ? threadsafeUriData->ToIURI() : nullptr;
|
||||
}
|
||||
if (uri) {
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#ifndef mozilla_image_src_ProgressTracker_h
|
||||
#define mozilla_image_src_ProgressTracker_h
|
||||
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/WeakPtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
@ -77,15 +76,13 @@ public:
|
|||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ProgressTracker)
|
||||
|
||||
ProgressTracker()
|
||||
: mImageMutex("ProgressTracker::mImage")
|
||||
, mImage(nullptr)
|
||||
: mImage(nullptr)
|
||||
, mProgress(NoProgress)
|
||||
{ }
|
||||
|
||||
bool HasImage() const { MutexAutoLock lock(mImageMutex); return mImage; }
|
||||
bool HasImage() const { return mImage; }
|
||||
already_AddRefed<Image> GetImage() const
|
||||
{
|
||||
MutexAutoLock lock(mImageMutex);
|
||||
nsRefPtr<Image> image = mImage;
|
||||
return image.forget();
|
||||
}
|
||||
|
@ -193,9 +190,7 @@ private:
|
|||
|
||||
nsCOMPtr<nsIRunnable> mRunnable;
|
||||
|
||||
// mImage is a weak ref; it should be set to null when the image goes out of
|
||||
// scope. mImageMutex protects mImage.
|
||||
mutable Mutex mImageMutex;
|
||||
// This weak ref should be set null when the image goes out of scope.
|
||||
Image* mImage;
|
||||
|
||||
// List of observers attached to the image. Each observer represents a
|
||||
|
|
Загрузка…
Ссылка в новой задаче