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 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 SendPacketInternal(packet); | 79 SendPacketInternal(packet); |
80 } | 80 } |
81 SentPacket sent_packet(options.packet_id, TimeMillis()); | 81 SentPacket sent_packet(options.packet_id, TimeMillis()); |
82 SignalSentPacket(this, sent_packet); | 82 SignalSentPacket(this, sent_packet); |
83 return static_cast<int>(len); | 83 return static_cast<int>(len); |
84 } | 84 } |
85 int SetOption(Socket::Option opt, int value) override { return true; } | 85 int SetOption(Socket::Option opt, int value) override { return true; } |
86 bool GetOption(Socket::Option opt, int* value) override { return true; } | 86 bool GetOption(Socket::Option opt, int* value) override { return true; } |
87 int GetError() override { return 0; } | 87 int GetError() override { return 0; } |
88 | 88 |
89 void set_last_received_packet(rtc::CopyOnWriteBuffer* packet) { | |
90 last_received_packet_ = *packet; | |
91 } | |
Taylor Brandstetter
2017/08/23 22:13:29
Can this be private and called internally? Instead
Zhi Huang
2017/08/24 23:38:07
We can just store the last sent packet before trig
| |
92 | |
93 const CopyOnWriteBuffer* last_received_packet() { | |
94 return &last_received_packet_; | |
95 } | |
96 | |
89 private: | 97 private: |
90 void set_writable(bool writable) { | 98 void set_writable(bool writable) { |
91 if (writable_ == writable) { | 99 if (writable_ == writable) { |
92 return; | 100 return; |
93 } | 101 } |
94 writable_ = writable; | 102 writable_ = writable; |
95 if (writable_) { | 103 if (writable_) { |
96 SignalReadyToSend(this); | 104 SignalReadyToSend(this); |
97 } | 105 } |
98 SignalWritableState(this); | 106 SignalWritableState(this); |
99 } | 107 } |
100 | 108 |
101 void set_receiving(bool receiving) { | 109 void set_receiving(bool receiving) { |
102 if (receiving_ == receiving) { | 110 if (receiving_ == receiving) { |
103 return; | 111 return; |
104 } | 112 } |
105 receiving_ = receiving; | 113 receiving_ = receiving; |
106 SignalReceivingState(this); | 114 SignalReceivingState(this); |
107 } | 115 } |
108 | 116 |
109 void SendPacketInternal(const CopyOnWriteBuffer& packet) { | 117 void SendPacketInternal(const CopyOnWriteBuffer& packet) { |
110 if (dest_) { | 118 if (dest_) { |
111 dest_->SignalReadPacket(dest_, packet.data<char>(), packet.size(), | 119 dest_->SignalReadPacket(dest_, packet.data<char>(), packet.size(), |
112 CreatePacketTime(0), 0); | 120 CreatePacketTime(0), 0); |
113 } | 121 } |
114 } | 122 } |
115 | 123 |
124 CopyOnWriteBuffer last_received_packet_; | |
116 AsyncInvoker invoker_; | 125 AsyncInvoker invoker_; |
117 std::string debug_name_; | 126 std::string debug_name_; |
118 FakePacketTransport* dest_ = nullptr; | 127 FakePacketTransport* dest_ = nullptr; |
119 bool async_ = false; | 128 bool async_ = false; |
120 int async_delay_ms_ = 0; | 129 int async_delay_ms_ = 0; |
121 bool writable_ = false; | 130 bool writable_ = false; |
122 bool receiving_ = false; | 131 bool receiving_ = false; |
123 }; | 132 }; |
124 | 133 |
125 } // namespace rtc | 134 } // namespace rtc |
126 | 135 |
127 #endif // WEBRTC_P2P_BASE_FAKEPACKETTRANSPORT_H_ | 136 #endif // WEBRTC_P2P_BASE_FAKEPACKETTRANSPORT_H_ |
OLD | NEW |