| Index: webrtc/api/proxy.h
|
| diff --git a/webrtc/api/proxy.h b/webrtc/api/proxy.h
|
| index 1351a0427e6b4077f034bbc593b5626d9b16bb33..b5a8071bcfbbcdddf21e459a22802c7a88498e8c 100644
|
| --- a/webrtc/api/proxy.h
|
| +++ b/webrtc/api/proxy.h
|
| @@ -295,69 +295,106 @@ class MethodCall5 : public rtc::Message,
|
| T5 a5_;
|
| };
|
|
|
| +// TODO(nisse): Rename this to {BEGIN|END}_SIGNALLING_PROXY_MAP, and
|
| +// the below to {BEGIN|END}_PROXY_MAP. Also rename the class to
|
| +// c##SignallingProxy.
|
| #define BEGIN_PROXY_MAP(c) \
|
| class c##Proxy : public c##Interface { \
|
| protected: \
|
| typedef c##Interface C; \
|
| - c##Proxy(rtc::Thread* thread, C* c) : owner_thread_(thread), c_(c) {} \
|
| + c##Proxy(rtc::Thread* signaling_thread, C* c) \
|
| + : signaling_thread_(signaling_thread), c_(c) {} \
|
| ~c##Proxy() { \
|
| MethodCall0<c##Proxy, void> call(this, &c##Proxy::Release_s); \
|
| - call.Marshal(owner_thread_); \
|
| + call.Marshal(signaling_thread_); \
|
| } \
|
| \
|
| public: \
|
| - static rtc::scoped_refptr<C> Create(rtc::Thread* thread, C* c) { \
|
| - return new rtc::RefCountedObject<c##Proxy>(thread, c); \
|
| + static rtc::scoped_refptr<C> Create(rtc::Thread* signaling_thread, C* c) { \
|
| + return new rtc::RefCountedObject<c##Proxy>(signaling_thread, c); \
|
| + }
|
| +
|
| +#define BEGIN_WORKER_PROXY_MAP(c) \
|
| + class c##Proxy : public c##Interface { \
|
| + protected: \
|
| + typedef c##Interface C; \
|
| + c##Proxy(rtc::Thread* signaling_thread, rtc::Thread* worker_thread, C* c) \
|
| + : signaling_thread_(signaling_thread), \
|
| + worker_thread_(worker_thread), \
|
| + c_(c) {} \
|
| + ~c##Proxy() { \
|
| + MethodCall0<c##Proxy, void> call(this, &c##Proxy::Release_s); \
|
| + call.Marshal(signaling_thread_); \
|
| + } \
|
| + \
|
| + public: \
|
| + static rtc::scoped_refptr<C> Create( \
|
| + rtc::Thread* signaling_thread, rtc::Thread* worker_thread, C* c) { \
|
| + return new rtc::RefCountedObject<c##Proxy>( \
|
| + signaling_thread, worker_thread, c); \
|
| }
|
|
|
| #define PROXY_METHOD0(r, method) \
|
| r method() override { \
|
| MethodCall0<C, r> call(c_.get(), &C::method); \
|
| - return call.Marshal(owner_thread_); \
|
| + return call.Marshal(signaling_thread_); \
|
| }
|
|
|
| #define PROXY_CONSTMETHOD0(r, method) \
|
| r method() const override { \
|
| ConstMethodCall0<C, r> call(c_.get(), &C::method); \
|
| - return call.Marshal(owner_thread_); \
|
| + return call.Marshal(signaling_thread_); \
|
| }
|
|
|
| #define PROXY_METHOD1(r, method, t1) \
|
| r method(t1 a1) override { \
|
| MethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \
|
| - return call.Marshal(owner_thread_); \
|
| + return call.Marshal(signaling_thread_); \
|
| }
|
|
|
| #define PROXY_CONSTMETHOD1(r, method, t1) \
|
| r method(t1 a1) const override { \
|
| ConstMethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \
|
| - return call.Marshal(owner_thread_); \
|
| + return call.Marshal(signaling_thread_); \
|
| }
|
|
|
| #define PROXY_METHOD2(r, method, t1, t2) \
|
| r method(t1 a1, t2 a2) override { \
|
| MethodCall2<C, r, t1, t2> call(c_.get(), &C::method, a1, a2); \
|
| - return call.Marshal(owner_thread_); \
|
| + return call.Marshal(signaling_thread_); \
|
| }
|
|
|
| #define PROXY_METHOD3(r, method, t1, t2, t3) \
|
| r method(t1 a1, t2 a2, t3 a3) override { \
|
| MethodCall3<C, r, t1, t2, t3> call(c_.get(), &C::method, a1, a2, a3); \
|
| - return call.Marshal(owner_thread_); \
|
| + return call.Marshal(signaling_thread_); \
|
| }
|
|
|
| #define PROXY_METHOD4(r, method, t1, t2, t3, t4) \
|
| r method(t1 a1, t2 a2, t3 a3, t4 a4) override { \
|
| MethodCall4<C, r, t1, t2, t3, t4> call(c_.get(), &C::method, a1, a2, a3, \
|
| a4); \
|
| - return call.Marshal(owner_thread_); \
|
| + return call.Marshal(signaling_thread_); \
|
| }
|
|
|
| #define PROXY_METHOD5(r, method, t1, t2, t3, t4, t5) \
|
| r method(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) override { \
|
| MethodCall5<C, r, t1, t2, t3, t4, t5> call(c_.get(), &C::method, a1, a2, \
|
| a3, a4, a5); \
|
| - return call.Marshal(owner_thread_); \
|
| + return call.Marshal(signaling_thread_); \
|
| + }
|
| +
|
| +// Define methods which should be invoked on the worker thread.
|
| +#define PROXY_WORKER_METHOD1(r, method, t1) \
|
| + r method(t1 a1) override { \
|
| + MethodCall1<C, r, t1> call(c_.get(), &C::method, a1); \
|
| + return call.Marshal(worker_thread_); \
|
| + }
|
| +
|
| +#define PROXY_WORKER_METHOD2(r, method, t1, t2) \
|
| + r method(t1 a1, t2 a2) override { \
|
| + MethodCall2<C, r, t1, t2> call(c_.get(), &C::method, a1, a2); \
|
| + return call.Marshal(worker_thread_); \
|
| }
|
|
|
| #define END_PROXY() \
|
| @@ -365,10 +402,20 @@ class MethodCall5 : public rtc::Message,
|
| void Release_s() {\
|
| c_ = NULL;\
|
| }\
|
| - mutable rtc::Thread* owner_thread_;\
|
| + mutable rtc::Thread* signaling_thread_;\
|
| rtc::scoped_refptr<C> c_;\
|
| };\
|
|
|
| +#define END_WORKER_PROXY() \
|
| + private: \
|
| + void Release_s() { \
|
| + c_ = NULL; \
|
| + } \
|
| + mutable rtc::Thread* signaling_thread_; \
|
| + mutable rtc::Thread* worker_thread_; \
|
| + rtc::scoped_refptr<C> c_; \
|
| + }; \
|
| +
|
| } // namespace webrtc
|
|
|
| #endif // WEBRTC_API_PROXY_H_
|
|
|