Index: cc/raster/task.h |
diff --git a/cc/raster/task.h b/cc/raster/task.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..19ca11afb6040b0c703faae36cae88eb8300ed57 |
--- /dev/null |
+++ b/cc/raster/task.h |
@@ -0,0 +1,64 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CC_RASTER_TASK_H_ |
+#define CC_RASTER_TASK_H_ |
+ |
+#include <vector> |
+ |
+#include "base/memory/ref_counted.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "cc/base/cc_export.h" |
+ |
+namespace cc { |
+ |
+// A task with or without dependencies which can be run by a TaskGraphRunner. To |
+// run a Task, it should be inserted into a TaskGraph, which can then |
+// be scheduled on the TaskGraphRunner. |
+class CC_EXPORT Task : public base::RefCountedThreadSafe<Task> { |
reveman
2016/04/06 12:18:06
dependencies should not be part of the task. it sh
prashant.n
2016/04/06 13:11:50
Yes. I just checked, we are already keeping that i
|
+ public: |
+ typedef std::vector<scoped_refptr<Task>> Vector; |
+ |
+ const Task::Vector& dependencies() const { return dependencies_; } |
+ |
+ // Subclasses should implement these methods. ScheduleOnOriginThread() and |
+ // CompleteOnOriginThread() must be called on origin thread and |
+ // RunOnWorkerThread() may be called on any thread (origin or worker). The |
+ // subclasses are responsible for locking and thread safety. |
+ virtual void ScheduleOnOriginThread() = 0; |
+ virtual void CompleteOnOriginThread() = 0; |
reveman
2016/04/06 12:18:06
Schedule/Complete should not be part of the task c
prashant.n
2016/04/06 13:11:50
Do you mean to say, having this only in dervied cl
|
+ virtual void RunOnWorkerThread() = 0; |
+ |
+ void WillSchedule(); |
+ void DidSchedule(); |
+ bool HasBeenScheduled() const; |
+ |
+ void WillComplete(); |
+ void DidComplete(); |
+ bool HasCompleted() const; |
+ |
+ void WillRun(); |
+ void DidRun(); |
+ bool HasFinishedRunning() const; |
+ |
+ protected: |
+ friend class base::RefCountedThreadSafe<Task>; |
+ |
+ // For creating task without dependencies. |
+ Task(); |
+ // For creating task with dependencies. |
+ explicit Task(Task::Vector* dependencies); |
+ virtual ~Task(); |
+ |
+ bool did_schedule_; |
+ bool did_complete_; |
+ bool will_run_; |
+ bool did_run_; |
+ |
+ Task::Vector dependencies_; |
+}; |
+ |
+} // namespace cc |
+ |
+#endif // CC_RASTER_TASK_H_ |