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

Side by Side Diff: webrtc/base/messagehandler.h

Issue 1797463002: Make rtc::scoped_ptr a type alias for std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/base/scoped_ptr.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 virtual void OnMessage(Message* msg) { 43 virtual void OnMessage(Message* msg) {
44 result_ = functor_(); 44 result_ = functor_();
45 } 45 }
46 const ReturnT& result() const { return result_; } 46 const ReturnT& result() const { return result_; }
47 47
48 private: 48 private:
49 FunctorT functor_; 49 FunctorT functor_;
50 ReturnT result_; 50 ReturnT result_;
51 }; 51 };
52 52
53 // Specialization for rtc::scoped_ptr<ReturnT>. 53 // Specialization for std::unique_ptr<ReturnT>.
54 template <class ReturnT, class FunctorT> 54 template <class ReturnT, class FunctorT>
55 class FunctorMessageHandler<class rtc::scoped_ptr<ReturnT>, FunctorT> 55 class FunctorMessageHandler<class std::unique_ptr<ReturnT>, FunctorT>
56 : public MessageHandler { 56 : public MessageHandler {
57 public: 57 public:
58 explicit FunctorMessageHandler(const FunctorT& functor) : functor_(functor) {} 58 explicit FunctorMessageHandler(const FunctorT& functor) : functor_(functor) {}
59 virtual void OnMessage(Message* msg) { result_ = std::move(functor_()); } 59 virtual void OnMessage(Message* msg) { result_ = std::move(functor_()); }
60 rtc::scoped_ptr<ReturnT> result() { return std::move(result_); } 60 std::unique_ptr<ReturnT> result() { return std::move(result_); }
61 61
62 private: 62 private:
63 FunctorT functor_; 63 FunctorT functor_;
64 rtc::scoped_ptr<ReturnT> result_; 64 std::unique_ptr<ReturnT> result_;
65 }; 65 };
66 66
67 // Specialization for ReturnT of void. 67 // Specialization for ReturnT of void.
68 template <class FunctorT> 68 template <class FunctorT>
69 class FunctorMessageHandler<void, FunctorT> : public MessageHandler { 69 class FunctorMessageHandler<void, FunctorT> : public MessageHandler {
70 public: 70 public:
71 explicit FunctorMessageHandler(const FunctorT& functor) 71 explicit FunctorMessageHandler(const FunctorT& functor)
72 : functor_(functor) {} 72 : functor_(functor) {}
73 virtual void OnMessage(Message* msg) { 73 virtual void OnMessage(Message* msg) {
74 functor_(); 74 functor_();
75 } 75 }
76 void result() const {} 76 void result() const {}
77 77
78 private: 78 private:
79 FunctorT functor_; 79 FunctorT functor_;
80 }; 80 };
81 81
82 } // namespace rtc 82 } // namespace rtc
83 83
84 #endif // WEBRTC_BASE_MESSAGEHANDLER_H_ 84 #endif // WEBRTC_BASE_MESSAGEHANDLER_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/base/scoped_ptr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698