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
3 // found in the LICENSE file.
5 #include "cc/trees/proxy.h"
7 #include "cc/base/thread.h"
8 #include "cc/base/thread_impl.h"
12 Thread
* Proxy::MainThread() const { return main_thread_
.get(); }
14 bool Proxy::HasImplThread() const { return impl_thread_
; }
16 Thread
* Proxy::ImplThread() const { return impl_thread_
.get(); }
18 Thread
* Proxy::CurrentThread() const {
19 if (MainThread() && MainThread()->BelongsToCurrentThread())
21 if (ImplThread() && ImplThread()->BelongsToCurrentThread())
26 bool Proxy::IsMainThread() const {
29 if (impl_thread_is_overridden_
)
31 return MainThread()->BelongsToCurrentThread();
37 bool Proxy::IsImplThread() const {
39 if (impl_thread_is_overridden_
)
41 return ImplThread() && ImplThread()->BelongsToCurrentThread();
48 void Proxy::SetCurrentThreadIsImplThread(bool is_impl_thread
) {
49 impl_thread_is_overridden_
= is_impl_thread
;
53 bool Proxy::IsMainThreadBlocked() const {
55 return is_main_thread_blocked_
;
62 void Proxy::SetMainThreadBlocked(bool is_main_thread_blocked
) {
63 is_main_thread_blocked_
= is_main_thread_blocked
;
67 Proxy::Proxy(scoped_ptr
<Thread
> impl_thread
)
68 : main_thread_(ThreadImpl::CreateForCurrentThread()),
70 impl_thread_(impl_thread
.Pass()) {}
72 impl_thread_(impl_thread
.Pass()),
73 impl_thread_is_overridden_(false),
74 is_main_thread_blocked_(false) {}
78 DCHECK(IsMainThread());