Index: webrtc/api/proxy.h |
diff --git a/webrtc/api/proxy.h b/webrtc/api/proxy.h |
index 1351a0427e6b4077f034bbc593b5626d9b16bb33..769c2181b65a4b85ce5ad0d06cea3ba21b093f13 100644 |
--- a/webrtc/api/proxy.h |
+++ b/webrtc/api/proxy.h |
@@ -299,65 +299,100 @@ class MethodCall5 : public rtc::Message, |
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( \ |
perkj_webrtc
2016/04/05 12:36:55
nit: formatting of line length.
nisse-webrtc
2016/04/05 12:43:34
Not sure exactly what you're suggesting, but I cha
|
+ 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 +400,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_ |