| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2017 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2017 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 |
| 11 #ifndef WEBRTC_P2P_BASE_FAKEPACKETTRANSPORT_H_ | 11 #ifndef WEBRTC_P2P_BASE_FAKEPACKETTRANSPORT_H_ |
| 12 #define WEBRTC_P2P_BASE_FAKEPACKETTRANSPORT_H_ | 12 #define WEBRTC_P2P_BASE_FAKEPACKETTRANSPORT_H_ |
| 13 | 13 |
| 14 #include <string> | 14 #include <string> |
| 15 | 15 |
| 16 #include "webrtc/base/asyncinvoker.h" | 16 #include "webrtc/base/asyncinvoker.h" |
| 17 #include "webrtc/base/copyonwritebuffer.h" | 17 #include "webrtc/base/copyonwritebuffer.h" |
| 18 #include "webrtc/p2p/base/packettransportinterface.h" | 18 #include "webrtc/p2p/base/packettransportinternal.h" |
| 19 | 19 |
| 20 namespace rtc { | 20 namespace rtc { |
| 21 | 21 |
| 22 // Used to simulate a packet-based transport. | 22 // Used to simulate a packet-based transport. |
| 23 class FakePacketTransport : public PacketTransportInterface { | 23 class FakePacketTransport : public PacketTransportInternal { |
| 24 public: | 24 public: |
| 25 explicit FakePacketTransport(const std::string& debug_name) | 25 explicit FakePacketTransport(const std::string& debug_name) |
| 26 : debug_name_(debug_name) {} | 26 : debug_name_(debug_name) {} |
| 27 ~FakePacketTransport() override { | 27 ~FakePacketTransport() override { |
| 28 if (dest_ && dest_->dest_ == this) { | 28 if (dest_ && dest_->dest_ == this) { |
| 29 dest_->dest_ = nullptr; | 29 dest_->dest_ = nullptr; |
| 30 } | 30 } |
| 31 } | 31 } |
| 32 | 32 |
| 33 // If async, will send packets by "Post"-ing to message queue instead of | 33 // If async, will send packets by "Post"-ing to message queue instead of |
| (...skipping 16 matching lines...) Expand all Loading... |
| 50 if (!asymmetric) { | 50 if (!asymmetric) { |
| 51 dest->SetDestination(this, true); | 51 dest->SetDestination(this, true); |
| 52 } | 52 } |
| 53 } else { | 53 } else { |
| 54 // Simulates loss of connectivity, by asymmetrically forgetting dest_. | 54 // Simulates loss of connectivity, by asymmetrically forgetting dest_. |
| 55 dest_ = nullptr; | 55 dest_ = nullptr; |
| 56 set_writable(false); | 56 set_writable(false); |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 | 59 |
| 60 // Fake PacketTransportInterface implementation. | 60 // Fake PacketTransportInternal implementation. |
| 61 std::string debug_name() const override { return debug_name_; } | 61 std::string debug_name() const override { return debug_name_; } |
| 62 bool writable() const override { return writable_; } | 62 bool writable() const override { return writable_; } |
| 63 bool receiving() const override { return receiving_; } | 63 bool receiving() const override { return receiving_; } |
| 64 int SendPacket(const char* data, | 64 int SendPacket(const char* data, |
| 65 size_t len, | 65 size_t len, |
| 66 const PacketOptions& options, | 66 const PacketOptions& options, |
| 67 int flags) override { | 67 int flags) override { |
| 68 if (!dest_) { | 68 if (!dest_) { |
| 69 return -1; | 69 return -1; |
| 70 } | 70 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 FakePacketTransport* dest_ = nullptr; | 117 FakePacketTransport* dest_ = nullptr; |
| 118 bool async_ = false; | 118 bool async_ = false; |
| 119 int async_delay_ms_ = 0; | 119 int async_delay_ms_ = 0; |
| 120 bool writable_ = false; | 120 bool writable_ = false; |
| 121 bool receiving_ = false; | 121 bool receiving_ = false; |
| 122 }; | 122 }; |
| 123 | 123 |
| 124 } // namespace rtc | 124 } // namespace rtc |
| 125 | 125 |
| 126 #endif // WEBRTC_P2P_BASE_FAKEPACKETTRANSPORT_H_ | 126 #endif // WEBRTC_P2P_BASE_FAKEPACKETTRANSPORT_H_ |
| OLD | NEW |