Don't consider a Bluetooth adapter present until it has an address.
[chromium-blink-merge.git] / cc / CCProxy.cpp
blobb0894424d904b0d879650237cdb9bdb3f848fd63
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"
10 #include <wtf/MainThread.h>
12 using namespace WTF;
14 namespace WebCore {
16 namespace {
17 #ifndef NDEBUG
18 bool implThreadIsOverridden = false;
19 bool s_isMainThreadBlocked = false;
20 base::PlatformThreadId threadIDOverridenToBeImplThread;
21 #endif
22 CCThread* s_mainThread = 0;
23 CCThread* s_implThread = 0;
26 void CCProxy::setMainThread(CCThread* thread)
28 s_mainThread = thread;
31 CCThread* CCProxy::mainThread()
33 return s_mainThread;
36 bool CCProxy::hasImplThread()
38 return s_implThread;
41 void CCProxy::setImplThread(CCThread* thread)
43 s_implThread = thread;
46 CCThread* CCProxy::implThread()
48 return s_implThread;
51 CCThread* CCProxy::currentThread()
53 base::PlatformThreadId currentThreadIdentifier = base::PlatformThread::CurrentId();
54 if (s_mainThread && s_mainThread->threadID() == currentThreadIdentifier)
55 return s_mainThread;
56 if (s_implThread && s_implThread->threadID() == currentThreadIdentifier)
57 return s_implThread;
58 return 0;
61 #ifndef NDEBUG
62 bool CCProxy::isMainThread()
64 ASSERT(s_mainThread);
65 if (implThreadIsOverridden && base::PlatformThread::CurrentId() == threadIDOverridenToBeImplThread)
66 return false;
67 return base::PlatformThread::CurrentId() == s_mainThread->threadID();
70 bool CCProxy::isImplThread()
72 base::PlatformThreadId implThreadID = s_implThread ? s_implThread->threadID() : 0;
73 if (implThreadIsOverridden && base::PlatformThread::CurrentId() == threadIDOverridenToBeImplThread)
74 return true;
75 return base::PlatformThread::CurrentId() == implThreadID;
78 void CCProxy::setCurrentThreadIsImplThread(bool isImplThread)
80 implThreadIsOverridden = isImplThread;
81 if (isImplThread)
82 threadIDOverridenToBeImplThread = base::PlatformThread::CurrentId();
85 bool CCProxy::isMainThreadBlocked()
87 return s_isMainThreadBlocked;
90 void CCProxy::setMainThreadBlocked(bool isMainThreadBlocked)
92 s_isMainThreadBlocked = isMainThreadBlocked;
94 #endif
96 CCProxy::CCProxy()
98 ASSERT(isMainThread());
101 CCProxy::~CCProxy()
103 ASSERT(isMainThread());