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

Unified Diff: cc/raster/task.h

Issue 1854723002: cc: Simplify task and its derived classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unnecessary static cast. 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/raster_buffer.h ('k') | cc/raster/task.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« no previous file with comments | « cc/raster/raster_buffer.h ('k') | cc/raster/task.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698