Backed out changeset 5f97bf645c13 (bug 1157343) for tp crashes.

This commit is contained in:
Ryan VanderMeulen 2015-04-24 10:09:23 -04:00
parent 96062ef95d
commit 61750cf7e7
2 changed files with 16 additions and 28 deletions

View File

@ -87,7 +87,6 @@ CheckProgressConsistency(Progress aProgress)
void void
ProgressTracker::SetImage(Image* aImage) ProgressTracker::SetImage(Image* aImage)
{ {
MutexAutoLock lock(mImageMutex);
MOZ_ASSERT(aImage, "Setting null image"); MOZ_ASSERT(aImage, "Setting null image");
MOZ_ASSERT(!mImage, "Setting image when we already have one"); MOZ_ASSERT(!mImage, "Setting image when we already have one");
mImage = aImage; mImage = aImage;
@ -96,7 +95,6 @@ ProgressTracker::SetImage(Image* aImage)
void void
ProgressTracker::ResetImage() ProgressTracker::ResetImage()
{ {
MutexAutoLock lock(mImageMutex);
MOZ_ASSERT(mImage, "Resetting image when it's already null!"); MOZ_ASSERT(mImage, "Resetting image when it's already null!");
mImage = nullptr; mImage = nullptr;
} }
@ -185,9 +183,8 @@ ProgressTracker::Notify(IProgressObserver* aObserver)
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
#ifdef PR_LOGGING #ifdef PR_LOGGING
nsRefPtr<Image> image = GetImage(); if (mImage && mImage->GetURI()) {
if (image && image->GetURI()) { nsRefPtr<ImageURL> uri(mImage->GetURI());
nsRefPtr<ImageURL> uri(image->GetURI());
nsAutoCString spec; nsAutoCString spec;
uri->GetSpec(spec); uri->GetSpec(spec);
LOG_FUNC_WITH_PARAM(GetImgLog(), LOG_FUNC_WITH_PARAM(GetImgLog(),
@ -254,10 +251,9 @@ ProgressTracker::NotifyCurrentState(IProgressObserver* aObserver)
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
#ifdef PR_LOGGING #ifdef PR_LOGGING
nsRefPtr<Image> image = GetImage();
nsAutoCString spec; nsAutoCString spec;
if (image && image->GetURI()) { if (mImage && mImage->GetURI()) {
image->GetURI()->GetSpec(spec); mImage->GetURI()->GetSpec(spec);
} }
LOG_FUNC_WITH_PARAM(GetImgLog(), LOG_FUNC_WITH_PARAM(GetImgLog(),
"ProgressTracker::NotifyCurrentState", "uri", spec.get()); "ProgressTracker::NotifyCurrentState", "uri", spec.get());
@ -371,7 +367,7 @@ ProgressTracker::SyncNotifyProgress(Progress aProgress,
CheckProgressConsistency(mProgress); CheckProgressConsistency(mProgress);
// Send notifications. // Send notifications.
SyncNotifyInternal(mObservers, HasImage(), progress, aInvalidRect); SyncNotifyInternal(mObservers, !!mImage, progress, aInvalidRect);
if (progress & FLAG_HAS_ERROR) { if (progress & FLAG_HAS_ERROR) {
FireFailureNotification(); FireFailureNotification();
@ -383,21 +379,19 @@ ProgressTracker::SyncNotify(IProgressObserver* aObserver)
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
nsRefPtr<Image> image = GetImage();
#ifdef PR_LOGGING #ifdef PR_LOGGING
nsAutoCString spec; nsAutoCString spec;
if (image && image->GetURI()) { if (mImage && mImage->GetURI()) {
image->GetURI()->GetSpec(spec); mImage->GetURI()->GetSpec(spec);
} }
LOG_SCOPE_WITH_PARAM(GetImgLog(), LOG_SCOPE_WITH_PARAM(GetImgLog(),
"ProgressTracker::SyncNotify", "uri", spec.get()); "ProgressTracker::SyncNotify", "uri", spec.get());
#endif #endif
nsIntRect rect; nsIntRect rect;
if (image) { if (mImage) {
if (NS_FAILED(image->GetWidth(&rect.width)) || if (NS_FAILED(mImage->GetWidth(&rect.width)) ||
NS_FAILED(image->GetHeight(&rect.height))) { NS_FAILED(mImage->GetHeight(&rect.height))) {
// Either the image has no intrinsic size, or it has an error. // Either the image has no intrinsic size, or it has an error.
rect = GetMaxSizedIntRect(); rect = GetMaxSizedIntRect();
} }
@ -405,7 +399,7 @@ ProgressTracker::SyncNotify(IProgressObserver* aObserver)
ObserverArray array; ObserverArray array;
array.AppendElement(aObserver); array.AppendElement(aObserver);
SyncNotifyInternal(array, !!image, mProgress, rect); SyncNotifyInternal(array, !!mImage, mProgress, rect);
} }
void void
@ -517,12 +511,11 @@ ProgressTracker::FireFailureNotification()
// Some kind of problem has happened with image decoding. // Some kind of problem has happened with image decoding.
// Report the URI to net:failed-to-process-uri-conent observers. // Report the URI to net:failed-to-process-uri-conent observers.
nsRefPtr<Image> image = GetImage(); if (mImage) {
if (image) {
// Should be on main thread, so ok to create a new nsIURI. // Should be on main thread, so ok to create a new nsIURI.
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
{ {
nsRefPtr<ImageURL> threadsafeUriData = image->GetURI(); nsRefPtr<ImageURL> threadsafeUriData = mImage->GetURI();
uri = threadsafeUriData ? threadsafeUriData->ToIURI() : nullptr; uri = threadsafeUriData ? threadsafeUriData->ToIURI() : nullptr;
} }
if (uri) { if (uri) {

View File

@ -7,7 +7,6 @@
#ifndef mozilla_image_src_ProgressTracker_h #ifndef mozilla_image_src_ProgressTracker_h
#define mozilla_image_src_ProgressTracker_h #define mozilla_image_src_ProgressTracker_h
#include "mozilla/Mutex.h"
#include "mozilla/RefPtr.h" #include "mozilla/RefPtr.h"
#include "mozilla/WeakPtr.h" #include "mozilla/WeakPtr.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
@ -77,15 +76,13 @@ public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ProgressTracker) NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ProgressTracker)
ProgressTracker() ProgressTracker()
: mImageMutex("ProgressTracker::mImage") : mImage(nullptr)
, mImage(nullptr)
, mProgress(NoProgress) , mProgress(NoProgress)
{ } { }
bool HasImage() const { MutexAutoLock lock(mImageMutex); return mImage; } bool HasImage() const { return mImage; }
already_AddRefed<Image> GetImage() const already_AddRefed<Image> GetImage() const
{ {
MutexAutoLock lock(mImageMutex);
nsRefPtr<Image> image = mImage; nsRefPtr<Image> image = mImage;
return image.forget(); return image.forget();
} }
@ -193,9 +190,7 @@ private:
nsCOMPtr<nsIRunnable> mRunnable; nsCOMPtr<nsIRunnable> mRunnable;
// mImage is a weak ref; it should be set to null when the image goes out of // This weak ref should be set null when the image goes out of scope.
// scope. mImageMutex protects mImage.
mutable Mutex mImageMutex;
Image* mImage; Image* mImage;
// List of observers attached to the image. Each observer represents a // List of observers attached to the image. Each observer represents a