| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 EXPECT_LE(num_get_work_, max_get_work_); | 123 EXPECT_LE(num_get_work_, max_get_work_); |
| 124 | 124 |
| 125 // Check if a Sequence should be returned. | 125 // Check if a Sequence should be returned. |
| 126 if (num_sequences_to_create_ == 0) | 126 if (num_sequences_to_create_ == 0) |
| 127 return nullptr; | 127 return nullptr; |
| 128 --num_sequences_to_create_; | 128 --num_sequences_to_create_; |
| 129 } | 129 } |
| 130 | 130 |
| 131 // Create a Sequence that contains one Task. | 131 // Create a Sequence that contains one Task. |
| 132 scoped_refptr<Sequence> sequence(new Sequence); | 132 scoped_refptr<Sequence> sequence(new Sequence); |
| 133 task_tracker_.PostTask( | 133 std::unique_ptr<Task> task(new Task( |
| 134 Bind(IgnoreResult(&Sequence::PushTask), Unretained(sequence.get())), | 134 FROM_HERE, |
| 135 WrapUnique(new Task( | 135 Bind(&TaskSchedulerWorkerThreadTest::RunTaskCallback, Unretained(this)), |
| 136 FROM_HERE, Bind(&TaskSchedulerWorkerThreadTest::RunTaskCallback, | 136 TaskTraits())); |
| 137 Unretained(this)), | 137 EXPECT_TRUE(task_tracker_.WillPostTask(task.get())); |
| 138 TaskTraits()))); | 138 sequence->PushTask(std::move(task)); |
| 139 | 139 |
| 140 { | 140 { |
| 141 // Add the Sequence to the vector of created Sequences. | 141 // Add the Sequence to the vector of created Sequences. |
| 142 AutoSchedulerLock auto_lock(lock_); | 142 AutoSchedulerLock auto_lock(lock_); |
| 143 created_sequences_.push_back(sequence); | 143 created_sequences_.push_back(sequence); |
| 144 } | 144 } |
| 145 | 145 |
| 146 return sequence; | 146 return sequence; |
| 147 } | 147 } |
| 148 | 148 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 // GetWork(). | 235 // GetWork(). |
| 236 worker_thread_->WakeUp(); | 236 worker_thread_->WakeUp(); |
| 237 WaitForAllSequencesToRun(); | 237 WaitForAllSequencesToRun(); |
| 238 WaitForNumGetWork(expected_num_get_work); | 238 WaitForNumGetWork(expected_num_get_work); |
| 239 } | 239 } |
| 240 } | 240 } |
| 241 | 241 |
| 242 } // namespace | 242 } // namespace |
| 243 } // namespace internal | 243 } // namespace internal |
| 244 } // namespace base | 244 } // namespace base |
| OLD | NEW |