mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 08:15:31 +00:00
Bug 1637433 - P2. Replace ShutdownBackgroundThreadRunnable with simple task for clarity. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D74993
This commit is contained in:
parent
af15c09ca9
commit
4629c7f6b2
@ -98,7 +98,6 @@ class ParentImpl final : public BackgroundParentImpl {
|
||||
|
||||
private:
|
||||
class ShutdownObserver;
|
||||
class ShutdownBackgroundThreadRunnable;
|
||||
class ForceCloseBackgroundActorsRunnable;
|
||||
class ConnectActorRunnable;
|
||||
class CreateActorHelper;
|
||||
@ -551,20 +550,6 @@ class ParentImpl::ShutdownObserver final : public nsIObserver {
|
||||
~ShutdownObserver() { AssertIsOnMainThread(); }
|
||||
};
|
||||
|
||||
class ParentImpl::ShutdownBackgroundThreadRunnable final : public Runnable {
|
||||
public:
|
||||
ShutdownBackgroundThreadRunnable()
|
||||
: Runnable("Background::ParentImpl::ShutdownBackgroundThreadRunnable") {
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnMainThread();
|
||||
}
|
||||
|
||||
private:
|
||||
~ShutdownBackgroundThreadRunnable() = default;
|
||||
|
||||
NS_DECL_NSIRUNNABLE
|
||||
};
|
||||
|
||||
class ParentImpl::ForceCloseBackgroundActorsRunnable final : public Runnable {
|
||||
nsTArray<ParentImpl*>* mActorArray;
|
||||
|
||||
@ -1367,10 +1352,18 @@ void ParentImpl::ShutdownBackgroundThread() {
|
||||
MOZ_ALWAYS_SUCCEEDS(shutdownTimer->Cancel());
|
||||
}
|
||||
|
||||
// Dispatch this runnable to unregister the thread from the profiler.
|
||||
nsCOMPtr<nsIRunnable> shutdownRunnable =
|
||||
new ShutdownBackgroundThreadRunnable();
|
||||
MOZ_ALWAYS_SUCCEEDS(thread->Dispatch(shutdownRunnable, NS_DISPATCH_NORMAL));
|
||||
// Dispatch this runnable to unregister the PR thread from the profiler.
|
||||
MOZ_ALWAYS_SUCCEEDS(thread->Dispatch(
|
||||
NS_NewRunnableFunction(
|
||||
"Background::ParentImpl::ShutdownBackgroundThreadRunnable",
|
||||
[]() {
|
||||
// It is possible that another background thread was created while
|
||||
// this thread was shutting down. In that case we can't assert
|
||||
// anything about sBackgroundPRThread and we should not modify it
|
||||
// here.
|
||||
sBackgroundPRThread.compareExchange(PR_GetCurrentThread(),
|
||||
nullptr);
|
||||
})));
|
||||
|
||||
MOZ_ALWAYS_SUCCEEDS(thread->Shutdown());
|
||||
}
|
||||
@ -1468,18 +1461,6 @@ ParentImpl::ShutdownObserver::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ParentImpl::ShutdownBackgroundThreadRunnable::Run() {
|
||||
AssertIsInMainOrSocketProcess();
|
||||
|
||||
// It is possible that another background thread was created while this thread
|
||||
// was shutting down. In that case we can't assert anything about
|
||||
// sBackgroundPRThread and we should not modify it here.
|
||||
sBackgroundPRThread.compareExchange(PR_GetCurrentThread(), nullptr);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ParentImpl::ForceCloseBackgroundActorsRunnable::Run() {
|
||||
AssertIsInMainOrSocketProcess();
|
||||
|
Loading…
Reference in New Issue
Block a user