зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1366072 - Use nsIRunnable instead of Runnable in MessageLoop (r=kanru)
MozReview-Commit-ID: 9LmBghd0D46
This commit is contained in:
Родитель
c85ab6308c
Коммит
bbed3cf3c1
|
@ -248,7 +248,7 @@ bool MessageLoop::ProcessNextDelayedNonNestableTask() {
|
|||
if (deferred_non_nestable_work_queue_.empty())
|
||||
return false;
|
||||
|
||||
RefPtr<Runnable> task = deferred_non_nestable_work_queue_.front().task.forget();
|
||||
nsCOMPtr<nsIRunnable> task = deferred_non_nestable_work_queue_.front().task.forget();
|
||||
deferred_non_nestable_work_queue_.pop();
|
||||
|
||||
RunTask(task.forget());
|
||||
|
@ -266,15 +266,15 @@ void MessageLoop::Quit() {
|
|||
}
|
||||
}
|
||||
|
||||
void MessageLoop::PostTask(already_AddRefed<Runnable> task) {
|
||||
void MessageLoop::PostTask(already_AddRefed<nsIRunnable> task) {
|
||||
PostTask_Helper(Move(task), 0);
|
||||
}
|
||||
|
||||
void MessageLoop::PostDelayedTask(already_AddRefed<Runnable> task, int delay_ms) {
|
||||
void MessageLoop::PostDelayedTask(already_AddRefed<nsIRunnable> task, int delay_ms) {
|
||||
PostTask_Helper(Move(task), delay_ms);
|
||||
}
|
||||
|
||||
void MessageLoop::PostIdleTask(already_AddRefed<Runnable> task) {
|
||||
void MessageLoop::PostIdleTask(already_AddRefed<nsIRunnable> task) {
|
||||
DCHECK(current() == this);
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
|
@ -283,7 +283,7 @@ void MessageLoop::PostIdleTask(already_AddRefed<Runnable> task) {
|
|||
}
|
||||
|
||||
// Possibly called on a background thread!
|
||||
void MessageLoop::PostTask_Helper(already_AddRefed<Runnable> task, int delay_ms) {
|
||||
void MessageLoop::PostTask_Helper(already_AddRefed<nsIRunnable> task, int delay_ms) {
|
||||
if (nsIEventTarget* target = pump_->GetXPCOMThread()) {
|
||||
nsresult rv;
|
||||
if (delay_ms) {
|
||||
|
@ -296,7 +296,7 @@ void MessageLoop::PostTask_Helper(already_AddRefed<Runnable> task, int delay_ms)
|
|||
}
|
||||
|
||||
#ifdef MOZ_TASK_TRACER
|
||||
RefPtr<Runnable> tracedTask = task;
|
||||
nsCOMPtr<nsIRunnable> tracedTask = task;
|
||||
if (mozilla::tasktracer::IsStartLogging()) {
|
||||
tracedTask = mozilla::tasktracer::CreateTracedRunnable(Move(task));
|
||||
(static_cast<mozilla::tasktracer::TracedRunnable*>(tracedTask.get()))->DispatchTask();
|
||||
|
@ -352,12 +352,12 @@ bool MessageLoop::NestableTasksAllowed() const {
|
|||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void MessageLoop::RunTask(already_AddRefed<Runnable> aTask) {
|
||||
void MessageLoop::RunTask(already_AddRefed<nsIRunnable> aTask) {
|
||||
DCHECK(nestable_tasks_allowed_);
|
||||
// Execute the task and assume the worst: It is probably not reentrant.
|
||||
nestable_tasks_allowed_ = false;
|
||||
|
||||
RefPtr<Runnable> task = aTask;
|
||||
nsCOMPtr<nsIRunnable> task = aTask;
|
||||
task->Run();
|
||||
task = nullptr;
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#endif
|
||||
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIRunnable.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
class nsIThread;
|
||||
|
@ -112,12 +114,12 @@ public:
|
|||
// NOTE: These methods may be called on any thread. The Task will be invoked
|
||||
// on the thread that executes MessageLoop::Run().
|
||||
|
||||
void PostTask(already_AddRefed<mozilla::Runnable> task);
|
||||
void PostTask(already_AddRefed<nsIRunnable> task);
|
||||
|
||||
void PostDelayedTask(already_AddRefed<mozilla::Runnable> task, int delay_ms);
|
||||
void PostDelayedTask(already_AddRefed<nsIRunnable> task, int delay_ms);
|
||||
|
||||
// PostIdleTask is not thread safe and should be called on this thread
|
||||
void PostIdleTask(already_AddRefed<mozilla::Runnable> task);
|
||||
void PostIdleTask(already_AddRefed<nsIRunnable> task);
|
||||
|
||||
// Run the message loop.
|
||||
void Run();
|
||||
|
@ -282,12 +284,12 @@ public:
|
|||
|
||||
// This structure is copied around by value.
|
||||
struct PendingTask {
|
||||
RefPtr<mozilla::Runnable> task; // The task to run.
|
||||
nsCOMPtr<nsIRunnable> task; // The task to run.
|
||||
base::TimeTicks delayed_run_time; // The time when the task should be run.
|
||||
int sequence_num; // Secondary sort key for run time.
|
||||
bool nestable; // OK to dispatch from a nested loop.
|
||||
|
||||
PendingTask(already_AddRefed<mozilla::Runnable> aTask, bool aNestable)
|
||||
PendingTask(already_AddRefed<nsIRunnable> aTask, bool aNestable)
|
||||
: task(aTask), sequence_num(0), nestable(aNestable) {
|
||||
}
|
||||
|
||||
|
@ -355,10 +357,10 @@ public:
|
|||
// appended to the list work_queue_. Such re-entrancy generally happens when
|
||||
// an unrequested message pump (typical of a native dialog) is executing in
|
||||
// the context of a task.
|
||||
bool QueueOrRunTask(already_AddRefed<mozilla::Runnable> new_task);
|
||||
bool QueueOrRunTask(already_AddRefed<nsIRunnable> new_task);
|
||||
|
||||
// Runs the specified task and deletes it.
|
||||
void RunTask(already_AddRefed<mozilla::Runnable> task);
|
||||
void RunTask(already_AddRefed<nsIRunnable> task);
|
||||
|
||||
// Calls RunTask or queues the pending_task on the deferred task list if it
|
||||
// cannot be run right now. Returns true if the task was run.
|
||||
|
@ -378,7 +380,7 @@ public:
|
|||
bool DeletePendingTasks();
|
||||
|
||||
// Post a task to our incomming queue.
|
||||
void PostTask_Helper(already_AddRefed<mozilla::Runnable> task, int delay_ms);
|
||||
void PostTask_Helper(already_AddRefed<nsIRunnable> task, int delay_ms);
|
||||
|
||||
// base::MessagePump::Delegate methods:
|
||||
virtual bool DoWork() override;
|
||||
|
|
Загрузка…
Ссылка в новой задаче