OLD | NEW |
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 "base/task_scheduler/scheduler_worker_thread.h" | 5 #include "base/task_scheduler/scheduler_worker_thread.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <vector> | 10 #include <vector> |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 num_get_work_callback_cv_->Signal(); | 122 num_get_work_callback_cv_->Signal(); |
123 | 123 |
124 // Check if a Sequence should be returned. | 124 // Check if a Sequence should be returned. |
125 if (num_sequences_to_create_ == 0) | 125 if (num_sequences_to_create_ == 0) |
126 return nullptr; | 126 return nullptr; |
127 --num_sequences_to_create_; | 127 --num_sequences_to_create_; |
128 } | 128 } |
129 | 129 |
130 // Create a Sequence that contains 1 Task. | 130 // Create a Sequence that contains 1 Task. |
131 scoped_refptr<Sequence> sequence(new Sequence); | 131 scoped_refptr<Sequence> sequence(new Sequence); |
132 task_tracker_.PostTask( | 132 std::unique_ptr<Task> task(new Task( |
133 Bind(IgnoreResult(&Sequence::PushTask), Unretained(sequence.get())), | 133 FROM_HERE, |
134 WrapUnique(new Task( | 134 Bind(&TaskSchedulerWorkerThreadTest::RunTaskCallback, Unretained(this)), |
135 FROM_HERE, Bind(&TaskSchedulerWorkerThreadTest::RunTaskCallback, | 135 TaskTraits())); |
136 Unretained(this)), | 136 EXPECT_TRUE(task_tracker_.WillPostTask(task.get())); |
137 TaskTraits()))); | 137 sequence->PushTask(std::move(task)); |
138 | 138 |
139 { | 139 { |
140 // Add the Sequence to the vector of created Sequences. | 140 // Add the Sequence to the vector of created Sequences. |
141 AutoSchedulerLock auto_lock(lock_); | 141 AutoSchedulerLock auto_lock(lock_); |
142 created_sequences_.push_back(sequence); | 142 created_sequences_.push_back(sequence); |
143 } | 143 } |
144 | 144 |
145 return sequence; | 145 return sequence; |
146 } | 146 } |
147 | 147 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 // |i| calls in which it returned nullptr. | 233 // |i| calls in which it returned nullptr. |
234 const size_t expected_num_get_work_callback = 2 * (i + 1); | 234 const size_t expected_num_get_work_callback = 2 * (i + 1); |
235 WaitForNumGetWorkCallback(expected_num_get_work_callback); | 235 WaitForNumGetWorkCallback(expected_num_get_work_callback); |
236 EXPECT_EQ(expected_num_get_work_callback, NumGetWorkCallback()); | 236 EXPECT_EQ(expected_num_get_work_callback, NumGetWorkCallback()); |
237 } | 237 } |
238 } | 238 } |
239 | 239 |
240 } // namespace | 240 } // namespace |
241 } // namespace internal | 241 } // namespace internal |
242 } // namespace base | 242 } // namespace base |
OLD | NEW |