| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2012 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 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 class SigslotDefault : public testing::Test, public sigslot::has_slots<> { | 26 class SigslotDefault : public testing::Test, public sigslot::has_slots<> { |
| 27 protected: | 27 protected: |
| 28 sigslot::signal0<> signal_; | 28 sigslot::signal0<> signal_; |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 template<class slot_policy = sigslot::single_threaded, | 31 template<class slot_policy = sigslot::single_threaded, |
| 32 class signal_policy = sigslot::single_threaded> | 32 class signal_policy = sigslot::single_threaded> |
| 33 class SigslotReceiver : public sigslot::has_slots<slot_policy> { | 33 class SigslotReceiver : public sigslot::has_slots<slot_policy> { |
| 34 public: | 34 public: |
| 35 SigslotReceiver() : signal_(NULL), signal_count_(0) { | 35 SigslotReceiver() : signal_(nullptr), signal_count_(0) {} |
| 36 } | |
| 37 ~SigslotReceiver() { | 36 ~SigslotReceiver() { |
| 38 } | 37 } |
| 39 | 38 |
| 40 void Connect(sigslot::signal0<signal_policy>* signal) { | 39 void Connect(sigslot::signal0<signal_policy>* signal) { |
| 41 if (!signal) return; | 40 if (!signal) return; |
| 42 Disconnect(); | 41 Disconnect(); |
| 43 signal_ = signal; | 42 signal_ = signal; |
| 44 signal->connect(this, | 43 signal->connect(this, |
| 45 &SigslotReceiver<slot_policy, signal_policy>::OnSignal); | 44 &SigslotReceiver<slot_policy, signal_policy>::OnSignal); |
| 46 } | 45 } |
| 47 void Disconnect() { | 46 void Disconnect() { |
| 48 if (!signal_) return; | 47 if (!signal_) return; |
| 49 signal_->disconnect(this); | 48 signal_->disconnect(this); |
| 50 signal_ = NULL; | 49 signal_ = nullptr; |
| 51 } | 50 } |
| 52 void OnSignal() { | 51 void OnSignal() { |
| 53 ++signal_count_; | 52 ++signal_count_; |
| 54 } | 53 } |
| 55 int signal_count() { return signal_count_; } | 54 int signal_count() { return signal_count_; } |
| 56 | 55 |
| 57 private: | 56 private: |
| 58 sigslot::signal0<signal_policy>* signal_; | 57 sigslot::signal0<signal_policy>* signal_; |
| 59 int signal_count_; | 58 int signal_count_; |
| 60 }; | 59 }; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 sigslot::signal0<>* signal = new sigslot::signal0<>; | 236 sigslot::signal0<>* signal = new sigslot::signal0<>; |
| 238 SigslotReceiver<>* receiver = new SigslotReceiver<>(); | 237 SigslotReceiver<>* receiver = new SigslotReceiver<>(); |
| 239 receiver->Connect(signal); | 238 receiver->Connect(signal); |
| 240 (*signal)(); | 239 (*signal)(); |
| 241 EXPECT_EQ(1, receiver->signal_count()); | 240 EXPECT_EQ(1, receiver->signal_count()); |
| 242 | 241 |
| 243 delete receiver; | 242 delete receiver; |
| 244 (*signal)(); | 243 (*signal)(); |
| 245 delete signal; | 244 delete signal; |
| 246 } | 245 } |
| OLD | NEW |