| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef BASE_THREADING_TASK_RUNNER_HANDLE_INTERNAL_H_ |
| 6 #define BASE_THREADING_TASK_RUNNER_HANDLE_INTERNAL_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" |
| 10 |
| 11 namespace base { |
| 12 |
| 13 class SequencedTaskRunner; |
| 14 class SingleThreadTaskRunner; |
| 15 class TaskRunner; |
| 16 |
| 17 namespace internal { |
| 18 |
| 19 // Holds the state associated with one of the TaskScope variants. Stores the |
| 20 // relevant pointer in a generic TaskRunner pointer and remembers the type |
| 21 // through an enum which makes for fast lookup of which levels of TaskRunners |
| 22 // are available. |
| 23 struct TaskScopeState { |
| 24 TaskScopeState(scoped_refptr<TaskRunner> task_runner); |
| 25 TaskScopeState(scoped_refptr<SequencedTaskRunner> sequenced_task_runner); |
| 26 TaskScopeState( |
| 27 scoped_refptr<SingleThreadTaskRunner> single_thread_task_runner); |
| 28 |
| 29 ~TaskScopeState(); |
| 30 |
| 31 // TaskScope types sorted from least restrictive to most restrictive. Order |
| 32 // is used for quick lookup of available TaskScope type on current thread. |
| 33 enum Type { PARALLEL, SEQUENCED, SINGLE_THREADED }; |
| 34 |
| 35 const Type type; |
| 36 |
| 37 // A generic TaskRunner to store the potentially more specific TaskRunner |
| 38 // which can safely be upcasted if |type| allows. |
| 39 const scoped_refptr<TaskRunner> task_runner; |
| 40 |
| 41 private: |
| 42 DISALLOW_COPY_AND_ASSIGN(TaskScopeState); |
| 43 }; |
| 44 |
| 45 } // namespace internal |
| 46 } // namespace base |
| 47 |
| 48 #endif // BASE_THREADING_TASK_RUNNER_HANDLE_INTERNAL_H_ |
| OLD | NEW |