PeerConnection(Java): auto-WrapCurrentThread() when creating PeerConnectionFactory.

Various pieces of talk/ assume that the current Thread is ThreadManager'd
without checking this, so unconditionally wrap the caller's thread in case it
was created by Java code unbeknownst to ThreadManager.

BUG=2947
R=wu@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/9419004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6154 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
fischman@webrtc.org 2014-05-14 17:33:32 +00:00
parent a70dff4427
commit 2c98af7935

View File

@ -1928,6 +1928,12 @@ class OwnedFactoryAndThreads {
JOW(jlong, PeerConnectionFactory_nativeCreatePeerConnectionFactory)(
JNIEnv* jni, jclass) {
// talk/ assumes pretty widely that the current Thread is ThreadManager'd, but
// ThreadManager only WrapCurrentThread()s the thread where it is first
// created. Since the semantics around when auto-wrapping happens in
// talk/base/ are convoluted, we simply wrap here to avoid having to think
// about ramifications of auto-wrapping there.
talk_base::ThreadManager::Instance()->WrapCurrentThread();
webrtc::Trace::CreateTrace();
Thread* worker_thread = new Thread();
worker_thread->SetName("worker_thread", NULL);