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

Side by Side Diff: cc/test/task_graph_runner_test_template.cc

Issue 1854723002: cc: Simplify task and its derived classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/test/task_graph_runner_test_template.h" 5 #include "cc/test/task_graph_runner_test_template.h"
6 6
7 namespace cc { 7 namespace cc {
8 8
9 const int TaskGraphRunnerTestBase::kNamespaceCount; 9 const int TaskGraphRunnerTestBase::kNamespaceCount;
10 10
11 void TaskGraphRunnerTestBase::SetTaskGraphRunner( 11 void TaskGraphRunnerTestBase::SetTaskGraphRunner(
12 TaskGraphRunner* task_graph_runner) { 12 TaskGraphRunner* task_graph_runner) {
13 task_graph_runner_ = task_graph_runner; 13 task_graph_runner_ = task_graph_runner;
14 } 14 }
15 15
16 void TaskGraphRunnerTestBase::ResetIds(int namespace_index) { 16 void TaskGraphRunnerTestBase::ResetIds(int namespace_index) {
17 run_task_ids_[namespace_index].clear(); 17 run_task_ids_[namespace_index].clear();
18 on_task_completed_ids_[namespace_index].clear(); 18 on_task_completed_ids_[namespace_index].clear();
19 } 19 }
20 20
21 void TaskGraphRunnerTestBase::RunAllTasks(int namespace_index) { 21 void TaskGraphRunnerTestBase::RunAllTasks(int namespace_index) {
22 task_graph_runner_->WaitForTasksToFinishRunning( 22 task_graph_runner_->WaitForTasksToFinishRunning(
23 namespace_token_[namespace_index]); 23 namespace_token_[namespace_index]);
24 24
25 Task::Vector completed_tasks; 25 DependencyTask::Vector completed_tasks;
26 task_graph_runner_->CollectCompletedTasks(namespace_token_[namespace_index], 26 task_graph_runner_->CollectCompletedTasks(namespace_token_[namespace_index],
27 &completed_tasks); 27 &completed_tasks);
28 for (Task::Vector::const_iterator it = completed_tasks.begin(); 28 for (DependencyTask::Vector::const_iterator it = completed_tasks.begin();
29 it != completed_tasks.end(); ++it) { 29 it != completed_tasks.end(); ++it) {
30 FakeTaskImpl* task = static_cast<FakeTaskImpl*>(it->get()); 30 FakeTaskImpl* task = static_cast<FakeTaskImpl*>(it->get());
31 task->CompleteOnOriginThread(); 31 task->CompleteOnOriginThread(nullptr);
32 } 32 }
33 } 33 }
34 34
35 void TaskGraphRunnerTestBase::RunTaskOnWorkerThread(int namespace_index, 35 void TaskGraphRunnerTestBase::RunTaskOnWorkerThread(int namespace_index,
36 unsigned id) { 36 unsigned id) {
37 base::AutoLock lock(run_task_ids_lock_); 37 base::AutoLock lock(run_task_ids_lock_);
38 run_task_ids_[namespace_index].push_back(id); 38 run_task_ids_[namespace_index].push_back(id);
39 } 39 }
40 40
41 void TaskGraphRunnerTestBase::OnTaskCompleted(int namespace_index, 41 void TaskGraphRunnerTestBase::OnTaskCompleted(int namespace_index,
42 unsigned id) { 42 unsigned id) {
43 on_task_completed_ids_[namespace_index].push_back(id); 43 on_task_completed_ids_[namespace_index].push_back(id);
44 } 44 }
45 45
46 const std::vector<unsigned>& TaskGraphRunnerTestBase::run_task_ids( 46 const std::vector<unsigned>& TaskGraphRunnerTestBase::run_task_ids(
47 int namespace_index) { 47 int namespace_index) {
48 return run_task_ids_[namespace_index]; 48 return run_task_ids_[namespace_index];
49 } 49 }
50 50
51 const std::vector<unsigned>& TaskGraphRunnerTestBase::on_task_completed_ids( 51 const std::vector<unsigned>& TaskGraphRunnerTestBase::on_task_completed_ids(
52 int namespace_index) { 52 int namespace_index) {
53 return on_task_completed_ids_[namespace_index]; 53 return on_task_completed_ids_[namespace_index];
54 } 54 }
55 55
56 void TaskGraphRunnerTestBase::ScheduleTasks( 56 void TaskGraphRunnerTestBase::ScheduleTasks(
57 int namespace_index, 57 int namespace_index,
58 const std::vector<TaskInfo>& tasks) { 58 const std::vector<TaskInfo>& tasks) {
59 Task::Vector new_tasks; 59 DependencyTask::Vector new_tasks;
60 Task::Vector new_dependents; 60 DependencyTask::Vector new_dependents;
61 TaskGraph new_graph; 61 TaskGraph new_graph;
62 62
63 for (std::vector<TaskInfo>::const_iterator it = tasks.begin(); 63 for (std::vector<TaskInfo>::const_iterator it = tasks.begin();
64 it != tasks.end(); ++it) { 64 it != tasks.end(); ++it) {
65 scoped_refptr<FakeTaskImpl> new_task( 65 scoped_refptr<FakeTaskImpl> new_task(
66 new FakeTaskImpl(this, it->namespace_index, it->id)); 66 new FakeTaskImpl(this, it->namespace_index, it->id));
67 new_graph.nodes.push_back( 67 new_graph.nodes.push_back(
68 TaskGraph::Node(new_task.get(), it->category, it->priority, 0u)); 68 TaskGraph::Node(new_task.get(), it->category, it->priority, 0u));
69 for (unsigned i = 0; i < it->dependent_count; ++i) { 69 for (unsigned i = 0; i < it->dependent_count; ++i) {
70 scoped_refptr<FakeDependentTaskImpl> new_dependent_task( 70 scoped_refptr<FakeDependentTaskImpl> new_dependent_task(
(...skipping 14 matching lines...) Expand all
85 &new_graph); 85 &new_graph);
86 86
87 dependents_[namespace_index].swap(new_dependents); 87 dependents_[namespace_index].swap(new_dependents);
88 tasks_[namespace_index].swap(new_tasks); 88 tasks_[namespace_index].swap(new_tasks);
89 } 89 }
90 90
91 void TaskGraphRunnerTestBase::FakeTaskImpl::RunOnWorkerThread() { 91 void TaskGraphRunnerTestBase::FakeTaskImpl::RunOnWorkerThread() {
92 test_->RunTaskOnWorkerThread(namespace_index_, id_); 92 test_->RunTaskOnWorkerThread(namespace_index_, id_);
93 } 93 }
94 94
95 void TaskGraphRunnerTestBase::FakeTaskImpl::CompleteOnOriginThread() { 95 void TaskGraphRunnerTestBase::FakeTaskImpl::CompleteOnOriginThread(
96 DependencyTaskClient* client) {
96 test_->OnTaskCompleted(namespace_index_, id_); 97 test_->OnTaskCompleted(namespace_index_, id_);
97 } 98 }
98 99
99 } // namespace cc 100 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698