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

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: Corrected scope of dependencies. 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
Index: cc/raster/task.h
diff --git a/cc/raster/task.h b/cc/raster/task.h
new file mode 100644
index 0000000000000000000000000000000000000000..7ce90977b0813b581b8d2af10502be2e3ab14819
--- /dev/null
+++ b/cc/raster/task.h
@@ -0,0 +1,57 @@
+// 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> {
+ public:
+ typedef std::vector<scoped_refptr<Task>> Vector;
+
+ // 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;
+ 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>;
+
+ Task();
+ virtual ~Task();
+
+ bool did_schedule_;
+ bool did_complete_;
+ bool will_run_;
+ bool did_run_;
+};
+
+} // namespace cc
+
+#endif // CC_RASTER_TASK_H_
« no previous file with comments | « cc/raster/raster_buffer.h ('k') | cc/raster/task.cc » ('j') | cc/tiles/tile_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698