From b1c05068b88e25aad9f9611c07c7c70effafd324 Mon Sep 17 00:00:00 2001 From: Andrew Osmond Date: Wed, 7 Feb 2018 07:27:27 -0500 Subject: [PATCH] Bug 1383682 - Part 2. Rename IProgressObserver::SetNotificationsDeferred to make purpose clear. r=tnikkel IProgressObserver::SetNotificationsDeferred is now used just for ProgressTracker to track when there is a pending notification for an observer. It has been renamed to MarkPendingNotify and ClearPendingNotify to make a clear distinction. --- image/IProgressObserver.h | 3 ++- image/MultipartImage.cpp | 17 ++++++++++++----- image/MultipartImage.h | 5 +++-- image/ProgressTracker.cpp | 10 +++++----- image/imgRequestProxy.cpp | 2 +- image/imgRequestProxy.h | 12 ++++++++---- 6 files changed, 31 insertions(+), 18 deletions(-) diff --git a/image/IProgressObserver.h b/image/IProgressObserver.h index 329586a27172..4068c25dccc3 100644 --- a/image/IProgressObserver.h +++ b/image/IProgressObserver.h @@ -43,7 +43,8 @@ public: // Other, internal-only methods: virtual void SetHasImage() = 0; virtual bool NotificationsDeferred() const = 0; - virtual void SetNotificationsDeferred(bool aDeferNotifications) = 0; + virtual void MarkPendingNotify() = 0; + virtual void ClearPendingNotify() = 0; virtual already_AddRefed GetEventTarget() const { diff --git a/image/MultipartImage.cpp b/image/MultipartImage.cpp index d0fdb58a962f..3a9d0ef04f79 100644 --- a/image/MultipartImage.cpp +++ b/image/MultipartImage.cpp @@ -95,7 +95,8 @@ public: // Other notifications are ignored. virtual void SetHasImage() override { } virtual bool NotificationsDeferred() const override { return false; } - virtual void SetNotificationsDeferred(bool) override { } + virtual void MarkPendingNotify() override { } + virtual void ClearPendingNotify() override { } private: virtual ~NextPartObserver() { } @@ -122,7 +123,7 @@ private: MultipartImage::MultipartImage(Image* aFirstPart) : ImageWrapper(aFirstPart) - , mDeferNotifications(false) + , mPendingNotify(false) { mNextPartObserver = new NextPartObserver(this); } @@ -333,13 +334,19 @@ MultipartImage::SetHasImage() bool MultipartImage::NotificationsDeferred() const { - return mDeferNotifications; + return mPendingNotify; } void -MultipartImage::SetNotificationsDeferred(bool aDeferNotifications) +MultipartImage::MarkPendingNotify() { - mDeferNotifications = aDeferNotifications; + mPendingNotify = true; +} + +void +MultipartImage::ClearPendingNotify() +{ + mPendingNotify = false; } } // namespace image diff --git a/image/MultipartImage.h b/image/MultipartImage.h index e26877ccd4e0..d3d0647a46b0 100644 --- a/image/MultipartImage.h +++ b/image/MultipartImage.h @@ -59,7 +59,8 @@ public: virtual void OnLoadComplete(bool aLastPart) override; virtual void SetHasImage() override; virtual bool NotificationsDeferred() const override; - virtual void SetNotificationsDeferred(bool aDeferNotifications) override; + virtual void MarkPendingNotify() override; + virtual void ClearPendingNotify() override; protected: virtual ~MultipartImage(); @@ -76,7 +77,7 @@ private: RefPtr mTracker; RefPtr mNextPartObserver; RefPtr mNextPart; - bool mDeferNotifications : 1; + bool mPendingNotify : 1; }; } // namespace image diff --git a/image/ProgressTracker.cpp b/image/ProgressTracker.cpp index d34e96d6ec5a..d0fc77821387 100644 --- a/image/ProgressTracker.cpp +++ b/image/ProgressTracker.cpp @@ -141,7 +141,7 @@ class AsyncNotifyRunnable : public Runnable MOZ_ASSERT(NS_IsMainThread(), "Should be running on the main thread"); MOZ_ASSERT(mTracker, "mTracker should not be null"); for (uint32_t i = 0; i < mObservers.Length(); ++i) { - mObservers[i]->SetNotificationsDeferred(false); + mObservers[i]->ClearPendingNotify(); mTracker->SyncNotify(mObservers[i]); } @@ -190,7 +190,7 @@ ProgressTracker::Notify(IProgressObserver* aObserver) } } - aObserver->SetNotificationsDeferred(true); + aObserver->MarkPendingNotify(); // If we have an existing runnable that we can use, we just append this // observer to its list of observers to be notified. This ensures we don't @@ -226,7 +226,7 @@ class AsyncNotifyCurrentStateRunnable : public Runnable NS_IMETHOD Run() override { MOZ_ASSERT(NS_IsMainThread(), "Should be running on the main thread"); - mObserver->SetNotificationsDeferred(false); + mObserver->ClearPendingNotify(); mProgressTracker->SyncNotify(mObserver); return NS_OK; @@ -261,7 +261,7 @@ ProgressTracker::NotifyCurrentState(IProgressObserver* aObserver) "ProgressTracker::NotifyCurrentState", "uri", spec.get()); } - aObserver->SetNotificationsDeferred(true); + aObserver->MarkPendingNotify(); nsCOMPtr ev = new AsyncNotifyCurrentStateRunnable(this, aObserver); @@ -526,7 +526,7 @@ ProgressTracker::RemoveObserver(IProgressObserver* aObserver) if (aObserver->NotificationsDeferred() && runnable) { runnable->RemoveObserver(aObserver); - aObserver->SetNotificationsDeferred(false); + aObserver->ClearPendingNotify(); } return removed; diff --git a/image/imgRequestProxy.cpp b/image/imgRequestProxy.cpp index f0c278955872..90a7caeb5b46 100644 --- a/image/imgRequestProxy.cpp +++ b/image/imgRequestProxy.cpp @@ -120,7 +120,7 @@ imgRequestProxy::imgRequestProxy() : mForceDispatchLoadGroup(false), mListenerIsStrongRef(false), mDecodeRequested(false), - mDeferNotifications(false), + mPendingNotify(false), mValidating(false), mHadListener(false), mHadDispatch(false) diff --git a/image/imgRequestProxy.h b/image/imgRequestProxy.h index 287a72239c2b..c7ca46482e57 100644 --- a/image/imgRequestProxy.h +++ b/image/imgRequestProxy.h @@ -115,11 +115,15 @@ public: // an event it has scheduled has been fired and/or validation is complete. virtual bool NotificationsDeferred() const override { - return IsValidating() || mDeferNotifications; + return IsValidating() || mPendingNotify; } - virtual void SetNotificationsDeferred(bool aDeferNotifications) override + virtual void MarkPendingNotify() override { - mDeferNotifications = aDeferNotifications; + mPendingNotify = true; + } + virtual void ClearPendingNotify() override + { + mPendingNotify = false; } bool IsValidating() const { @@ -250,7 +254,7 @@ private: // Whether we want to defer our notifications by the non-virtual Observer // interfaces as image loads proceed. - bool mDeferNotifications : 1; + bool mPendingNotify : 1; bool mValidating : 1; bool mHadListener : 1; bool mHadDispatch : 1;