| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/single_thread_task_runner.h" |
| 14 #include "base/threading/platform_thread.h" | 15 #include "base/threading/platform_thread.h" |
| 15 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 16 #include "base/values.h" | 17 #include "base/values.h" |
| 17 #include "cc/base/cc_export.h" | 18 #include "cc/base/cc_export.h" |
| 18 | 19 |
| 19 namespace base { | 20 namespace base { |
| 20 namespace trace_event { | 21 namespace trace_event { |
| 21 class TracedValue; | 22 class TracedValue; |
| 22 } | 23 } |
| 23 class SingleThreadTaskRunner; | 24 class SingleThreadTaskRunner; |
| 24 } | 25 } |
| 25 | 26 |
| 26 namespace cc { | 27 namespace cc { |
| 27 class BlockingTaskRunner; | 28 class BlockingTaskRunner; |
| 28 | 29 |
| 29 // Class responsible for controlling access to the main and impl task runners. | 30 // Class responsible for controlling access to the main and impl task runners. |
| 30 // Useful for assertion checks. | 31 // Useful for assertion checks. |
| 31 class CC_EXPORT TaskRunnerProvider { | 32 class CC_EXPORT TaskRunnerProvider { |
| 32 public: | 33 public: |
| 34 static scoped_ptr<TaskRunnerProvider> Create( |
| 35 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 36 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
| 37 return make_scoped_ptr( |
| 38 new TaskRunnerProvider(main_task_runner, impl_task_runner)); |
| 39 } |
| 40 |
| 33 base::SingleThreadTaskRunner* MainThreadTaskRunner() const; | 41 base::SingleThreadTaskRunner* MainThreadTaskRunner() const; |
| 34 bool HasImplThread() const; | 42 bool HasImplThread() const; |
| 35 base::SingleThreadTaskRunner* ImplThreadTaskRunner() const; | 43 base::SingleThreadTaskRunner* ImplThreadTaskRunner() const; |
| 36 | 44 |
| 37 // Debug hooks. | 45 // Debug hooks. |
| 38 bool IsMainThread() const; | 46 bool IsMainThread() const; |
| 39 bool IsImplThread() const; | 47 bool IsImplThread() const; |
| 40 bool IsMainThreadBlocked() const; | 48 bool IsMainThreadBlocked() const; |
| 41 #if DCHECK_IS_ON() | 49 #if DCHECK_IS_ON() |
| 42 void SetMainThreadBlocked(bool is_main_thread_blocked); | 50 void SetMainThreadBlocked(bool is_main_thread_blocked); |
| 43 void SetCurrentThreadIsImplThread(bool is_impl_thread); | 51 void SetCurrentThreadIsImplThread(bool is_impl_thread); |
| 44 #endif | 52 #endif |
| 45 | 53 |
| 46 virtual ~TaskRunnerProvider(); | 54 virtual ~TaskRunnerProvider(); |
| 47 | 55 |
| 48 BlockingTaskRunner* blocking_main_thread_task_runner() const { | 56 BlockingTaskRunner* blocking_main_thread_task_runner() const { |
| 49 return blocking_main_thread_task_runner_.get(); | 57 return blocking_main_thread_task_runner_.get(); |
| 50 } | 58 } |
| 51 | 59 |
| 60 protected: |
| 52 TaskRunnerProvider( | 61 TaskRunnerProvider( |
| 53 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 62 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 54 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); | 63 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); |
| 55 | 64 |
| 56 protected: | |
| 57 friend class DebugScopedSetImplThread; | 65 friend class DebugScopedSetImplThread; |
| 58 friend class DebugScopedSetMainThread; | 66 friend class DebugScopedSetMainThread; |
| 59 friend class DebugScopedSetMainThreadBlocked; | 67 friend class DebugScopedSetMainThreadBlocked; |
| 60 | 68 |
| 61 private: | 69 private: |
| 62 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | 70 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
| 63 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner_; | 71 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner_; |
| 64 scoped_ptr<BlockingTaskRunner> blocking_main_thread_task_runner_; | 72 scoped_ptr<BlockingTaskRunner> blocking_main_thread_task_runner_; |
| 65 | 73 |
| 66 #if DCHECK_IS_ON() | 74 #if DCHECK_IS_ON() |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 ~DebugScopedSetMainThreadBlocked() {} | 106 ~DebugScopedSetMainThreadBlocked() {} |
| 99 | 107 |
| 100 private: | 108 private: |
| 101 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetMainThreadBlocked); | 109 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetMainThreadBlocked); |
| 102 }; | 110 }; |
| 103 #endif | 111 #endif |
| 104 | 112 |
| 105 } // namespace cc | 113 } // namespace cc |
| 106 | 114 |
| 107 #endif // CC_TREES_TASK_RUNNER_PROVIDER_H_ | 115 #endif // CC_TREES_TASK_RUNNER_PROVIDER_H_ |
| OLD | NEW |