Skip to content

Commit

Permalink
Bug 1676760 - Remove ParentProcessVsyncNotifier. r=smaug
Browse files Browse the repository at this point in the history
Seems excessive to have a separate class for this, it really just calls a method on a different thread.

Differential Revision: https://phabricator.services.mozilla.com/D139766
  • Loading branch information
mstange committed Mar 1, 2022
1 parent 4062a11 commit 3865c1a
Showing 1 changed file with 6 additions and 33 deletions.
39 changes: 6 additions & 33 deletions layout/base/nsRefreshDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

#include "nsRefreshDriver.h"
#include "nsThreadUtils.h"

#ifdef XP_WIN
# include <windows.h>
Expand Down Expand Up @@ -494,33 +495,6 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer {
MOZ_ASSERT(NS_IsMainThread());
}

class ParentProcessVsyncNotifier final : public Runnable,
public nsIRunnablePriority {
public:
explicit ParentProcessVsyncNotifier(RefreshDriverVsyncObserver* aObserver)
: Runnable(
"VsyncRefreshDriverTimer::RefreshDriverVsyncObserver::"
"ParentProcessVsyncNotifier"),
mObserver(aObserver) {}

NS_DECL_ISUPPORTS_INHERITED

NS_IMETHOD Run() override {
MOZ_ASSERT(NS_IsMainThread());
mObserver->NotifyVsyncOnMainThread();
return NS_OK;
}

NS_IMETHOD GetPriority(uint32_t* aPriority) override {
*aPriority = nsIRunnablePriority::PRIORITY_VSYNC;
return NS_OK;
}

private:
~ParentProcessVsyncNotifier() = default;
RefPtr<RefreshDriverVsyncObserver> mObserver;
};

bool NotifyVsync(const VsyncEvent& aVsync) override {
// Compress vsync notifications such that only 1 may run at a time
// This is so that we don't flood the refresh driver with vsync messages
Expand Down Expand Up @@ -548,7 +522,11 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer {
// thread.
// TODO: On Linux Wayland, the vsync thread is currently the main thread,
// and yet we still dispatch the runnable. Do we need to?
nsCOMPtr<nsIRunnable> vsyncEvent = new ParentProcessVsyncNotifier(this);
nsCOMPtr<nsIRunnable> vsyncEvent = new PrioritizableRunnable(
NS_NewRunnableFunction(
"VsyncRefreshDriverTimer::NotifyVsyncOnMainThread",
[self = RefPtr{this}]() { self->NotifyVsyncOnMainThread(); }),
nsIRunnablePriority::PRIORITY_VSYNC);
NS_DispatchToMainThread(vsyncEvent);
return true;
}
Expand Down Expand Up @@ -823,11 +801,6 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer {
bool mIsTicking = false;
}; // VsyncRefreshDriverTimer

NS_IMPL_ISUPPORTS_INHERITED(
VsyncRefreshDriverTimer::RefreshDriverVsyncObserver::
ParentProcessVsyncNotifier,
Runnable, nsIRunnablePriority)

/**
* Since the content process takes some time to setup
* the vsync IPC connection, this timer is used
Expand Down

0 comments on commit 3865c1a

Please sign in to comment.