Chromium Code Reviews| Index: cc/raster/task.cc |
| diff --git a/cc/raster/task.cc b/cc/raster/task.cc |
| index c19e549462830731ab05d09d536025d86861a7c5..2e688686ecc8a53462ba854af7e0a6c71fbda67c 100644 |
| --- a/cc/raster/task.cc |
| +++ b/cc/raster/task.cc |
| @@ -8,28 +8,61 @@ |
| namespace cc { |
| -Task::Task() : will_run_(false), did_run_(false) {} |
| +TaskState::TaskState() : value_(NEW) {} |
| -Task::~Task() { |
| - DCHECK(!will_run_); |
| +TaskState::~TaskState() { |
| + DCHECK_NE(value_, RUNNING) << "Running task should never get destroyed."; |
| + DCHECK(value_ == NEW || value_ == FINISHED || value_ == CANCELED) |
| + << "Task, if scheduled, should get concluded either in FINISHED or " |
| + "CANCELED state."; |
| } |
| -void Task::WillRun() { |
| - DCHECK(!will_run_); |
| - DCHECK(!did_run_); |
| - will_run_ = true; |
| +bool TaskState::IsScheduled() const { |
| + return (value_ == SCHEDULED); |
|
ericrk
2016/04/21 18:24:25
nit: why the extra ()?
prashant.n
2016/04/22 03:57:56
For readability I added.
I guess chromium does no
|
| } |
| -void Task::DidRun() { |
| - DCHECK(will_run_); |
| - will_run_ = false; |
| - did_run_ = true; |
| +bool TaskState::IsRunning() const { |
| + return (value_ == RUNNING); |
| +} |
| +bool TaskState::IsFinished() const { |
| + return (value_ == FINISHED); |
| +} |
| +bool TaskState::IsCanceled() const { |
| + return (value_ == CANCELED); |
| +} |
| + |
| +void TaskState::Reset() { |
| + value_ = NEW; |
| +} |
| + |
| +void TaskState::DidSchedule() { |
| + DCHECK(value_ == NEW) << "Task should be in NEW state to get scheduled."; |
| + value_ = SCHEDULED; |
| } |
| -bool Task::HasFinishedRunning() const { |
| - return did_run_; |
| +void TaskState::DidStart() { |
| + DCHECK_EQ(value_, SCHEDULED) << "Task should be scheduled to start."; |
| + DCHECK(value_ != RUNNING && value_ != FINISHED) |
|
ericrk
2016/04/21 18:24:25
This check is redundant with the above. (they both
|
| + << "Task should not be running or finished."; |
| + value_ = RUNNING; |
| } |
| +void TaskState::DidFinish() { |
| + DCHECK(value_ == RUNNING && value_ != FINISHED) |
| + << "Task should be running and not finished."; |
| + value_ = FINISHED; |
| +} |
| + |
| +void TaskState::DidCancel() { |
| + DCHECK(value_ == NEW || (value_ == SCHEDULED && value_ != RUNNING)) |
|
ericrk
2016/04/21 18:24:25
Should read DCHECK(value_ == NEW || value_ == SCHE
|
| + << "Task should be scheduled and not running to get canceled."; |
| + value_ = CANCELED; |
| +} |
| + |
| +Task::Task() {} |
| + |
| +Task::~Task() {} |
| + |
| TaskGraph::TaskGraph() {} |
| TaskGraph::TaskGraph(const TaskGraph& other) = default; |