OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CC_RASTER_TASK_H_ |
| 6 #define CC_RASTER_TASK_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "cc/base/cc_export.h" |
| 13 |
| 14 namespace cc { |
| 15 |
| 16 // A task with or without dependencies which can be run by a TaskGraphRunner. To |
| 17 // run a Task, it should be inserted into a TaskGraph, which can then |
| 18 // be scheduled on the TaskGraphRunner. |
| 19 class CC_EXPORT Task : public base::RefCountedThreadSafe<Task> { |
| 20 public: |
| 21 typedef std::vector<scoped_refptr<Task>> Vector; |
| 22 |
| 23 // Subclasses should implement these methods. ScheduleOnOriginThread() and |
| 24 // CompleteOnOriginThread() must be called on origin thread and |
| 25 // RunOnWorkerThread() may be called on any thread (origin or worker). The |
| 26 // subclasses are responsible for locking and thread safety. |
| 27 virtual void ScheduleOnOriginThread() = 0; |
| 28 virtual void CompleteOnOriginThread() = 0; |
| 29 virtual void RunOnWorkerThread() = 0; |
| 30 |
| 31 void WillSchedule(); |
| 32 void DidSchedule(); |
| 33 bool HasBeenScheduled() const; |
| 34 |
| 35 void WillComplete(); |
| 36 void DidComplete(); |
| 37 bool HasCompleted() const; |
| 38 |
| 39 void WillRun(); |
| 40 void DidRun(); |
| 41 bool HasFinishedRunning() const; |
| 42 |
| 43 protected: |
| 44 friend class base::RefCountedThreadSafe<Task>; |
| 45 |
| 46 Task(); |
| 47 virtual ~Task(); |
| 48 |
| 49 bool did_schedule_; |
| 50 bool did_complete_; |
| 51 bool will_run_; |
| 52 bool did_run_; |
| 53 }; |
| 54 |
| 55 } // namespace cc |
| 56 |
| 57 #endif // CC_RASTER_TASK_H_ |
OLD | NEW |