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

Unified Diff: webrtc/base/messagehandler.h

Issue 1226153003: Improvements to rtc::Bind (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 5 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/base/bind.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/messagehandler.h
diff --git a/webrtc/base/messagehandler.h b/webrtc/base/messagehandler.h
index 123c8509736794a978f3b644f37ca0bfe4db2cbd..b0a82179a2310766914bee8c53d9ac4628769d40 100644
--- a/webrtc/base/messagehandler.h
+++ b/webrtc/base/messagehandler.h
@@ -12,6 +12,7 @@
#define WEBRTC_BASE_MESSAGEHANDLER_H_
#include "webrtc/base/constructormagic.h"
+#include "webrtc/base/scoped_ptr.h"
namespace rtc {
@@ -47,6 +48,20 @@ class FunctorMessageHandler : public MessageHandler {
ReturnT result_;
};
+// Specialization for rtc::scoped_ptr<ReturnT>.
+template <class ReturnT, class FunctorT>
+class FunctorMessageHandler<class rtc::scoped_ptr<ReturnT>, FunctorT>
+ : public MessageHandler {
+ public:
+ explicit FunctorMessageHandler(const FunctorT& functor) : functor_(functor) {}
+ virtual void OnMessage(Message* msg) { result_ = functor_().Pass(); }
+ rtc::scoped_ptr<ReturnT> result() { return result_.Pass(); }
+
+ private:
+ FunctorT functor_;
+ rtc::scoped_ptr<ReturnT> result_;
+};
+
// Specialization for ReturnT of void.
template <class FunctorT>
class FunctorMessageHandler<void, FunctorT> : public MessageHandler {
@@ -62,7 +77,6 @@ class FunctorMessageHandler<void, FunctorT> : public MessageHandler {
FunctorT functor_;
};
-
} // namespace rtc
#endif // WEBRTC_BASE_MESSAGEHANDLER_H_
« no previous file with comments | « webrtc/base/bind.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698