Bug 1383682 - Part 2. Rename IProgressObserver::SetNotificationsDeferred to make purpose clear. r=tnikkel
authorAndrew Osmond <aosmond@mozilla.com>
Wed, 07 Feb 2018 07:27:27 -0500
changeset 457773 62497967f092c6c76778ddc1534f110d4583eeb9
parent 457772 c657d87a001166bf42e47580c37919b8b018238d
child 457774 30ee5a21a6a14cf3bb4e043b3129280a72e151ea
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel
bugs1383682
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
image/MultipartImage.cpp
image/MultipartImage.h
image/ProgressTracker.cpp
image/imgRequestProxy.cpp
image/imgRequestProxy.h
--- a/image/IProgressObserver.h
+++ b/image/IProgressObserver.h
@@ -38,17 +38,18 @@ public:
 
   // imgINotificationObserver methods:
   virtual void Notify(int32_t aType, const nsIntRect* aRect = nullptr) = 0;
   virtual void OnLoadComplete(bool aLastPart) = 0;
 
   // 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<nsIEventTarget> GetEventTarget() const
   {
     return nullptr;
   }
 
 protected:
   virtual ~IProgressObserver() { }
--- a/image/MultipartImage.cpp
+++ b/image/MultipartImage.cpp
@@ -90,17 +90,18 @@ public:
     if (tracker->GetProgress() & FLAG_HAS_ERROR) {
       FinishObserving();
     }
   }
 
   // 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() { }
 
   void FinishObserving()
   {
     MOZ_ASSERT(mImage);
 
@@ -117,17 +118,17 @@ private:
 
 
 ///////////////////////////////////////////////////////////////////////////////
 // Implementation
 ///////////////////////////////////////////////////////////////////////////////
 
 MultipartImage::MultipartImage(Image* aFirstPart)
   : ImageWrapper(aFirstPart)
-  , mDeferNotifications(false)
+  , mPendingNotify(false)
 {
   mNextPartObserver = new NextPartObserver(this);
 }
 
 void
 MultipartImage::Init()
 {
   MOZ_ASSERT(NS_IsMainThread());
@@ -328,19 +329,25 @@ void
 MultipartImage::SetHasImage()
 {
   mTracker->OnImageAvailable();
 }
 
 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
 } // namespace mozilla
--- a/image/MultipartImage.h
+++ b/image/MultipartImage.h
@@ -54,32 +54,33 @@ public:
 #endif
 
   // Overridden IProgressObserver methods:
   virtual void Notify(int32_t aType,
                       const nsIntRect* aRect = nullptr) override;
   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();
 
 private:
   friend class ImageFactory;
   friend class NextPartObserver;
 
   explicit MultipartImage(Image* aFirstPart);
   void Init();
 
   void FinishTransition();
 
   RefPtr<ProgressTracker> mTracker;
   RefPtr<NextPartObserver> mNextPartObserver;
   RefPtr<Image> mNextPart;
-  bool mDeferNotifications : 1;
+  bool mPendingNotify : 1;
 };
 
 } // namespace image
 } // namespace mozilla
 
 #endif // mozilla_image_MultipartImage_h
--- a/image/ProgressTracker.cpp
+++ b/image/ProgressTracker.cpp
@@ -136,17 +136,17 @@ class AsyncNotifyRunnable : public Runna
       mObservers.AppendElement(aObserver);
     }
 
     NS_IMETHOD Run() override
     {
       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]);
       }
 
       mTracker->mRunnable = nullptr;
       return NS_OK;
     }
 
     void AddObserver(IProgressObserver* aObserver)
@@ -185,17 +185,17 @@ ProgressTracker::Notify(IProgressObserve
       LOG_FUNC_WITH_PARAM(gImgLog,
                           "ProgressTracker::Notify async", "uri", spec.get());
     } else {
       LOG_FUNC_WITH_PARAM(gImgLog,
                           "ProgressTracker::Notify async", "uri", "<unknown>");
     }
   }
 
-  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
   // unnecessarily delay onload.
   AsyncNotifyRunnable* runnable =
     static_cast<AsyncNotifyRunnable*>(mRunnable.get());
 
   if (runnable) {
@@ -221,17 +221,17 @@ class AsyncNotifyCurrentStateRunnable : 
       MOZ_ASSERT(mProgressTracker, "mProgressTracker should not be null");
       MOZ_ASSERT(mObserver, "mObserver should not be null");
       mImage = mProgressTracker->GetImage();
     }
 
     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;
     }
 
   private:
     RefPtr<ProgressTracker> mProgressTracker;
     RefPtr<IProgressObserver> mObserver;
@@ -256,17 +256,17 @@ ProgressTracker::NotifyCurrentState(IPro
     nsAutoCString spec;
     if (image && image->GetURI()) {
       image->GetURI()->GetSpec(spec);
     }
     LOG_FUNC_WITH_PARAM(gImgLog,
                         "ProgressTracker::NotifyCurrentState", "uri", spec.get());
   }
 
-  aObserver->SetNotificationsDeferred(true);
+  aObserver->MarkPendingNotify();
 
   nsCOMPtr<nsIRunnable> ev = new AsyncNotifyCurrentStateRunnable(this,
                                                                  aObserver);
   mEventTarget->Dispatch(ev.forget(), NS_DISPATCH_NORMAL);
 }
 
 /**
  * ImageObserverNotifier is a helper type that abstracts over the difference
@@ -521,17 +521,17 @@ ProgressTracker::RemoveObserver(IProgres
 
   // Make sure we don't give callbacks to an observer that isn't interested in
   // them any more.
   AsyncNotifyRunnable* runnable =
     static_cast<AsyncNotifyRunnable*>(mRunnable.get());
 
   if (aObserver->NotificationsDeferred() && runnable) {
     runnable->RemoveObserver(aObserver);
-    aObserver->SetNotificationsDeferred(false);
+    aObserver->ClearPendingNotify();
   }
 
   return removed;
 }
 
 uint32_t
 ProgressTracker::ObserverCount() const
 {
--- a/image/imgRequestProxy.cpp
+++ b/image/imgRequestProxy.cpp
@@ -115,17 +115,17 @@ imgRequestProxy::imgRequestProxy() :
   mLoadFlags(nsIRequest::LOAD_NORMAL),
   mLockCount(0),
   mAnimationConsumers(0),
   mCanceled(false),
   mIsInLoadGroup(false),
   mForceDispatchLoadGroup(false),
   mListenerIsStrongRef(false),
   mDecodeRequested(false),
-  mDeferNotifications(false),
+  mPendingNotify(false),
   mValidating(false),
   mHadListener(false),
   mHadDispatch(false)
 {
   /* member initializers and constructor code */
   LOG_FUNC(gImgLog, "imgRequestProxy::imgRequestProxy");
 }
 
--- a/image/imgRequestProxy.h
+++ b/image/imgRequestProxy.h
@@ -110,21 +110,25 @@ public:
 
   // Other, internal-only methods:
   virtual void SetHasImage() override;
 
   // Whether we want notifications from ProgressTracker to be deferred until
   // 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
   {
     return mValidating;
   }
   void MarkValidating();
   void ClearValidating();
 
@@ -245,17 +249,17 @@ private:
   bool mCanceled : 1;
   bool mIsInLoadGroup : 1;
   bool mForceDispatchLoadGroup : 1;
   bool mListenerIsStrongRef : 1;
   bool mDecodeRequested : 1;
 
   // 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;
 };
 
 // Used for static image proxies for which no requests are available, so
 // certain behaviours must be overridden to compensate.
 class imgRequestProxyStatic : public imgRequestProxy