diff options
author | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-10 22:04:21 +0000 |
---|---|---|
committer | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-10 22:04:21 +0000 |
commit | dedbe4068e61e476f7dc42f0921dba360329b3e8 (patch) | |
tree | 59f333e3ba8a54f324caae5d236e1bb679cc6ee1 | |
parent | efa810b842c84c52825e6446ba2608ffa4e2450a (diff) | |
download | chromium_src-dedbe4068e61e476f7dc42f0921dba360329b3e8.zip chromium_src-dedbe4068e61e476f7dc42f0921dba360329b3e8.tar.gz chromium_src-dedbe4068e61e476f7dc42f0921dba360329b3e8.tar.bz2 |
Avoid using WTF threading code in cc
This stuff isn't available in the component build since we only initialize WTF
threading inside WebKit.dll and cc isn't in WebKit.dll
BUG=
Review URL: https://chromiumcodereview.appspot.com/10913158
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155846 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | cc/CCProxy.cpp | 16 | ||||
-rw-r--r-- | cc/CCProxy.h | 1 | ||||
-rw-r--r-- | cc/CCScopedTexture.cpp | 4 | ||||
-rw-r--r-- | cc/CCScopedTexture.h | 4 | ||||
-rw-r--r-- | cc/CCScopedThreadProxy.h | 7 | ||||
-rw-r--r-- | cc/CCThread.h | 5 | ||||
-rw-r--r-- | cc/test/CCSchedulerTestCommon.h | 3 | ||||
-rw-r--r-- | webkit/compositor_bindings/CCThreadImpl.cpp | 24 | ||||
-rw-r--r-- | webkit/compositor_bindings/CCThreadImpl.h | 14 | ||||
-rw-r--r-- | webkit/compositor_bindings/WebCompositorImpl.cpp | 12 |
10 files changed, 55 insertions, 35 deletions
diff --git a/cc/CCProxy.cpp b/cc/CCProxy.cpp index 2e89398..b089442 100644 --- a/cc/CCProxy.cpp +++ b/cc/CCProxy.cpp @@ -17,7 +17,7 @@ namespace { #ifndef NDEBUG bool implThreadIsOverridden = false; bool s_isMainThreadBlocked = false; -ThreadIdentifier threadIDOverridenToBeImplThread; +base::PlatformThreadId threadIDOverridenToBeImplThread; #endif CCThread* s_mainThread = 0; CCThread* s_implThread = 0; @@ -50,7 +50,7 @@ CCThread* CCProxy::implThread() CCThread* CCProxy::currentThread() { - ThreadIdentifier currentThreadIdentifier = WTF::currentThread(); + base::PlatformThreadId currentThreadIdentifier = base::PlatformThread::CurrentId(); if (s_mainThread && s_mainThread->threadID() == currentThreadIdentifier) return s_mainThread; if (s_implThread && s_implThread->threadID() == currentThreadIdentifier) @@ -62,24 +62,24 @@ CCThread* CCProxy::currentThread() bool CCProxy::isMainThread() { ASSERT(s_mainThread); - if (implThreadIsOverridden && WTF::currentThread() == threadIDOverridenToBeImplThread) + if (implThreadIsOverridden && base::PlatformThread::CurrentId() == threadIDOverridenToBeImplThread) return false; - return WTF::currentThread() == s_mainThread->threadID(); + return base::PlatformThread::CurrentId() == s_mainThread->threadID(); } bool CCProxy::isImplThread() { - WTF::ThreadIdentifier implThreadID = s_implThread ? s_implThread->threadID() : 0; - if (implThreadIsOverridden && WTF::currentThread() == threadIDOverridenToBeImplThread) + base::PlatformThreadId implThreadID = s_implThread ? s_implThread->threadID() : 0; + if (implThreadIsOverridden && base::PlatformThread::CurrentId() == threadIDOverridenToBeImplThread) return true; - return WTF::currentThread() == implThreadID; + return base::PlatformThread::CurrentId() == implThreadID; } void CCProxy::setCurrentThreadIsImplThread(bool isImplThread) { implThreadIsOverridden = isImplThread; if (isImplThread) - threadIDOverridenToBeImplThread = WTF::currentThread(); + threadIDOverridenToBeImplThread = base::PlatformThread::CurrentId(); } bool CCProxy::isMainThreadBlocked() diff --git a/cc/CCProxy.h b/cc/CCProxy.h index f2cbc7d..486c132 100644 --- a/cc/CCProxy.h +++ b/cc/CCProxy.h @@ -10,7 +10,6 @@ #include <wtf/Noncopyable.h> #include <wtf/PassOwnPtr.h> #include <wtf/PassRefPtr.h> -#include <wtf/Threading.h> namespace WebCore { diff --git a/cc/CCScopedTexture.cpp b/cc/CCScopedTexture.cpp index b032680..524dfd4 100644 --- a/cc/CCScopedTexture.cpp +++ b/cc/CCScopedTexture.cpp @@ -28,7 +28,7 @@ bool CCScopedTexture::allocate(int pool, const IntSize& size, GC3Denum format, C setId(m_resourceProvider->createResource(pool, size, format, hint)); #if !ASSERT_DISABLED - m_allocateThreadIdentifier = WTF::currentThread(); + m_allocateThreadIdentifier = base::PlatformThread::CurrentId(); #endif return id(); @@ -37,7 +37,7 @@ bool CCScopedTexture::allocate(int pool, const IntSize& size, GC3Denum format, C void CCScopedTexture::free() { if (id()) { - ASSERT(m_allocateThreadIdentifier == WTF::currentThread()); + ASSERT(m_allocateThreadIdentifier == base::PlatformThread::CurrentId()); m_resourceProvider->deleteResource(id()); } setId(0); diff --git a/cc/CCScopedTexture.h b/cc/CCScopedTexture.h index c82b8bc..866c050c 100644 --- a/cc/CCScopedTexture.h +++ b/cc/CCScopedTexture.h @@ -8,7 +8,7 @@ #include "CCTexture.h" #if !ASSERT_DISABLED -#include <wtf/MainThread.h> +#include "base/threading/platform_thread.h" #endif namespace WebCore { @@ -35,7 +35,7 @@ private: CCResourceProvider* m_resourceProvider; #if !ASSERT_DISABLED - ThreadIdentifier m_allocateThreadIdentifier; + base::PlatformThreadId m_allocateThreadIdentifier; #endif }; diff --git a/cc/CCScopedThreadProxy.h b/cc/CCScopedThreadProxy.h index e30587c..32c5b8e 100644 --- a/cc/CCScopedThreadProxy.h +++ b/cc/CCScopedThreadProxy.h @@ -6,6 +6,7 @@ #define CCScopedThreadProxy_h #include "CCThreadTask.h" +#include "base/threading/platform_thread.h" #include <wtf/ThreadSafeRefCounted.h> namespace WebCore { @@ -24,7 +25,7 @@ class CCScopedThreadProxy : public ThreadSafeRefCounted<CCScopedThreadProxy> { public: static PassRefPtr<CCScopedThreadProxy> create(CCThread* targetThread) { - ASSERT(currentThread() == targetThread->threadID()); + ASSERT(base::PlatformThread::CurrentId() == targetThread->threadID()); return adoptRef(new CCScopedThreadProxy(targetThread)); } @@ -38,7 +39,7 @@ public: void shutdown() { - ASSERT(currentThread() == m_targetThread->threadID()); + ASSERT(base::PlatformThread::CurrentId() == m_targetThread->threadID()); ASSERT(!m_shutdown); m_shutdown = true; } @@ -57,7 +58,7 @@ private: deref(); return; } - ASSERT(currentThread() == m_targetThread->threadID()); + ASSERT(base::PlatformThread::CurrentId() == m_targetThread->threadID()); task->performTask(); deref(); } diff --git a/cc/CCThread.h b/cc/CCThread.h index d375932..a20d5e0 100644 --- a/cc/CCThread.h +++ b/cc/CCThread.h @@ -5,8 +5,9 @@ #ifndef CCThread_h #define CCThread_h +#include "base/threading/platform_thread.h" #include <wtf/PassOwnPtr.h> -#include <wtf/Threading.h> +#include <wtf/Noncopyable.h> namespace WebCore { @@ -33,7 +34,7 @@ public: // Executes the task after the specified delay. virtual void postDelayedTask(PassOwnPtr<Task>, long long delayMs) = 0; - virtual WTF::ThreadIdentifier threadID() const = 0; + virtual base::PlatformThreadId threadID() const = 0; }; } diff --git a/cc/test/CCSchedulerTestCommon.h b/cc/test/CCSchedulerTestCommon.h index cb78510..e7bdce7 100644 --- a/cc/test/CCSchedulerTestCommon.h +++ b/cc/test/CCSchedulerTestCommon.h @@ -8,6 +8,7 @@ #include "CCDelayBasedTimeSource.h" #include "CCFrameRateController.h" #include "CCThread.h" +#include "base/threading/platform_thread.h" #include <gtest/gtest.h> #include <wtf/OwnPtr.h> @@ -64,7 +65,7 @@ public: m_pendingTask = task; m_pendingTaskDelay = delay; } - virtual WTF::ThreadIdentifier threadID() const { return 0; } + virtual base::PlatformThreadId threadID() const { return 0; } protected: OwnPtr<Task> m_pendingTask; diff --git a/webkit/compositor_bindings/CCThreadImpl.cpp b/webkit/compositor_bindings/CCThreadImpl.cpp index 18db0ad..6a58525 100644 --- a/webkit/compositor_bindings/CCThreadImpl.cpp +++ b/webkit/compositor_bindings/CCThreadImpl.cpp @@ -22,7 +22,7 @@ namespace WebKit { // PassOwnPtrs. class GetThreadIDTask : public WebThread::Task { public: - GetThreadIDTask(ThreadIdentifier* result, CCCompletionEvent* completion) + GetThreadIDTask(base::PlatformThreadId* result, CCCompletionEvent* completion) : m_completion(completion) , m_result(result) { } @@ -30,13 +30,13 @@ public: virtual void run() { - *m_result = currentThread(); + *m_result = base::PlatformThread::CurrentId(); m_completion->signal(); } private: CCCompletionEvent* m_completion; - ThreadIdentifier* m_result; + base::PlatformThreadId* m_result; }; // General adapter from a CCThread::Task to a WebThread::Task. @@ -55,9 +55,14 @@ private: OwnPtr<CCThread::Task> m_task; }; -PassOwnPtr<CCThread> CCThreadImpl::create(WebThread* thread) +PassOwnPtr<CCThread> CCThreadImpl::createForCurrentThread() { - return adoptPtr(new CCThreadImpl(thread)); + return adoptPtr(new CCThreadImpl(Platform::current()->currentThread(), true)); +} + +PassOwnPtr<CCThread> CCThreadImpl::createForDifferentThread(WebThread* thread) +{ + return adoptPtr(new CCThreadImpl(thread, false)); } CCThreadImpl::~CCThreadImpl() @@ -74,22 +79,21 @@ void CCThreadImpl::postDelayedTask(PassOwnPtr<CCThread::Task> task, long long de m_thread->postDelayedTask(new CCThreadTaskAdapter(task), delayMs); } -ThreadIdentifier CCThreadImpl::threadID() const +base::PlatformThreadId CCThreadImpl::threadID() const { return m_threadID; } -CCThreadImpl::CCThreadImpl(WebThread* thread) +CCThreadImpl::CCThreadImpl(WebThread* thread, bool currentThread) : m_thread(thread) { - if (thread == WebKit::Platform::current()->currentThread()) { - m_threadID = currentThread(); + if (currentThread) { + m_threadID = base::PlatformThread::CurrentId(); return; } // Get the threadId for the newly-created thread by running a task // on that thread, blocking on the result. - m_threadID = currentThread(); CCCompletionEvent completion; m_thread->postTask(new GetThreadIDTask(&m_threadID, &completion)); completion.wait(); diff --git a/webkit/compositor_bindings/CCThreadImpl.h b/webkit/compositor_bindings/CCThreadImpl.h index 094d5b5..31b017e 100644 --- a/webkit/compositor_bindings/CCThreadImpl.h +++ b/webkit/compositor_bindings/CCThreadImpl.h @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "CCThread.h" +#include "base/threading/platform_thread.h" #include <wtf/OwnPtr.h> #include <wtf/Threading.h> @@ -16,17 +17,22 @@ class WebThread; // Implements CCThread in terms of WebThread. class CCThreadImpl : public WebCore::CCThread { public: - static PassOwnPtr<WebCore::CCThread> create(WebThread*); + // Creates a CCThreadImpl wrapping the current thread. + static PassOwnPtr<WebCore::CCThread> createForCurrentThread(); + + // Creates a CCThread wrapping a non-current WebThread. + static PassOwnPtr<WebCore::CCThread> createForDifferentThread(WebThread*); + virtual ~CCThreadImpl(); virtual void postTask(PassOwnPtr<WebCore::CCThread::Task>); virtual void postDelayedTask(PassOwnPtr<WebCore::CCThread::Task>, long long delayMs); - WTF::ThreadIdentifier threadID() const; + base::PlatformThreadId threadID() const; private: - explicit CCThreadImpl(WebThread*); + CCThreadImpl(WebThread*, bool currentThread); WebThread* m_thread; - WTF::ThreadIdentifier m_threadID; + base::PlatformThreadId m_threadID; }; } // namespace WebKit diff --git a/webkit/compositor_bindings/WebCompositorImpl.cpp b/webkit/compositor_bindings/WebCompositorImpl.cpp index 8fd9f45..5086837 100644 --- a/webkit/compositor_bindings/WebCompositorImpl.cpp +++ b/webkit/compositor_bindings/WebCompositorImpl.cpp @@ -13,6 +13,14 @@ #include <public/Platform.h> #include <wtf/ThreadingPrimitives.h> +#if defined(USE_LIBCC_FOR_COMPOSITOR) +#ifdef LOG +#undef LOG +#endif +#include "base/message_loop_proxy.h" +#include "webkit/glue/webthread_impl.h" +#endif + using namespace WebCore; namespace WebKit { @@ -60,10 +68,10 @@ void WebCompositorImpl::initialize(WebThread* implThread) ASSERT(!s_initialized); s_initialized = true; - s_mainThread = CCThreadImpl::create(WebKit::Platform::current()->currentThread()).leakPtr(); + s_mainThread = CCThreadImpl::createForCurrentThread().leakPtr(); CCProxy::setMainThread(s_mainThread); if (implThread) { - s_implThread = CCThreadImpl::create(implThread).leakPtr(); + s_implThread = CCThreadImpl::createForDifferentThread(implThread).leakPtr(); CCProxy::setImplThread(s_implThread); } else CCProxy::setImplThread(0); |