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_pool_impl.h" | 5 #include "base/task_scheduler/scheduler_worker_pool_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <unordered_set> | 10 #include <unordered_set> |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 } | 331 } |
332 | 332 |
333 // Verifies that the current thread allows I/O if |io_restriction| is ALLOWED | 333 // Verifies that the current thread allows I/O if |io_restriction| is ALLOWED |
334 // and disallows it otherwise. Signals |event| before returning. | 334 // and disallows it otherwise. Signals |event| before returning. |
335 void ExpectIORestriction(IORestriction io_restriction, WaitableEvent* event) { | 335 void ExpectIORestriction(IORestriction io_restriction, WaitableEvent* event) { |
336 DCHECK(event); | 336 DCHECK(event); |
337 | 337 |
338 if (io_restriction == IORestriction::ALLOWED) { | 338 if (io_restriction == IORestriction::ALLOWED) { |
339 ThreadRestrictions::AssertIOAllowed(); | 339 ThreadRestrictions::AssertIOAllowed(); |
340 } else { | 340 } else { |
341 static_assert( | |
342 ENABLE_THREAD_RESTRICTIONS == DCHECK_IS_ON(), | |
343 "ENABLE_THREAD_RESTRICTIONS and DCHECK_IS_ON() have diverged."); | |
344 EXPECT_DCHECK_DEATH({ ThreadRestrictions::AssertIOAllowed(); }, ""); | 341 EXPECT_DCHECK_DEATH({ ThreadRestrictions::AssertIOAllowed(); }, ""); |
345 } | 342 } |
346 | 343 |
347 event->Signal(); | 344 event->Signal(); |
348 } | 345 } |
349 | 346 |
350 class TaskSchedulerWorkerPoolImplIORestrictionTest | 347 class TaskSchedulerWorkerPoolImplIORestrictionTest |
351 : public testing::TestWithParam<IORestriction> { | 348 : public testing::TestWithParam<IORestriction> { |
352 public: | 349 public: |
353 TaskSchedulerWorkerPoolImplIORestrictionTest() = default; | 350 TaskSchedulerWorkerPoolImplIORestrictionTest() = default; |
(...skipping 25 matching lines...) Expand all Loading... |
379 | 376 |
380 INSTANTIATE_TEST_CASE_P(IOAllowed, | 377 INSTANTIATE_TEST_CASE_P(IOAllowed, |
381 TaskSchedulerWorkerPoolImplIORestrictionTest, | 378 TaskSchedulerWorkerPoolImplIORestrictionTest, |
382 ::testing::Values(IORestriction::ALLOWED)); | 379 ::testing::Values(IORestriction::ALLOWED)); |
383 INSTANTIATE_TEST_CASE_P(IODisallowed, | 380 INSTANTIATE_TEST_CASE_P(IODisallowed, |
384 TaskSchedulerWorkerPoolImplIORestrictionTest, | 381 TaskSchedulerWorkerPoolImplIORestrictionTest, |
385 ::testing::Values(IORestriction::DISALLOWED)); | 382 ::testing::Values(IORestriction::DISALLOWED)); |
386 | 383 |
387 } // namespace internal | 384 } // namespace internal |
388 } // namespace base | 385 } // namespace base |
OLD | NEW |