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

Side by Side Diff: cc/raster/task.cc

Issue 1866043006: cc: Remove ScheduleOnOriginThread() and CompleteOnOriginThread(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 4 years, 7 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/raster/task.h" 5 #include "cc/raster/task.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace cc { 9 namespace cc {
10 10
11 TaskState::TaskState() : value_(Value::NEW) {} 11 TaskState::TaskState() : value_(Value::NEW) {}
12 12
13 TaskState::~TaskState() { 13 TaskState::~TaskState() {
14 DCHECK(value_ != Value::RUNNING) 14 DCHECK(value_ != Value::RUNNING)
15 << "Running task should never get destroyed."; 15 << "Running task should never get destroyed.";
16 // TODO(prashant.n): Remove NEW, once all the tests follow the task life
17 // cycle correctly. Few tests still do not take care of task states.
18 // crbug.com/613814.
16 DCHECK(value_ == Value::NEW || value_ == Value::FINISHED || 19 DCHECK(value_ == Value::NEW || value_ == Value::FINISHED ||
17 value_ == Value::CANCELED) 20 value_ == Value::CANCELED)
18 << "Task, if scheduled, should get concluded either in FINISHED or " 21 << "Task, if scheduled, should get concluded either in FINISHED or "
19 "CANCELED state."; 22 "CANCELED state.";
20 } 23 }
21 24
22 bool TaskState::IsScheduled() const { 25 bool TaskState::IsScheduled() const {
23 return value_ == Value::SCHEDULED; 26 return value_ == Value::SCHEDULED;
24 } 27 }
25 28
26 bool TaskState::IsRunning() const { 29 bool TaskState::IsRunning() const {
27 return value_ == Value::RUNNING; 30 return value_ == Value::RUNNING;
28 } 31 }
32
29 bool TaskState::IsFinished() const { 33 bool TaskState::IsFinished() const {
30 return value_ == Value::FINISHED; 34 return value_ == Value::FINISHED;
31 } 35 }
36
32 bool TaskState::IsCanceled() const { 37 bool TaskState::IsCanceled() const {
33 return value_ == Value::CANCELED; 38 return value_ == Value::CANCELED;
34 } 39 }
35 40
36 void TaskState::Reset() { 41 void TaskState::Reset() {
37 value_ = Value::NEW; 42 value_ = Value::NEW;
38 } 43 }
39 44
40 void TaskState::DidSchedule() { 45 void TaskState::DidSchedule() {
41 DCHECK(value_ == Value::NEW) 46 DCHECK(value_ == Value::NEW)
42 << "Task should be in NEW state to get scheduled."; 47 << "Task should be in NEW state to get scheduled.";
43 value_ = Value::SCHEDULED; 48 value_ = Value::SCHEDULED;
44 } 49 }
45 50
46 void TaskState::DidStart() { 51 void TaskState::DidStart() {
47 DCHECK(value_ == Value::SCHEDULED) 52 DCHECK(value_ == Value::SCHEDULED)
48 << "Task should be only in SCHEDULED state to start, that is it should " 53 << "Task should be only in SCHEDULED state to start, that is it should "
49 "not be started or finished."; 54 "not be started or finished.";
50 value_ = Value::RUNNING; 55 value_ = Value::RUNNING;
51 } 56 }
52 57
53 void TaskState::DidFinish() { 58 void TaskState::DidFinish() {
54 DCHECK(value_ == Value::RUNNING) 59 DCHECK(value_ == Value::RUNNING)
55 << "Task should be running and not finished earlier."; 60 << "Task should be running and not finished earlier.";
56 value_ = Value::FINISHED; 61 value_ = Value::FINISHED;
57 } 62 }
58 63
59 void TaskState::DidCancel() { 64 void TaskState::DidCancel() {
60 DCHECK(value_ == Value::NEW || value_ == Value::SCHEDULED) 65 DCHECK(value_ == Value::NEW || value_ == Value::SCHEDULED)
61 << "Task should be scheduled and not running to get canceled."; 66 << "Task should be either new or scheduled to get canceled.";
62 value_ = Value::CANCELED; 67 value_ = Value::CANCELED;
63 } 68 }
64 69
65 Task::Task() {} 70 Task::Task() {}
66 71
67 Task::~Task() {} 72 Task::~Task() {}
68 73
69 TaskGraph::TaskGraph() {} 74 TaskGraph::TaskGraph() {}
70 75
71 TaskGraph::TaskGraph(const TaskGraph& other) = default; 76 TaskGraph::TaskGraph(const TaskGraph& other) = default;
72 77
73 TaskGraph::~TaskGraph() {} 78 TaskGraph::~TaskGraph() {}
74 79
75 void TaskGraph::Swap(TaskGraph* other) { 80 void TaskGraph::Swap(TaskGraph* other) {
76 nodes.swap(other->nodes); 81 nodes.swap(other->nodes);
77 edges.swap(other->edges); 82 edges.swap(other->edges);
78 } 83 }
79 84
80 void TaskGraph::Reset() { 85 void TaskGraph::Reset() {
81 nodes.clear(); 86 nodes.clear();
82 edges.clear(); 87 edges.clear();
83 } 88 }
84 89
85 } // namespace cc 90 } // namespace cc
OLDNEW
« 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