OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "cc/trees/proxy.h" | 5 #include "cc/trees/proxy.h" |
6 | 6 |
7 #include "base/message_loop/message_loop_proxy.h" | 7 #include "base/message_loop/message_loop_proxy.h" |
8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
9 | 9 |
10 namespace cc { | 10 namespace cc { |
11 | 11 |
12 base::SingleThreadTaskRunner* Proxy::MainThreadTaskRunner() const { | 12 base::SingleThreadTaskRunner* Proxy::MainThreadTaskRunner() const { |
13 return main_task_runner_.get(); | 13 return main_task_runner_.get(); |
14 } | 14 } |
15 | 15 |
16 bool Proxy::HasImplThread() const { return !!impl_task_runner_.get(); } | 16 bool Proxy::HasImplThread() const { return !!impl_task_runner_.get(); } |
17 | 17 |
18 base::SingleThreadTaskRunner* Proxy::ImplThreadTaskRunner() const { | 18 base::SingleThreadTaskRunner* Proxy::ImplThreadTaskRunner() const { |
19 return impl_task_runner_.get(); | 19 return impl_task_runner_.get(); |
20 } | 20 } |
21 | 21 |
22 bool Proxy::IsMainThread() const { | 22 bool Proxy::IsMainThread() const { |
23 #if DCHECK_IS_ON | 23 #if DCHECK_IS_ON |
24 DCHECK(main_task_runner_.get()); | |
25 if (impl_thread_is_overridden_) | 24 if (impl_thread_is_overridden_) |
26 return false; | 25 return false; |
27 return main_task_runner_->BelongsToCurrentThread(); | 26 |
| 27 bool is_main_thread = base::PlatformThread::CurrentId() == main_thread_id_; |
| 28 if (is_main_thread && main_task_runner_.get()) { |
| 29 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 30 } |
| 31 return is_main_thread; |
28 #else | 32 #else |
29 return true; | 33 return true; |
30 #endif | 34 #endif |
31 } | 35 } |
32 | 36 |
33 bool Proxy::IsImplThread() const { | 37 bool Proxy::IsImplThread() const { |
34 #if DCHECK_IS_ON | 38 #if DCHECK_IS_ON |
35 if (impl_thread_is_overridden_) | 39 if (impl_thread_is_overridden_) |
36 return true; | 40 return true; |
37 if (!impl_task_runner_.get()) | 41 if (!impl_task_runner_.get()) |
(...skipping 23 matching lines...) Expand all Loading... |
61 is_main_thread_blocked_ = is_main_thread_blocked; | 65 is_main_thread_blocked_ = is_main_thread_blocked; |
62 } | 66 } |
63 #endif | 67 #endif |
64 | 68 |
65 Proxy::Proxy(scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) | 69 Proxy::Proxy(scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) |
66 : main_task_runner_(base::MessageLoopProxy::current()), | 70 : main_task_runner_(base::MessageLoopProxy::current()), |
67 #if !DCHECK_IS_ON | 71 #if !DCHECK_IS_ON |
68 impl_task_runner_(impl_task_runner) { | 72 impl_task_runner_(impl_task_runner) { |
69 #else | 73 #else |
70 impl_task_runner_(impl_task_runner), | 74 impl_task_runner_(impl_task_runner), |
| 75 main_thread_id_(base::PlatformThread::CurrentId()), |
71 impl_thread_is_overridden_(false), | 76 impl_thread_is_overridden_(false), |
72 is_main_thread_blocked_(false) { | 77 is_main_thread_blocked_(false) { |
73 #endif | 78 #endif |
74 } | 79 } |
75 | 80 |
76 Proxy::~Proxy() { | 81 Proxy::~Proxy() { |
77 DCHECK(IsMainThread()); | 82 DCHECK(IsMainThread()); |
78 } | 83 } |
79 | 84 |
80 scoped_ptr<base::Value> Proxy::SchedulerAsValueForTesting() { | 85 scoped_ptr<base::Value> Proxy::SchedulerAsValueForTesting() { |
81 return make_scoped_ptr(base::Value::CreateNullValue()); | 86 return make_scoped_ptr(base::Value::CreateNullValue()); |
82 } | 87 } |
83 | 88 |
84 } // namespace cc | 89 } // namespace cc |
OLD | NEW |