Index: cc/raster/task_graph_work_queue.cc |
diff --git a/cc/raster/task_graph_work_queue.cc b/cc/raster/task_graph_work_queue.cc |
index aa7565473aec4c35e08d9c007db6d9c8c6d38499..807539db8e49252a01c6b346a625525c7d326d85 100644 |
--- a/cc/raster/task_graph_work_queue.cc |
+++ b/cc/raster/task_graph_work_queue.cc |
@@ -144,6 +144,11 @@ void TaskGraphWorkQueue::ScheduleTasks(NamespaceToken token, TaskGraph* graph) { |
}); |
if (old_it != task_namespace.graph.nodes.end()) { |
std::swap(*old_it, task_namespace.graph.nodes.back()); |
+ // If old task is scheduled to run again and not yet started running, |
+ // reset its state to initial state as it has to be inserted in new |
+ // |ready_to_run_tasks|, where it gets scheduled. |
+ if (node.task->state().IsScheduled()) |
+ node.task->state().Reset(); |
task_namespace.graph.nodes.pop_back(); |
} |
@@ -152,7 +157,7 @@ void TaskGraphWorkQueue::ScheduleTasks(NamespaceToken token, TaskGraph* graph) { |
continue; |
// Skip if already finished running task. |
- if (node.task->HasFinishedRunning()) |
+ if (node.task->state().IsFinished()) |
continue; |
// Skip if already running. |
@@ -163,6 +168,7 @@ void TaskGraphWorkQueue::ScheduleTasks(NamespaceToken token, TaskGraph* graph) { |
})) |
continue; |
+ node.task->state().DidSchedule(); |
task_namespace.ready_to_run_tasks[node.category].push_back(PrioritizedTask( |
node.task, &task_namespace, node.category, node.priority)); |
} |
@@ -184,7 +190,7 @@ void TaskGraphWorkQueue::ScheduleTasks(NamespaceToken token, TaskGraph* graph) { |
TaskGraph::Node& node = *it; |
// Skip if already finished running task. |
- if (node.task->HasFinishedRunning()) |
+ if (node.task->state().IsFinished()) |
continue; |
// Skip if already running. |
@@ -198,6 +204,7 @@ void TaskGraphWorkQueue::ScheduleTasks(NamespaceToken token, TaskGraph* graph) { |
DCHECK(std::find(task_namespace.completed_tasks.begin(), |
task_namespace.completed_tasks.end(), |
node.task) == task_namespace.completed_tasks.end()); |
+ node.task->state().DidCancel(); |
task_namespace.completed_tasks.push_back(node.task); |
} |
@@ -258,6 +265,7 @@ TaskGraphWorkQueue::PrioritizedTask TaskGraphWorkQueue::GetNextTaskToRun( |
} |
// Add task to |running_tasks|. |
+ task.task->state().DidStart(); |
task_namespace->running_tasks.push_back( |
std::make_pair(task.category, task.task)); |
@@ -292,6 +300,7 @@ void TaskGraphWorkQueue::CompleteTask(const PrioritizedTask& completed_task) { |
task_namespace->ready_to_run_tasks[dependent_node.category]; |
bool was_empty = ready_to_run_tasks.empty(); |
+ dependent_node.task->state().DidSchedule(); |
ready_to_run_tasks.push_back( |
PrioritizedTask(dependent_node.task, task_namespace, |
dependent_node.category, dependent_node.priority)); |
@@ -326,6 +335,7 @@ void TaskGraphWorkQueue::CompleteTask(const PrioritizedTask& completed_task) { |
} |
// Finally add task to |completed_tasks_|. |
+ task->state().DidFinish(); |
task_namespace->completed_tasks.push_back(task); |
} |