Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1910)

Unified Diff: cc/raster/task.cc

Issue 1903733003: cc: Implement states for Task for stricter control. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@land_merge_tile_task_runner
Patch Set: feedback Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/raster/task.h ('k') | cc/raster/task_graph_runner_perftest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/raster/task.cc
diff --git a/cc/raster/task.cc b/cc/raster/task.cc
index c19e549462830731ab05d09d536025d86861a7c5..4f26d12ba4495bef070161fd6b48569654755c51 100644
--- a/cc/raster/task.cc
+++ b/cc/raster/task.cc
@@ -8,28 +8,64 @@
namespace cc {
-Task::Task() : will_run_(false), did_run_(false) {}
+TaskState::TaskState() : value_(Value::NEW) {}
-Task::~Task() {
- DCHECK(!will_run_);
+TaskState::~TaskState() {
+ DCHECK(value_ != Value::RUNNING)
+ << "Running task should never get destroyed.";
+ DCHECK(value_ == Value::NEW || value_ == Value::FINISHED ||
+ value_ == 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_ == Value::SCHEDULED;
}
-void Task::DidRun() {
- DCHECK(will_run_);
- will_run_ = false;
- did_run_ = true;
+bool TaskState::IsRunning() const {
+ return value_ == Value::RUNNING;
+}
+bool TaskState::IsFinished() const {
+ return value_ == Value::FINISHED;
+}
+bool TaskState::IsCanceled() const {
+ return value_ == Value::CANCELED;
+}
+
+void TaskState::Reset() {
+ value_ = Value::NEW;
+}
+
+void TaskState::DidSchedule() {
+ DCHECK(value_ == Value::NEW)
+ << "Task should be in NEW state to get scheduled.";
+ value_ = Value::SCHEDULED;
}
-bool Task::HasFinishedRunning() const {
- return did_run_;
+void TaskState::DidStart() {
+ DCHECK(value_ == Value::SCHEDULED)
+ << "Task should be only in SCHEDULED state to start, that is it should "
+ "not be started or finished.";
+ value_ = Value::RUNNING;
}
+void TaskState::DidFinish() {
+ DCHECK(value_ == Value::RUNNING)
+ << "Task should be running and not finished earlier.";
+ value_ = Value::FINISHED;
+}
+
+void TaskState::DidCancel() {
+ DCHECK(value_ == Value::NEW || value_ == Value::SCHEDULED)
+ << "Task should be scheduled and not running to get canceled.";
+ value_ = Value::CANCELED;
+}
+
+Task::Task() {}
+
+Task::~Task() {}
+
TaskGraph::TaskGraph() {}
TaskGraph::TaskGraph(const TaskGraph& other) = default;
« no previous file with comments | « cc/raster/task.h ('k') | cc/raster/task_graph_runner_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698