| OLD | NEW |
| 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 16 matching lines...) Expand all Loading... |
| 27 virtual ~MessageHandler(); | 27 virtual ~MessageHandler(); |
| 28 virtual void OnMessage(Message* msg) = 0; | 28 virtual void OnMessage(Message* msg) = 0; |
| 29 | 29 |
| 30 protected: | 30 protected: |
| 31 MessageHandler() {} | 31 MessageHandler() {} |
| 32 | 32 |
| 33 private: | 33 private: |
| 34 RTC_DISALLOW_COPY_AND_ASSIGN(MessageHandler); | 34 RTC_DISALLOW_COPY_AND_ASSIGN(MessageHandler); |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 class NoOpMessageHandler : public MessageHandler { |
| 38 public: |
| 39 void OnMessage(Message* msg) override; |
| 40 }; |
| 41 |
| 37 // Helper class to facilitate executing a functor on a thread. | 42 // Helper class to facilitate executing a functor on a thread. |
| 38 template <class ReturnT, class FunctorT> | 43 template <class ReturnT, class FunctorT> |
| 39 class FunctorMessageHandler : public MessageHandler { | 44 class FunctorMessageHandler : public MessageHandler { |
| 40 public: | 45 public: |
| 41 explicit FunctorMessageHandler(const FunctorT& functor) | 46 explicit FunctorMessageHandler(const FunctorT& functor) |
| 42 : functor_(functor) {} | 47 : functor_(functor) {} |
| 43 virtual void OnMessage(Message* msg) { | 48 virtual void OnMessage(Message* msg) { |
| 44 result_ = functor_(); | 49 result_ = functor_(); |
| 45 } | 50 } |
| 46 const ReturnT& result() const { return result_; } | 51 const ReturnT& result() const { return result_; } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 75 } | 80 } |
| 76 void result() const {} | 81 void result() const {} |
| 77 | 82 |
| 78 private: | 83 private: |
| 79 FunctorT functor_; | 84 FunctorT functor_; |
| 80 }; | 85 }; |
| 81 | 86 |
| 82 } // namespace rtc | 87 } // namespace rtc |
| 83 | 88 |
| 84 #endif // WEBRTC_BASE_MESSAGEHANDLER_H_ | 89 #endif // WEBRTC_BASE_MESSAGEHANDLER_H_ |
| OLD | NEW |