summaryrefslogtreecommitdiffstats
path: root/webkit/compositor_bindings
diff options
context:
space:
mode:
authorjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-10 22:04:21 +0000
committerjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-10 22:04:21 +0000
commitdedbe4068e61e476f7dc42f0921dba360329b3e8 (patch)
tree59f333e3ba8a54f324caae5d236e1bb679cc6ee1 /webkit/compositor_bindings
parentefa810b842c84c52825e6446ba2608ffa4e2450a (diff)
downloadchromium_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
Diffstat (limited to 'webkit/compositor_bindings')
-rw-r--r--webkit/compositor_bindings/CCThreadImpl.cpp24
-rw-r--r--webkit/compositor_bindings/CCThreadImpl.h14
-rw-r--r--webkit/compositor_bindings/WebCompositorImpl.cpp12
3 files changed, 34 insertions, 16 deletions
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);