OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CC_TREES_TASK_RUNNER_PROVIDER_H_ | 5 #ifndef CC_TREES_TASK_RUNNER_PROVIDER_H_ |
6 #define CC_TREES_TASK_RUNNER_PROVIDER_H_ | 6 #define CC_TREES_TASK_RUNNER_PROVIDER_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <string> | 9 #include <string> |
9 | 10 |
10 #include "base/logging.h" | 11 #include "base/logging.h" |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ptr_util.h" |
12 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
15 #include "base/threading/platform_thread.h" | 16 #include "base/threading/platform_thread.h" |
16 #include "base/time/time.h" | 17 #include "base/time/time.h" |
17 #include "base/values.h" | 18 #include "base/values.h" |
18 #include "cc/base/cc_export.h" | 19 #include "cc/base/cc_export.h" |
19 | 20 |
20 namespace base { | 21 namespace base { |
21 namespace trace_event { | 22 namespace trace_event { |
22 class TracedValue; | 23 class TracedValue; |
23 } | 24 } |
24 class SingleThreadTaskRunner; | 25 class SingleThreadTaskRunner; |
25 } | 26 } |
26 | 27 |
27 namespace cc { | 28 namespace cc { |
28 class BlockingTaskRunner; | 29 class BlockingTaskRunner; |
29 | 30 |
30 // Class responsible for controlling access to the main and impl task runners. | 31 // Class responsible for controlling access to the main and impl task runners. |
31 // Useful for assertion checks. | 32 // Useful for assertion checks. |
32 class CC_EXPORT TaskRunnerProvider { | 33 class CC_EXPORT TaskRunnerProvider { |
33 public: | 34 public: |
34 static scoped_ptr<TaskRunnerProvider> Create( | 35 static std::unique_ptr<TaskRunnerProvider> Create( |
35 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 36 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
36 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 37 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
37 return make_scoped_ptr( | 38 return base::WrapUnique( |
38 new TaskRunnerProvider(main_task_runner, impl_task_runner)); | 39 new TaskRunnerProvider(main_task_runner, impl_task_runner)); |
39 } | 40 } |
40 | 41 |
41 base::SingleThreadTaskRunner* MainThreadTaskRunner() const; | 42 base::SingleThreadTaskRunner* MainThreadTaskRunner() const; |
42 bool HasImplThread() const; | 43 bool HasImplThread() const; |
43 base::SingleThreadTaskRunner* ImplThreadTaskRunner() const; | 44 base::SingleThreadTaskRunner* ImplThreadTaskRunner() const; |
44 | 45 |
45 // Debug hooks. | 46 // Debug hooks. |
46 bool IsMainThread() const; | 47 bool IsMainThread() const; |
47 bool IsImplThread() const; | 48 bool IsImplThread() const; |
(...skipping 14 matching lines...) Expand all Loading... |
62 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 63 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
63 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); | 64 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); |
64 | 65 |
65 friend class DebugScopedSetImplThread; | 66 friend class DebugScopedSetImplThread; |
66 friend class DebugScopedSetMainThread; | 67 friend class DebugScopedSetMainThread; |
67 friend class DebugScopedSetMainThreadBlocked; | 68 friend class DebugScopedSetMainThreadBlocked; |
68 | 69 |
69 private: | 70 private: |
70 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | 71 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
71 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner_; | 72 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner_; |
72 scoped_ptr<BlockingTaskRunner> blocking_main_thread_task_runner_; | 73 std::unique_ptr<BlockingTaskRunner> blocking_main_thread_task_runner_; |
73 | 74 |
74 #if DCHECK_IS_ON() | 75 #if DCHECK_IS_ON() |
75 const base::PlatformThreadId main_thread_id_; | 76 const base::PlatformThreadId main_thread_id_; |
76 bool impl_thread_is_overridden_; | 77 bool impl_thread_is_overridden_; |
77 bool is_main_thread_blocked_; | 78 bool is_main_thread_blocked_; |
78 #endif | 79 #endif |
79 | 80 |
80 DISALLOW_COPY_AND_ASSIGN(TaskRunnerProvider); | 81 DISALLOW_COPY_AND_ASSIGN(TaskRunnerProvider); |
81 }; | 82 }; |
82 | 83 |
(...skipping 23 matching lines...) Expand all Loading... |
106 ~DebugScopedSetMainThreadBlocked() {} | 107 ~DebugScopedSetMainThreadBlocked() {} |
107 | 108 |
108 private: | 109 private: |
109 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetMainThreadBlocked); | 110 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetMainThreadBlocked); |
110 }; | 111 }; |
111 #endif | 112 #endif |
112 | 113 |
113 } // namespace cc | 114 } // namespace cc |
114 | 115 |
115 #endif // CC_TREES_TASK_RUNNER_PROVIDER_H_ | 116 #endif // CC_TREES_TASK_RUNNER_PROVIDER_H_ |
OLD | NEW |