| 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.h" | 5 #include "base/task_scheduler/scheduler_worker.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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 165 |
| 166 // Check if a Sequence should be returned. | 166 // Check if a Sequence should be returned. |
| 167 if (outer_->num_sequences_to_create_ == 0) | 167 if (outer_->num_sequences_to_create_ == 0) |
| 168 return nullptr; | 168 return nullptr; |
| 169 --outer_->num_sequences_to_create_; | 169 --outer_->num_sequences_to_create_; |
| 170 } | 170 } |
| 171 | 171 |
| 172 // Create a Sequence with TasksPerSequence() Tasks. | 172 // Create a Sequence with TasksPerSequence() Tasks. |
| 173 scoped_refptr<Sequence> sequence(new Sequence); | 173 scoped_refptr<Sequence> sequence(new Sequence); |
| 174 for (size_t i = 0; i < outer_->TasksPerSequence(); ++i) { | 174 for (size_t i = 0; i < outer_->TasksPerSequence(); ++i) { |
| 175 std::unique_ptr<Task> task(new Task( | 175 std::unique_ptr<Task> task( |
| 176 FROM_HERE, Bind(&TaskSchedulerWorkerTest::RunTaskCallback, | 176 new Task(FROM_HERE, |
| 177 Unretained(outer_)), | 177 BindOnce(&TaskSchedulerWorkerTest::RunTaskCallback, |
| 178 TaskTraits(), TimeDelta())); | 178 Unretained(outer_)), |
| 179 TaskTraits(), TimeDelta())); |
| 179 EXPECT_TRUE(outer_->task_tracker_.WillPostTask(task.get())); | 180 EXPECT_TRUE(outer_->task_tracker_.WillPostTask(task.get())); |
| 180 sequence->PushTask(std::move(task)); | 181 sequence->PushTask(std::move(task)); |
| 181 } | 182 } |
| 182 | 183 |
| 183 ExpectCallToDidRunTask(); | 184 ExpectCallToDidRunTask(); |
| 184 | 185 |
| 185 { | 186 { |
| 186 // Add the Sequence to the vector of created Sequences. | 187 // Add the Sequence to the vector of created Sequences. |
| 187 AutoSchedulerLock auto_lock(outer_->lock_); | 188 AutoSchedulerLock auto_lock(outer_->lock_); |
| 188 outer_->created_sequences_.push_back(sequence); | 189 outer_->created_sequences_.push_back(sequence); |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 override { | 428 override { |
| 428 // Sends one item of work to signal |work_processed_|. On subsequent calls, | 429 // Sends one item of work to signal |work_processed_|. On subsequent calls, |
| 429 // sends nullptr to indicate there's no more work to be done. | 430 // sends nullptr to indicate there's no more work to be done. |
| 430 if (controls_->work_requested_) | 431 if (controls_->work_requested_) |
| 431 return nullptr; | 432 return nullptr; |
| 432 | 433 |
| 433 controls_->work_requested_ = true; | 434 controls_->work_requested_ = true; |
| 434 scoped_refptr<Sequence> sequence(new Sequence); | 435 scoped_refptr<Sequence> sequence(new Sequence); |
| 435 std::unique_ptr<Task> task(new Task( | 436 std::unique_ptr<Task> task(new Task( |
| 436 FROM_HERE, | 437 FROM_HERE, |
| 437 Bind( | 438 BindOnce( |
| 438 [](WaitableEvent* work_processed, WaitableEvent* work_running) { | 439 [](WaitableEvent* work_processed, WaitableEvent* work_running) { |
| 439 work_processed->Signal(); | 440 work_processed->Signal(); |
| 440 work_running->Wait(); | 441 work_running->Wait(); |
| 441 }, | 442 }, |
| 442 Unretained(&controls_->work_processed_), | 443 Unretained(&controls_->work_processed_), |
| 443 Unretained(&controls_->work_running_)), | 444 Unretained(&controls_->work_running_)), |
| 444 TaskTraits().WithBaseSyncPrimitives().WithShutdownBehavior( | 445 TaskTraits().WithBaseSyncPrimitives().WithShutdownBehavior( |
| 445 TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN), | 446 TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN), |
| 446 TimeDelta())); | 447 TimeDelta())); |
| 447 EXPECT_TRUE(task_tracker_->WillPostTask(task.get())); | 448 EXPECT_TRUE(task_tracker_->WillPostTask(task.get())); |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 // COM library wasn't already initialized on the thread. | 920 // COM library wasn't already initialized on the thread. |
| 920 EXPECT_EQ(S_OK, delegate_raw->coinitialize_hresult()); | 921 EXPECT_EQ(S_OK, delegate_raw->coinitialize_hresult()); |
| 921 | 922 |
| 922 worker->JoinForTesting(); | 923 worker->JoinForTesting(); |
| 923 } | 924 } |
| 924 | 925 |
| 925 #endif // defined(OS_WIN) | 926 #endif // defined(OS_WIN) |
| 926 | 927 |
| 927 } // namespace internal | 928 } // namespace internal |
| 928 } // namespace base | 929 } // namespace base |
| OLD | NEW |