Add Sad Tab resources to the iOS build.
[chromium-blink-merge.git] / cc / proxy.cc
blob5682a3fee06867db4b13e0709fd13ea9ff28b217
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 "config.h"
7 #include "cc/proxy.h"
9 #include "cc/thread.h"
10 #include "cc/thread_impl.h"
12 namespace cc {
14 Thread* Proxy::mainThread() const
16 return m_mainThread.get();
19 bool Proxy::hasImplThread() const
21 return m_implThread;
24 Thread* Proxy::implThread() const
26 return m_implThread.get();
29 Thread* Proxy::currentThread() const
31 if (mainThread() && mainThread()->belongsToCurrentThread())
32 return mainThread();
33 if (implThread() && implThread()->belongsToCurrentThread())
34 return implThread();
35 return 0;
38 bool Proxy::isMainThread() const
40 #ifndef NDEBUG
41 DCHECK(mainThread());
42 if (m_implThreadIsOverridden)
43 return false;
44 return mainThread()->belongsToCurrentThread();
45 #else
46 return true;
47 #endif
50 bool Proxy::isImplThread() const
52 #ifndef NDEBUG
53 if (m_implThreadIsOverridden)
54 return true;
55 return implThread() && implThread()->belongsToCurrentThread();
56 #else
57 return true;
58 #endif
61 #ifndef NDEBUG
62 void Proxy::setCurrentThreadIsImplThread(bool isImplThread)
64 m_implThreadIsOverridden = isImplThread;
66 #endif
68 bool Proxy::isMainThreadBlocked() const
70 #ifndef NDEBUG
71 return m_isMainThreadBlocked;
72 #else
73 return true;
74 #endif
77 #ifndef NDEBUG
78 void Proxy::setMainThreadBlocked(bool isMainThreadBlocked)
80 m_isMainThreadBlocked = isMainThreadBlocked;
82 #endif
84 Proxy::Proxy(scoped_ptr<Thread> implThread)
85 : m_mainThread(ThreadImpl::createForCurrentThread())
86 , m_implThread(implThread.Pass())
87 #ifndef NDEBUG
88 , m_implThreadIsOverridden(false)
89 , m_isMainThreadBlocked(false)
90 #endif
94 Proxy::~Proxy()
96 DCHECK(isMainThread());
99 } // namespace cc