Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Unified Diff: webrtc/api/proxy.h

Issue 2675173003: Adding "adapter" ORTC objects on top of ChannelManager/BaseChannel/etc. (Closed)
Patch Set: Add memcheck suppression for end-to-end tests. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/api/peerconnectioninterface.h ('k') | webrtc/api/rtcerror.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/proxy.h
diff --git a/webrtc/api/proxy.h b/webrtc/api/proxy.h
index 5634cfe9f843befd502c8509180c9788f497561c..46c424d927ffb868d4a67f9c0b0a0eca40019127 100644
--- a/webrtc/api/proxy.h
+++ b/webrtc/api/proxy.h
@@ -353,18 +353,18 @@ class MethodCall5 : public rtc::Message,
// Helper macros to reduce code duplication.
-#define PROXY_MAP_BOILERPLATE(c) \
- template <class INTERNAL_CLASS> \
- class c##ProxyWithInternal; \
- typedef c##ProxyWithInternal<c##Interface> c##Proxy; \
- template <class INTERNAL_CLASS> \
- class c##ProxyWithInternal : public c##Interface { \
- protected: \
- typedef c##Interface C; \
- \
- public: \
- const INTERNAL_CLASS* internal() const { return c_.get(); } \
- INTERNAL_CLASS* internal() { return c_.get(); }
+#define PROXY_MAP_BOILERPLATE(c) \
+ template <class INTERNAL_CLASS> \
+ class c##ProxyWithInternal; \
+ typedef c##ProxyWithInternal<c##Interface> c##Proxy; \
+ template <class INTERNAL_CLASS> \
+ class c##ProxyWithInternal : public c##Interface { \
+ protected: \
+ typedef c##Interface C; \
+ \
+ public: \
+ const INTERNAL_CLASS* internal() const { return c_; } \
+ INTERNAL_CLASS* internal() { return c_; }
#define END_PROXY_MAP() \
};
@@ -403,6 +403,11 @@ class MethodCall5 : public rtc::Message,
void DestroyInternal() { c_ = nullptr; } \
rtc::scoped_refptr<INTERNAL_CLASS> c_;
+// Note: This doesn't use a unique_ptr, because it intends to handle a corner
+// case where an object's deletion triggers a callback that calls back into
+// this proxy object. If relying on a unique_ptr to delete the object, its
+// inner pointer would be set to null before this reentrant callback would have
+// a chance to run, resulting in a segfault.
#define OWNED_PROXY_MAP_BOILERPLATE(c) \
public: \
~c##ProxyWithInternal() { \
@@ -412,8 +417,8 @@ class MethodCall5 : public rtc::Message,
} \
\
private: \
- void DestroyInternal() { c_.reset(nullptr); } \
- std::unique_ptr<INTERNAL_CLASS> c_;
+ void DestroyInternal() { delete c_; } \
+ INTERNAL_CLASS* c_;
#define BEGIN_SIGNALING_PROXY_MAP(c) \
PROXY_MAP_BOILERPLATE(c) \
@@ -438,16 +443,16 @@ class MethodCall5 : public rtc::Message,
worker_thread, c); \
}
-#define BEGIN_OWNED_PROXY_MAP(c) \
- PROXY_MAP_BOILERPLATE(c) \
- WORKER_PROXY_MAP_BOILERPLATE(c) \
- OWNED_PROXY_MAP_BOILERPLATE(c) \
- public: \
- static std::unique_ptr<c##ProxyWithInternal> Create( \
- rtc::Thread* signaling_thread, rtc::Thread* worker_thread, \
- INTERNAL_CLASS* c) { \
- return std::unique_ptr<c##ProxyWithInternal>( \
- new c##ProxyWithInternal(signaling_thread, worker_thread, c)); \
+#define BEGIN_OWNED_PROXY_MAP(c) \
+ PROXY_MAP_BOILERPLATE(c) \
+ WORKER_PROXY_MAP_BOILERPLATE(c) \
+ OWNED_PROXY_MAP_BOILERPLATE(c) \
+ public: \
+ static std::unique_ptr<c##Interface> Create( \
+ rtc::Thread* signaling_thread, rtc::Thread* worker_thread, \
+ std::unique_ptr<INTERNAL_CLASS> c) { \
+ return std::unique_ptr<c##Interface>(new c##ProxyWithInternal( \
+ signaling_thread, worker_thread, c.release())); \
}
#define PROXY_SIGNALING_THREAD_DESTRUCTOR() \
@@ -464,95 +469,109 @@ class MethodCall5 : public rtc::Message,
#define PROXY_METHOD0(r, method) \
r method() override { \
- MethodCall0<C, r> call(c_.get(), &C::method); \
+ MethodCall0<C, r> call(c_, &C::method); \
return call.Marshal(RTC_FROM_HERE, signaling_thread_); \
}
#define PROXY_CONSTMETHOD0(r, method) \
r method() const override { \
- ConstMethodCall0<C, r> call(c_.get(), &C::method); \
+ ConstMethodCall0<C, r> call(c_, &C::method); \
return call.Marshal(RTC_FROM_HERE, signaling_thread_); \
}
-#define PROXY_METHOD1(r, method, t1) \
- r method(t1 a1) override { \
- MethodCall1<C, r, t1> call(c_.get(), &C::method, std::move(a1)); \
- return call.Marshal(RTC_FROM_HERE, signaling_thread_); \
+#define PROXY_METHOD1(r, method, t1) \
+ r method(t1 a1) override { \
+ MethodCall1<C, r, t1> call(c_, &C::method, std::move(a1)); \
+ return call.Marshal(RTC_FROM_HERE, signaling_thread_); \
}
-#define PROXY_CONSTMETHOD1(r, method, t1) \
- r method(t1 a1) const override { \
- ConstMethodCall1<C, r, t1> call(c_.get(), &C::method, std::move(a1)); \
- return call.Marshal(RTC_FROM_HERE, signaling_thread_); \
+#define PROXY_CONSTMETHOD1(r, method, t1) \
+ r method(t1 a1) const override { \
+ ConstMethodCall1<C, r, t1> call(c_, &C::method, std::move(a1)); \
+ return call.Marshal(RTC_FROM_HERE, 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, std::move(a1), \
- std::move(a2)); \
- return call.Marshal(RTC_FROM_HERE, signaling_thread_); \
+#define PROXY_METHOD2(r, method, t1, t2) \
+ r method(t1 a1, t2 a2) override { \
+ MethodCall2<C, r, t1, t2> call(c_, &C::method, std::move(a1), \
+ std::move(a2)); \
+ return call.Marshal(RTC_FROM_HERE, 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, std::move(a1), \
- std::move(a2), std::move(a3)); \
- return call.Marshal(RTC_FROM_HERE, 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_, &C::method, std::move(a1), \
+ std::move(a2), std::move(a3)); \
+ return call.Marshal(RTC_FROM_HERE, 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, \
- std::move(a1), std::move(a2), \
- std::move(a3), std::move(a4)); \
+ MethodCall4<C, r, t1, t2, t3, t4> call(c_, &C::method, std::move(a1), \
+ std::move(a2), std::move(a3), \
+ std::move(a4)); \
return call.Marshal(RTC_FROM_HERE, 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, std::move(a1), std::move(a2), std::move(a3), \
- std::move(a4), std::move(a5)); \
- return call.Marshal(RTC_FROM_HERE, 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_, &C::method, std::move(a1), \
+ std::move(a2), std::move(a3), \
+ std::move(a4), std::move(a5)); \
+ return call.Marshal(RTC_FROM_HERE, signaling_thread_); \
}
// Define methods which should be invoked on the worker thread.
#define PROXY_WORKER_METHOD0(r, method) \
r method() override { \
- MethodCall0<C, r> call(c_.get(), &C::method); \
+ MethodCall0<C, r> call(c_, &C::method); \
return call.Marshal(RTC_FROM_HERE, worker_thread_); \
}
#define PROXY_WORKER_CONSTMETHOD0(r, method) \
r method() const override { \
- ConstMethodCall0<C, r> call(c_.get(), &C::method); \
+ ConstMethodCall0<C, r> call(c_, &C::method); \
return call.Marshal(RTC_FROM_HERE, worker_thread_); \
}
-#define PROXY_WORKER_METHOD1(r, method, t1) \
- r method(t1 a1) override { \
- MethodCall1<C, r, t1> call(c_.get(), &C::method, std::move(a1)); \
- return call.Marshal(RTC_FROM_HERE, worker_thread_); \
+#define PROXY_WORKER_METHOD1(r, method, t1) \
+ r method(t1 a1) override { \
+ MethodCall1<C, r, t1> call(c_, &C::method, std::move(a1)); \
+ return call.Marshal(RTC_FROM_HERE, worker_thread_); \
+ }
+
+#define PROXY_WORKER_CONSTMETHOD1(r, method, t1) \
+ r method(t1 a1) const override { \
+ ConstMethodCall1<C, r, t1> call(c_, &C::method, std::move(a1)); \
+ return call.Marshal(RTC_FROM_HERE, worker_thread_); \
+ }
+
+#define PROXY_WORKER_METHOD2(r, method, t1, t2) \
+ r method(t1 a1, t2 a2) override { \
+ MethodCall2<C, r, t1, t2> call(c_, &C::method, std::move(a1), \
+ std::move(a2)); \
+ return call.Marshal(RTC_FROM_HERE, worker_thread_); \
}
-#define PROXY_WORKER_CONSTMETHOD1(r, method, t1) \
- r method(t1 a1) const override { \
- ConstMethodCall1<C, r, t1> call(c_.get(), &C::method, std::move(a1)); \
- return call.Marshal(RTC_FROM_HERE, worker_thread_); \
+#define PROXY_WORKER_CONSTMETHOD2(r, method, t1, t2) \
+ r method(t1 a1, t2 a2) const override { \
+ ConstMethodCall2<C, r, t1, t2> call(c_, &C::method, std::move(a1), \
+ std::move(a2)); \
+ return call.Marshal(RTC_FROM_HERE, 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, std::move(a1), \
- std::move(a2)); \
- return call.Marshal(RTC_FROM_HERE, worker_thread_); \
+#define PROXY_WORKER_METHOD3(r, method, t1, t2, t3) \
+ r method(t1 a1, t2 a2, t3 a3) override { \
+ MethodCall3<C, r, t1, t2, t3> call(c_, &C::method, std::move(a1), \
+ std::move(a2), std::move(a3)); \
+ return call.Marshal(RTC_FROM_HERE, worker_thread_); \
}
-#define PROXY_WORKER_CONSTMETHOD2(r, method, t1, t2) \
- r method(t1 a1, t2 a2) const override { \
- ConstMethodCall2<C, r, t1, t2> call(c_.get(), &C::method, std::move(a1), \
- std::move(a2)); \
- return call.Marshal(RTC_FROM_HERE, worker_thread_); \
+#define PROXY_WORKER_CONSTMETHOD3(r, method, t1, t2) \
+ r method(t1 a1, t2 a2, t3 a3) const override { \
+ ConstMethodCall3<C, r, t1, t2, t3> call(c_, &C::method, std::move(a1), \
+ std::move(a2), std::move(a3)); \
+ return call.Marshal(RTC_FROM_HERE, worker_thread_); \
}
} // namespace webrtc
« no previous file with comments | « webrtc/api/peerconnectioninterface.h ('k') | webrtc/api/rtcerror.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698