mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
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.
This commit is contained in:
parent
dab9b6216c
commit
b1c05068b8
@ -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<nsIEventTarget> GetEventTarget() const
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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<ProgressTracker> mTracker;
|
||||
RefPtr<NextPartObserver> mNextPartObserver;
|
||||
RefPtr<Image> mNextPart;
|
||||
bool mDeferNotifications : 1;
|
||||
bool mPendingNotify : 1;
|
||||
};
|
||||
|
||||
} // namespace image
|
||||
|
@ -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<nsIRunnable> 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;
|
||||
|
@ -120,7 +120,7 @@ imgRequestProxy::imgRequestProxy() :
|
||||
mForceDispatchLoadGroup(false),
|
||||
mListenerIsStrongRef(false),
|
||||
mDecodeRequested(false),
|
||||
mDeferNotifications(false),
|
||||
mPendingNotify(false),
|
||||
mValidating(false),
|
||||
mHadListener(false),
|
||||
mHadDispatch(false)
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user