зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1741799 - Remove SupportsThreadSafeWeakPtr from WinWindowOcclusionTracker r=nical,gfx-reviewers
SupportsThreadSafeWeakPtr is not necessary for current WinWindowOcclusionTracker. Differential Revision: https://phabricator.services.mozilla.com/D131469
This commit is contained in:
Родитель
2dc3b69cde
Коммит
79ce913ffa
|
@ -86,16 +86,16 @@ class OcclusionUpdateRunnable : public CancelableRunnable {
|
|||
|
||||
class UpdateOcclusionStateRunnable : public Runnable {
|
||||
public:
|
||||
UpdateOcclusionStateRunnable(
|
||||
ThreadSafeWeakPtr<WinWindowOcclusionTracker> aOcclusionTracker,
|
||||
std::unordered_map<HWND, OcclusionState>* aMap, bool aShowAllWindows)
|
||||
UpdateOcclusionStateRunnable(std::unordered_map<HWND, OcclusionState>* aMap,
|
||||
bool aShowAllWindows)
|
||||
: Runnable("UpdateOcclusionStateRunnable"),
|
||||
mOcclusionTracker(aOcclusionTracker),
|
||||
mMap(aMap),
|
||||
mShowAllWindows(aShowAllWindows) {}
|
||||
|
||||
NS_IMETHOD Run() override {
|
||||
auto tracker = RefPtr<WinWindowOcclusionTracker>(mOcclusionTracker);
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
auto* tracker = WinWindowOcclusionTracker::Get();
|
||||
if (tracker) {
|
||||
tracker->UpdateOcclusionState(mMap, mShowAllWindows);
|
||||
}
|
||||
|
@ -103,7 +103,6 @@ class UpdateOcclusionStateRunnable : public Runnable {
|
|||
}
|
||||
|
||||
private:
|
||||
ThreadSafeWeakPtr<WinWindowOcclusionTracker> mOcclusionTracker;
|
||||
std::unordered_map<HWND, OcclusionState>* const mMap;
|
||||
const bool mShowAllWindows;
|
||||
};
|
||||
|
@ -334,7 +333,7 @@ already_AddRefed<SerializedRunnable> SerializedTaskDispatcher::GetNextTask(
|
|||
StaticRefPtr<WinWindowOcclusionTracker> WinWindowOcclusionTracker::sTracker;
|
||||
|
||||
/* static */
|
||||
RefPtr<WinWindowOcclusionTracker> WinWindowOcclusionTracker::Get() {
|
||||
WinWindowOcclusionTracker* WinWindowOcclusionTracker::Get() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
return sTracker;
|
||||
}
|
||||
|
@ -762,9 +761,8 @@ WinWindowOcclusionTracker::WindowOcclusionCalculator::
|
|||
MOZ_ASSERT(NS_IsMainThread());
|
||||
LOG(LogLevel::Info, "WindowOcclusionCalculator()");
|
||||
|
||||
auto tracker = WinWindowOcclusionTracker::Get();
|
||||
mSerializedTaskDispatcher = tracker->GetSerializedTaskDispatcher();
|
||||
mOcclusionTracker = ThreadSafeWeakPtr<WinWindowOcclusionTracker>(tracker);
|
||||
mSerializedTaskDispatcher =
|
||||
WinWindowOcclusionTracker::Get()->GetSerializedTaskDispatcher();
|
||||
}
|
||||
|
||||
WinWindowOcclusionTracker::WindowOcclusionCalculator::
|
||||
|
@ -989,7 +987,7 @@ void WinWindowOcclusionTracker::WindowOcclusionCalculator::
|
|||
}
|
||||
|
||||
RefPtr<Runnable> runnable = new UpdateOcclusionStateRunnable(
|
||||
mOcclusionTracker, &mRootWindowHwndsOcclusionState, mShowingThumbnails);
|
||||
&mRootWindowHwndsOcclusionState, mShowingThumbnails);
|
||||
mSerializedTaskDispatcher->PostTaskToMain(runnable.forget());
|
||||
}
|
||||
|
||||
|
@ -1205,8 +1203,7 @@ void WinWindowOcclusionTracker::WindowOcclusionCalculator::
|
|||
mShowingThumbnails = true;
|
||||
|
||||
RefPtr<Runnable> runnable = new UpdateOcclusionStateRunnable(
|
||||
mOcclusionTracker, &mRootWindowHwndsOcclusionState,
|
||||
mShowingThumbnails);
|
||||
&mRootWindowHwndsOcclusionState, mShowingThumbnails);
|
||||
mSerializedTaskDispatcher->PostTaskToMain(runnable.forget());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,16 +39,13 @@ class UpdateOcclusionStateRunnable;
|
|||
|
||||
// This class handles window occlusion tracking by using HWND.
|
||||
// Implementation is borrowed from chromium's NativeWindowOcclusionTrackerWin.
|
||||
class WinWindowOcclusionTracker final
|
||||
: public SupportsThreadSafeWeakPtr<WinWindowOcclusionTracker>,
|
||||
public DisplayStatusListener,
|
||||
class WinWindowOcclusionTracker final : public DisplayStatusListener,
|
||||
public SessionChangeListener {
|
||||
public:
|
||||
MOZ_DECLARE_THREADSAFEWEAKREFERENCE_TYPENAME(WinWindowOcclusionTracker)
|
||||
MOZ_DECLARE_REFCOUNTED_TYPENAME(WinWindowOcclusionTracker)
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(WinWindowOcclusionTracker)
|
||||
|
||||
/// Can only be called from the main thread.
|
||||
static RefPtr<WinWindowOcclusionTracker> Get();
|
||||
static WinWindowOcclusionTracker* Get();
|
||||
|
||||
/// Can only be called from the main thread.
|
||||
static void Ensure();
|
||||
|
@ -62,8 +59,6 @@ class WinWindowOcclusionTracker final
|
|||
/// Can be called from any thread.
|
||||
static bool IsInWinWindowOcclusionThread();
|
||||
|
||||
virtual ~WinWindowOcclusionTracker();
|
||||
|
||||
// Enables notifying to widget via NotifyOcclusionState() when the occlusion
|
||||
// state has been computed.
|
||||
void Enable(nsBaseWidget* aWindow, HWND aHwnd);
|
||||
|
@ -86,6 +81,7 @@ class WinWindowOcclusionTracker final
|
|||
friend class ::WinWindowOcclusionTrackerInteractiveTest;
|
||||
|
||||
explicit WinWindowOcclusionTracker(base::Thread* aThread);
|
||||
virtual ~WinWindowOcclusionTracker();
|
||||
|
||||
// This class computes the occlusion state of the tracked windows.
|
||||
// It runs on a separate thread, and notifies the main thread of
|
||||
|
@ -245,8 +241,6 @@ class WinWindowOcclusionTracker final
|
|||
// Used to serialize tasks related to mRootWindowHwndsOcclusionState.
|
||||
RefPtr<SerializedTaskDispatcher> mSerializedTaskDispatcher;
|
||||
|
||||
ThreadSafeWeakPtr<WinWindowOcclusionTracker> mOcclusionTracker;
|
||||
|
||||
friend class OcclusionUpdateRunnable;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче