Remove extra line from unit_tests.isolate
[chromium-blink-merge.git] / cc / CCProxy.cpp
blobbc5ae69a57b362022d0022cc5c4a2b7e4d7e8ef3
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 "CCProxy.h"
9 #include "CCThreadTask.h"
11 using namespace WTF;
13 namespace cc {
15 namespace {
16 #ifndef NDEBUG
17 bool implThreadIsOverridden = false;
18 bool s_isMainThreadBlocked = false;
19 base::PlatformThreadId threadIDOverridenToBeImplThread;
20 #endif
21 CCThread* s_mainThread = 0;
22 CCThread* s_implThread = 0;
25 void CCProxy::setMainThread(CCThread* thread)
27 s_mainThread = thread;
30 CCThread* CCProxy::mainThread()
32 return s_mainThread;
35 bool CCProxy::hasImplThread()
37 return s_implThread;
40 void CCProxy::setImplThread(CCThread* thread)
42 s_implThread = thread;
45 CCThread* CCProxy::implThread()
47 return s_implThread;
50 CCThread* CCProxy::currentThread()
52 base::PlatformThreadId currentThreadIdentifier = base::PlatformThread::CurrentId();
53 if (s_mainThread && s_mainThread->threadID() == currentThreadIdentifier)
54 return s_mainThread;
55 if (s_implThread && s_implThread->threadID() == currentThreadIdentifier)
56 return s_implThread;
57 return 0;
60 #ifndef NDEBUG
61 bool CCProxy::isMainThread()
63 ASSERT(s_mainThread);
64 if (implThreadIsOverridden && base::PlatformThread::CurrentId() == threadIDOverridenToBeImplThread)
65 return false;
66 return base::PlatformThread::CurrentId() == s_mainThread->threadID();
69 bool CCProxy::isImplThread()
71 base::PlatformThreadId implThreadID = s_implThread ? s_implThread->threadID() : 0;
72 if (implThreadIsOverridden && base::PlatformThread::CurrentId() == threadIDOverridenToBeImplThread)
73 return true;
74 return base::PlatformThread::CurrentId() == implThreadID;
77 void CCProxy::setCurrentThreadIsImplThread(bool isImplThread)
79 implThreadIsOverridden = isImplThread;
80 if (isImplThread)
81 threadIDOverridenToBeImplThread = base::PlatformThread::CurrentId();
84 bool CCProxy::isMainThreadBlocked()
86 return s_isMainThreadBlocked;
89 void CCProxy::setMainThreadBlocked(bool isMainThreadBlocked)
91 s_isMainThreadBlocked = isMainThreadBlocked;
93 #endif
95 CCProxy::CCProxy()
97 ASSERT(isMainThread());
100 CCProxy::~CCProxy()
102 ASSERT(isMainThread());