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 "base/message_loop/message_loop_proxy.h"
8 #include "base/single_thread_task_runner.h"
12 base::SingleThreadTaskRunner
* Proxy::MainThreadTaskRunner() const {
13 return main_task_runner_
.get();
16 bool Proxy::HasImplThread() const { return !!impl_task_runner_
.get(); }
18 base::SingleThreadTaskRunner
* Proxy::ImplThreadTaskRunner() const {
19 return impl_task_runner_
.get();
22 bool Proxy::IsMainThread() const {
24 DCHECK(main_task_runner_
.get());
25 if (impl_thread_is_overridden_
)
27 return main_task_runner_
->BelongsToCurrentThread();
33 bool Proxy::IsImplThread() const {
35 if (impl_thread_is_overridden_
)
37 if (!impl_task_runner_
.get())
39 return impl_task_runner_
->BelongsToCurrentThread();
46 void Proxy::SetCurrentThreadIsImplThread(bool is_impl_thread
) {
47 impl_thread_is_overridden_
= is_impl_thread
;
51 bool Proxy::IsMainThreadBlocked() const {
53 return is_main_thread_blocked_
;
60 void Proxy::SetMainThreadBlocked(bool is_main_thread_blocked
) {
61 is_main_thread_blocked_
= is_main_thread_blocked
;
66 scoped_refptr
<base::SingleThreadTaskRunner
> impl_task_runner
)
67 : main_task_runner_(base::MessageLoopProxy::current()),
69 impl_task_runner_(impl_task_runner
) {}
71 impl_task_runner_(impl_task_runner
),
72 impl_thread_is_overridden_(false),
73 is_main_thread_blocked_(false) {}
77 DCHECK(IsMainThread());
80 scoped_ptr
<base::Value
> Proxy::SchedulerStateAsValueForTesting() {
81 return make_scoped_ptr(base::Value::CreateNullValue());