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

Unified Diff: webrtc/base/messagehandler.h

Issue 1920043002: Replace scoped_ptr with unique_ptr in webrtc/base/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixes for compile errors. Created 4 years, 8 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
Index: webrtc/base/messagehandler.h
diff --git a/webrtc/base/messagehandler.h b/webrtc/base/messagehandler.h
index b55b229a6db4792dca32ca95c0adaff508c7110d..787aee74c08b3c33672f516c63d864635c4e59cf 100644
--- a/webrtc/base/messagehandler.h
+++ b/webrtc/base/messagehandler.h
@@ -11,6 +11,7 @@
#ifndef WEBRTC_BASE_MESSAGEHANDLER_H_
#define WEBRTC_BASE_MESSAGEHANDLER_H_
+#include <memory>
#include <utility>
#include "webrtc/base/constructormagic.h"
@@ -64,6 +65,20 @@ class FunctorMessageHandler<class rtc::scoped_ptr<ReturnT>, FunctorT>
rtc::scoped_ptr<ReturnT> result_;
};
+// Specialization for std::unique_ptr<ReturnT>.
+template <class ReturnT, class FunctorT>
+class FunctorMessageHandler<class std::unique_ptr<ReturnT>, FunctorT>
+ : public MessageHandler {
+ public:
+ explicit FunctorMessageHandler(const FunctorT& functor) : functor_(functor) {}
+ virtual void OnMessage(Message* msg) { result_ = std::move(functor_()); }
+ std::unique_ptr<ReturnT> result() { return std::move(result_); }
+
+ private:
+ FunctorT functor_;
+ std::unique_ptr<ReturnT> result_;
+};
+
// Specialization for ReturnT of void.
template <class FunctorT>
class FunctorMessageHandler<void, FunctorT> : public MessageHandler {

Powered by Google App Engine
This is Rietveld 408576698