OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2016 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 std::map<int, rtc::scoped_refptr<QuicDataChannel>> data_channel_by_id_; | 160 std::map<int, rtc::scoped_refptr<QuicDataChannel>> data_channel_by_id_; |
161 // Last incoming QUIC stream which has arrived. | 161 // Last incoming QUIC stream which has arrived. |
162 cricket::ReliableQuicStream* incoming_stream_ = nullptr; | 162 cricket::ReliableQuicStream* incoming_stream_ = nullptr; |
163 }; | 163 }; |
164 | 164 |
165 // A peer who creates a QuicDataChannel to transfer data, and simulates network | 165 // A peer who creates a QuicDataChannel to transfer data, and simulates network |
166 // connectivity with a fake ICE channel wrapped by the QUIC transport channel. | 166 // connectivity with a fake ICE channel wrapped by the QUIC transport channel. |
167 class QuicDataChannelPeer { | 167 class QuicDataChannelPeer { |
168 public: | 168 public: |
169 QuicDataChannelPeer() | 169 QuicDataChannelPeer() |
170 : ice_transport_channel_("data", 0), | 170 : ice_transport_channel_(new FakeTransportChannel("data", 0)), |
171 quic_transport_channel_(&ice_transport_channel_) { | 171 quic_transport_channel_(ice_transport_channel_) { |
172 ice_transport_channel_.SetAsync(true); | 172 ice_transport_channel_->SetAsync(true); |
173 fake_quic_data_transport_.ConnectToTransportChannel( | 173 fake_quic_data_transport_.ConnectToTransportChannel( |
174 &quic_transport_channel_); | 174 &quic_transport_channel_); |
175 } | 175 } |
176 | 176 |
177 void GenerateCertificateAndFingerprint() { | 177 void GenerateCertificateAndFingerprint() { |
178 rtc::scoped_refptr<rtc::RTCCertificate> local_cert = | 178 rtc::scoped_refptr<rtc::RTCCertificate> local_cert = |
179 rtc::RTCCertificate::Create(rtc::scoped_ptr<rtc::SSLIdentity>( | 179 rtc::RTCCertificate::Create(rtc::scoped_ptr<rtc::SSLIdentity>( |
180 rtc::SSLIdentity::Generate("cert_name", rtc::KT_DEFAULT))); | 180 rtc::SSLIdentity::Generate("cert_name", rtc::KT_DEFAULT))); |
181 quic_transport_channel_.SetLocalCertificate(local_cert); | 181 quic_transport_channel_.SetLocalCertificate(local_cert); |
182 local_fingerprint_.reset(CreateFingerprint(local_cert.get())); | 182 local_fingerprint_.reset(CreateFingerprint(local_cert.get())); |
(...skipping 11 matching lines...) Expand all Loading... |
194 | 194 |
195 rtc::scoped_refptr<QuicDataChannel> CreateDataChannelWithoutTransportChannel( | 195 rtc::scoped_refptr<QuicDataChannel> CreateDataChannelWithoutTransportChannel( |
196 int id, | 196 int id, |
197 const std::string& label, | 197 const std::string& label, |
198 const std::string& protocol) { | 198 const std::string& protocol) { |
199 return fake_quic_data_transport_.CreateDataChannel(id, label, protocol); | 199 return fake_quic_data_transport_.CreateDataChannel(id, label, protocol); |
200 } | 200 } |
201 | 201 |
202 // Connects |ice_transport_channel_| to that of the other peer. | 202 // Connects |ice_transport_channel_| to that of the other peer. |
203 void Connect(QuicDataChannelPeer* other_peer) { | 203 void Connect(QuicDataChannelPeer* other_peer) { |
204 ice_transport_channel_.Connect(); | 204 ice_transport_channel_->Connect(); |
205 other_peer->ice_transport_channel_.Connect(); | 205 other_peer->ice_transport_channel_->Connect(); |
206 ice_transport_channel_.SetDestination(&other_peer->ice_transport_channel_); | 206 ice_transport_channel_->SetDestination(other_peer->ice_transport_channel_); |
207 } | 207 } |
208 | 208 |
209 rtc::scoped_ptr<rtc::SSLFingerprint>& local_fingerprint() { | 209 rtc::scoped_ptr<rtc::SSLFingerprint>& local_fingerprint() { |
210 return local_fingerprint_; | 210 return local_fingerprint_; |
211 } | 211 } |
212 | 212 |
213 QuicTransportChannel* quic_transport_channel() { | 213 QuicTransportChannel* quic_transport_channel() { |
214 return &quic_transport_channel_; | 214 return &quic_transport_channel_; |
215 } | 215 } |
216 | 216 |
217 FakeTransportChannel* ice_transport_channel() { | 217 FakeTransportChannel* ice_transport_channel() { |
218 return &ice_transport_channel_; | 218 return ice_transport_channel_; |
219 } | 219 } |
220 | 220 |
221 private: | 221 private: |
222 FakeTransportChannel ice_transport_channel_; | 222 FakeTransportChannel* ice_transport_channel_; |
223 QuicTransportChannel quic_transport_channel_; | 223 QuicTransportChannel quic_transport_channel_; |
224 | 224 |
225 rtc::scoped_ptr<rtc::SSLFingerprint> local_fingerprint_; | 225 rtc::scoped_ptr<rtc::SSLFingerprint> local_fingerprint_; |
226 | 226 |
227 FakeQuicDataTransport fake_quic_data_transport_; | 227 FakeQuicDataTransport fake_quic_data_transport_; |
228 }; | 228 }; |
229 | 229 |
230 class QuicDataChannelTest : public testing::Test { | 230 class QuicDataChannelTest : public testing::Test { |
231 public: | 231 public: |
232 QuicDataChannelTest() {} | 232 QuicDataChannelTest() {} |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 size_t bytes_read2; | 650 size_t bytes_read2; |
651 ASSERT_TRUE(webrtc::ParseQuicDataMessageHeader( | 651 ASSERT_TRUE(webrtc::ParseQuicDataMessageHeader( |
652 header2.data<char>(), header2.size(), &decoded_data_channel_id2, | 652 header2.data<char>(), header2.size(), &decoded_data_channel_id2, |
653 &decoded_message_id2, &bytes_read2)); | 653 &decoded_message_id2, &bytes_read2)); |
654 EXPECT_EQ(data_channel_id2, decoded_data_channel_id2); | 654 EXPECT_EQ(data_channel_id2, decoded_data_channel_id2); |
655 EXPECT_EQ(message_id2, decoded_message_id2); | 655 EXPECT_EQ(message_id2, decoded_message_id2); |
656 EXPECT_EQ(8u, bytes_read2); | 656 EXPECT_EQ(8u, bytes_read2); |
657 } | 657 } |
658 | 658 |
659 } // namespace | 659 } // namespace |
OLD | NEW |