зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1743895: Add names to all TaskQueues, remove no-name constructor r=nika,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D132638
This commit is contained in:
Родитель
33641307ec
Коммит
08f296ee63
|
@ -631,7 +631,7 @@ nsresult MutableBlobStorage::DispatchToIOThread(
|
|||
do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
||||
MOZ_ASSERT(target);
|
||||
|
||||
mTaskQueue = new TaskQueue(target.forget());
|
||||
mTaskQueue = new TaskQueue(target.forget(), "BlobStorage");
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRunnable> runnable(aRunnable);
|
||||
|
|
|
@ -2691,7 +2691,7 @@ nsresult BackgroundRequestChild::PreprocessHelper::Init(
|
|||
// We use a TaskQueue here in order to be sure that the events are dispatched
|
||||
// in the correct order. This is not guaranteed in case we use the I/O thread
|
||||
// directly.
|
||||
mTaskQueue = MakeRefPtr<TaskQueue>(target.forget());
|
||||
mTaskQueue = MakeRefPtr<TaskQueue>(target.forget(), "BackgroundRequestChild");
|
||||
|
||||
ErrorResult errorResult;
|
||||
|
||||
|
|
|
@ -41,8 +41,8 @@ class MP4DemuxerBinding {
|
|||
explicit MP4DemuxerBinding(const char* aFileName = "dash_dashinit.mp4")
|
||||
: resource(new MockMediaResource(aFileName)),
|
||||
mDemuxer(new MP4Demuxer(resource)),
|
||||
mTaskQueue(
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR))),
|
||||
mTaskQueue(new TaskQueue(
|
||||
GetMediaThreadPool(MediaThreadType::SUPERVISOR), "TestMP4Demuxer")),
|
||||
mIndex(0) {
|
||||
EXPECT_EQ(NS_OK, resource->Open());
|
||||
}
|
||||
|
|
|
@ -152,7 +152,8 @@ already_AddRefed<MediaDataEncoder> CreateVideoEncoder(
|
|||
VideoInfo videoInfo(aWidth, aHeight);
|
||||
videoInfo.mMimeType = nsCString(aMimeType);
|
||||
const RefPtr<TaskQueue> taskQueue(
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::PLATFORM_ENCODER)));
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::PLATFORM_ENCODER),
|
||||
"TestMediaDataEncoder"));
|
||||
|
||||
RefPtr<MediaDataEncoder> e;
|
||||
if (aSpecific) {
|
||||
|
|
|
@ -19,7 +19,8 @@ using namespace mozilla;
|
|||
TEST(MediaEventSource, SingleListener)
|
||||
{
|
||||
RefPtr<TaskQueue> queue =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR));
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR),
|
||||
"TestMediaEventSource SingleListener");
|
||||
|
||||
MediaEventProducer<int> source;
|
||||
int i = 0;
|
||||
|
@ -43,7 +44,8 @@ TEST(MediaEventSource, SingleListener)
|
|||
TEST(MediaEventSource, MultiListener)
|
||||
{
|
||||
RefPtr<TaskQueue> queue =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR));
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR),
|
||||
"TestMediaEventSource MultiListener");
|
||||
|
||||
MediaEventProducer<int> source;
|
||||
int i = 0;
|
||||
|
@ -74,7 +76,8 @@ TEST(MediaEventSource, MultiListener)
|
|||
TEST(MediaEventSource, DisconnectAfterNotification)
|
||||
{
|
||||
RefPtr<TaskQueue> queue =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR));
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR),
|
||||
"TestMediaEventSource DisconnectAfterNotification");
|
||||
|
||||
MediaEventProducer<int> source;
|
||||
int i = 0;
|
||||
|
@ -101,7 +104,8 @@ TEST(MediaEventSource, DisconnectAfterNotification)
|
|||
TEST(MediaEventSource, DisconnectBeforeNotification)
|
||||
{
|
||||
RefPtr<TaskQueue> queue =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR));
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR),
|
||||
"TestMediaEventSource DisconnectBeforeNotification");
|
||||
|
||||
MediaEventProducer<int> source;
|
||||
int i = 0;
|
||||
|
@ -133,7 +137,8 @@ TEST(MediaEventSource, DisconnectBeforeNotification)
|
|||
TEST(MediaEventSource, DisconnectAndConnect)
|
||||
{
|
||||
RefPtr<TaskQueue> queue =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR));
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR),
|
||||
"TestMediaEventSource DisconnectAndConnect");
|
||||
|
||||
MediaEventProducerExc<int> source;
|
||||
MediaEventListener listener = source.Connect(queue, []() {});
|
||||
|
@ -148,7 +153,8 @@ TEST(MediaEventSource, DisconnectAndConnect)
|
|||
TEST(MediaEventSource, VoidEventType)
|
||||
{
|
||||
RefPtr<TaskQueue> queue =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR));
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR),
|
||||
"TestMediaEventSource VoidEventType");
|
||||
|
||||
MediaEventProducer<void> source;
|
||||
int i = 0;
|
||||
|
@ -185,7 +191,8 @@ TEST(MediaEventSource, VoidEventType)
|
|||
TEST(MediaEventSource, ListenerType1)
|
||||
{
|
||||
RefPtr<TaskQueue> queue =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR));
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR),
|
||||
"TestMediaEventSource ListenerType1");
|
||||
|
||||
MediaEventProducer<int> source;
|
||||
int i = 0;
|
||||
|
@ -213,7 +220,8 @@ TEST(MediaEventSource, ListenerType1)
|
|||
TEST(MediaEventSource, ListenerType2)
|
||||
{
|
||||
RefPtr<TaskQueue> queue =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR));
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR),
|
||||
"TestMediaEventSource ListenerType2");
|
||||
|
||||
MediaEventProducer<int> source;
|
||||
|
||||
|
@ -263,7 +271,8 @@ struct SomeEvent {
|
|||
TEST(MediaEventSource, CopyEvent1)
|
||||
{
|
||||
RefPtr<TaskQueue> queue =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR));
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR),
|
||||
"TestMediaEventSource CopyEvent1");
|
||||
|
||||
MediaEventProducer<SomeEvent> source;
|
||||
int i = 0;
|
||||
|
@ -290,7 +299,8 @@ TEST(MediaEventSource, CopyEvent1)
|
|||
TEST(MediaEventSource, CopyEvent2)
|
||||
{
|
||||
RefPtr<TaskQueue> queue =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR));
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR),
|
||||
"TestMediaEventSource CopyEvent2");
|
||||
|
||||
MediaEventProducer<SomeEvent> source;
|
||||
int i = 0;
|
||||
|
@ -319,7 +329,8 @@ TEST(MediaEventSource, CopyEvent2)
|
|||
TEST(MediaEventSource, MoveOnly)
|
||||
{
|
||||
RefPtr<TaskQueue> queue =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR));
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR),
|
||||
"TestMediaEventSource MoveOnly");
|
||||
|
||||
MediaEventProducerExc<UniquePtr<int>> source;
|
||||
|
||||
|
@ -353,7 +364,8 @@ struct RefCounter {
|
|||
TEST(MediaEventSource, NoMove)
|
||||
{
|
||||
RefPtr<TaskQueue> queue =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR));
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR),
|
||||
"TestMediaEventSource NoMove");
|
||||
|
||||
MediaEventProducer<RefPtr<RefCounter>> source;
|
||||
|
||||
|
@ -378,7 +390,8 @@ TEST(MediaEventSource, NoMove)
|
|||
TEST(MediaEventSource, MoveLambda)
|
||||
{
|
||||
RefPtr<TaskQueue> queue =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR));
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR),
|
||||
"TestMediaEventSource MoveLambda");
|
||||
|
||||
MediaEventProducer<void> source;
|
||||
|
||||
|
@ -430,7 +443,8 @@ class ClassForDestroyCheck final : private DestroyChecker<bool> {
|
|||
TEST(MediaEventSource, ResetFuncReferenceAfterDisconnect)
|
||||
{
|
||||
const RefPtr<TaskQueue> queue =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR));
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR),
|
||||
"TestMediaEventSource ResetFuncReferenceAfterDisconnect");
|
||||
MediaEventProducer<void> source;
|
||||
|
||||
// Using a class that supports refcounting to check the object destruction.
|
||||
|
@ -462,7 +476,9 @@ class TestTaskQueue : public TaskQueue, private DestroyChecker<Atomic<bool>> {
|
|||
public:
|
||||
TestTaskQueue(already_AddRefed<nsIEventTarget> aTarget,
|
||||
Atomic<bool>* aIsDestroyed)
|
||||
: TaskQueue(std::move(aTarget)), DestroyChecker(aIsDestroyed) {}
|
||||
: TaskQueue(std::move(aTarget),
|
||||
"TestMediaEventSource ResetTargetAfterDisconnect"),
|
||||
DestroyChecker(aIsDestroyed) {}
|
||||
};
|
||||
|
||||
TEST(MediaEventSource, ResetTargetAfterDisconnect)
|
||||
|
|
|
@ -128,6 +128,7 @@ class HLSDemuxer::HLSDemuxerCallbacksSupport
|
|||
|
||||
HLSDemuxer::HLSDemuxer(int aPlayerId)
|
||||
: mTaskQueue(new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR),
|
||||
"HLSDemuxer",
|
||||
/* aSupportsTailDispatch = */ false)) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
HLSDemuxerCallbacksSupport::Init();
|
||||
|
|
|
@ -131,7 +131,7 @@ void CanvasThreadHolder::DispatchToCanvasThread(
|
|||
}
|
||||
|
||||
already_AddRefed<TaskQueue> CanvasThreadHolder::CreateWorkerTaskQueue() {
|
||||
return MakeAndAddRef<TaskQueue>(do_AddRef(mCanvasWorkers));
|
||||
return MakeAndAddRef<TaskQueue>(do_AddRef(mCanvasWorkers), "CanvasWorker");
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
|
|
|
@ -171,7 +171,7 @@ class BaseProcessLauncher {
|
|||
|
||||
// Compute the serial event target we'll use for launching.
|
||||
nsCOMPtr<nsIEventTarget> threadOrPool = GetIPCLauncher();
|
||||
mLaunchThread = new TaskQueue(threadOrPool.forget());
|
||||
mLaunchThread = new TaskQueue(threadOrPool.forget(), "BaseProcessLauncher");
|
||||
|
||||
if (ShouldHaveDirectoryService()) {
|
||||
// "Current process directory" means the app dir, not the current
|
||||
|
|
|
@ -1544,7 +1544,7 @@ class BufferWriter final : public nsIInputStreamCallback {
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mTaskQueue = new TaskQueue(target.forget());
|
||||
mTaskQueue = new TaskQueue(target.forget(), "nsNetUtil:BufferWriter");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -428,7 +428,7 @@ nsresult nsFileChannel::ListenerBlockingPromise(BlockingPromise** aPromise) {
|
|||
return FixupContentLength(true);
|
||||
}
|
||||
|
||||
RefPtr<TaskQueue> taskQueue = new TaskQueue(sts.forget());
|
||||
RefPtr<TaskQueue> taskQueue = new TaskQueue(sts.forget(), "FileChannel");
|
||||
RefPtr<nsFileChannel> self = this;
|
||||
RefPtr<BlockingPromise> promise =
|
||||
mozilla::InvokeAsync(taskQueue, __func__, [self{std::move(self)}]() {
|
||||
|
|
|
@ -170,7 +170,7 @@ nsresult DataStorage::Init() {
|
|||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
mBackgroundTaskQueue = new TaskQueue(target.forget());
|
||||
mBackgroundTaskQueue = new TaskQueue(target.forget(), "PSM DataStorage");
|
||||
|
||||
// For test purposes, we can set the write timer to be very fast.
|
||||
uint32_t timerDelayMS = Preferences::GetInt("test.datastorage.write_timer_ms",
|
||||
|
|
|
@ -192,7 +192,7 @@ nsCertOverrideService::nsCertOverrideService()
|
|||
do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
||||
MOZ_ASSERT(target);
|
||||
|
||||
mWriterTaskQueue = new TaskQueue(target.forget());
|
||||
mWriterTaskQueue = new TaskQueue(target.forget(), "CertOverrideService");
|
||||
}
|
||||
|
||||
nsCertOverrideService::~nsCertOverrideService() = default;
|
||||
|
|
|
@ -42,7 +42,8 @@ TEST(DelayedRunnable, TaskQueueShutdownLeak)
|
|||
{
|
||||
Atomic<bool> active{false};
|
||||
auto taskQueue = MakeRefPtr<TaskQueue>(
|
||||
GetMediaThreadPool(mozilla::MediaThreadType::SUPERVISOR));
|
||||
GetMediaThreadPool(mozilla::MediaThreadType::SUPERVISOR),
|
||||
"TestDelayedRunnable TaskQueueShutdownLeak");
|
||||
taskQueue->DelayedDispatch(
|
||||
NS_NewRunnableFunction(__func__, [release = ReleaseDetector(&active)] {}),
|
||||
60e3 /* 1 minute */);
|
||||
|
@ -118,11 +119,14 @@ TEST(DelayedRunnable, TimerFiresBeforeRunnableRuns)
|
|||
RefPtr<mozilla::SharedThreadPool> pool =
|
||||
mozilla::SharedThreadPool::Get("Test Pool"_ns);
|
||||
auto tailTaskQueue1 = MakeRefPtr<TaskQueue>(
|
||||
do_AddRef(pool), /* aSupportsTailDispatch = */ true);
|
||||
do_AddRef(pool), "TestDelayedRunnable tailTaskQueue1",
|
||||
/* aSupportsTailDispatch = */ true);
|
||||
auto tailTaskQueue2 = MakeRefPtr<TaskQueue>(
|
||||
do_AddRef(pool), /* aSupportsTailDispatch = */ true);
|
||||
do_AddRef(pool), "TestDelayedRunnable tailTaskQueue2",
|
||||
/* aSupportsTailDispatch = */ true);
|
||||
auto noTailTaskQueue = MakeRefPtr<TaskQueue>(
|
||||
do_AddRef(pool), /* aSupportsTailDispatch = */ false);
|
||||
do_AddRef(pool), "TestDelayedRunnable noTailTaskQueue",
|
||||
/* aSupportsTailDispatch = */ false);
|
||||
Monitor outerMonitor(__func__);
|
||||
MonitorAutoLock lock(outerMonitor);
|
||||
MOZ_ALWAYS_SUCCEEDS(
|
||||
|
|
|
@ -22,7 +22,8 @@ class MOZ_STACK_CLASS AutoTaskQueue {
|
|||
public:
|
||||
AutoTaskQueue()
|
||||
: mTaskQueue(
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR))) {}
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR),
|
||||
"TestMozPromise AutoTaskQueue")) {}
|
||||
|
||||
~AutoTaskQueue() { mTaskQueue->AwaitShutdownAndIdle(); }
|
||||
|
||||
|
|
|
@ -28,7 +28,8 @@ struct Foo {
|
|||
TEST(WatchManager, Shutdown)
|
||||
{
|
||||
RefPtr<TaskQueue> queue =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR));
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR),
|
||||
"TestWatchManager Shutdown");
|
||||
|
||||
RefPtr<Foo> p = new Foo;
|
||||
WatchManager<Foo> manager(p, queue);
|
||||
|
|
|
@ -17,11 +17,14 @@ using namespace mozilla;
|
|||
TEST(TaskQueue, EventOrder)
|
||||
{
|
||||
RefPtr<TaskQueue> tq1 =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR), true);
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR),
|
||||
"TestTaskQueue tq1", true);
|
||||
RefPtr<TaskQueue> tq2 =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR), true);
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR),
|
||||
"TestTaskQueue tq2", true);
|
||||
RefPtr<TaskQueue> tq3 =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR), true);
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR),
|
||||
"TestTaskQueue tq3", true);
|
||||
|
||||
bool errored = false;
|
||||
int counter = 0;
|
||||
|
@ -86,7 +89,8 @@ TEST(TaskQueue, EventOrder)
|
|||
TEST(TaskQueue, GetCurrentSerialEventTarget)
|
||||
{
|
||||
RefPtr<TaskQueue> tq1 =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR), false);
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR),
|
||||
"TestTaskQueue GetCurrentSerialEventTarget", false);
|
||||
Unused << tq1->Dispatch(NS_NewRunnableFunction(
|
||||
"TestTaskQueue::TestCurrentSerialEventTarget::TestBody", [tq1]() {
|
||||
nsCOMPtr<nsISerialEventTarget> thread = GetCurrentSerialEventTarget();
|
||||
|
|
|
@ -21,10 +21,6 @@ TaskQueue::TaskQueue(already_AddRefed<nsIEventTarget> aTarget,
|
|||
mIsShutdown(false),
|
||||
mName(aName) {}
|
||||
|
||||
TaskQueue::TaskQueue(already_AddRefed<nsIEventTarget> aTarget,
|
||||
bool aSupportsTailDispatch)
|
||||
: TaskQueue(std::move(aTarget), "Unnamed", aSupportsTailDispatch) {}
|
||||
|
||||
TaskQueue::~TaskQueue() {
|
||||
// No one is referencing this TaskQueue anymore, meaning no tasks can be
|
||||
// pending as all Runner hold a reference to this TaskQueue.
|
||||
|
|
|
@ -53,9 +53,6 @@ class TaskQueue : public AbstractThread,
|
|||
class EventTargetWrapper;
|
||||
|
||||
public:
|
||||
explicit TaskQueue(already_AddRefed<nsIEventTarget> aTarget,
|
||||
bool aSupportsTailDispatch = false);
|
||||
|
||||
TaskQueue(already_AddRefed<nsIEventTarget> aTarget, const char* aName,
|
||||
bool aSupportsTailDispatch = false);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче