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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 LOG(LS_ERROR) << "Failed to send an invalid SRTP bypass packet using QUIC."; | 266 LOG(LS_ERROR) << "Failed to send an invalid SRTP bypass packet using QUIC."; |
267 return -1; | 267 return -1; |
268 } | 268 } |
269 | 269 |
270 // The state transition logic here is as follows: | 270 // The state transition logic here is as follows: |
271 // - Before the QUIC handshake is complete, the QUIC channel is unwritable. | 271 // - Before the QUIC handshake is complete, the QUIC channel is unwritable. |
272 // - When |channel_| goes writable we start the QUIC handshake. | 272 // - When |channel_| goes writable we start the QUIC handshake. |
273 // - Once the QUIC handshake completes, the state is that of the | 273 // - Once the QUIC handshake completes, the state is that of the |
274 // |channel_| again. | 274 // |channel_| again. |
275 void QuicTransportChannel::OnWritableState(TransportChannel* channel) { | 275 void QuicTransportChannel::OnWritableState(TransportChannel* channel) { |
276 ASSERT(rtc::Thread::Current() == network_thread_); | 276 RTC_DCHECK(rtc::Thread::Current() == network_thread_); |
277 ASSERT(channel == channel_.get()); | 277 RTC_DCHECK(channel == channel_.get()); |
278 LOG_J(LS_VERBOSE, this) | 278 LOG_J(LS_VERBOSE, this) |
279 << "QuicTransportChannel: channel writable state changed to " | 279 << "QuicTransportChannel: channel writable state changed to " |
280 << channel_->writable(); | 280 << channel_->writable(); |
281 switch (quic_state_) { | 281 switch (quic_state_) { |
282 case QUIC_TRANSPORT_NEW: | 282 case QUIC_TRANSPORT_NEW: |
283 // Start the QUIC handshake when |channel_| is writable. | 283 // Start the QUIC handshake when |channel_| is writable. |
284 // This will fail if the SSL role or remote fingerprint are not set. | 284 // This will fail if the SSL role or remote fingerprint are not set. |
285 // Otherwise failure could result from network or QUIC errors. | 285 // Otherwise failure could result from network or QUIC errors. |
286 MaybeStartQuic(); | 286 MaybeStartQuic(); |
287 break; | 287 break; |
(...skipping 12 matching lines...) Expand all Loading... |
300 } | 300 } |
301 break; | 301 break; |
302 case QUIC_TRANSPORT_CLOSED: | 302 case QUIC_TRANSPORT_CLOSED: |
303 // TODO(mikescarlett): Allow the QUIC connection to be reset if it drops | 303 // TODO(mikescarlett): Allow the QUIC connection to be reset if it drops |
304 // due to a non-failure. | 304 // due to a non-failure. |
305 break; | 305 break; |
306 } | 306 } |
307 } | 307 } |
308 | 308 |
309 void QuicTransportChannel::OnReceivingState(TransportChannel* channel) { | 309 void QuicTransportChannel::OnReceivingState(TransportChannel* channel) { |
310 ASSERT(rtc::Thread::Current() == network_thread_); | 310 RTC_DCHECK(rtc::Thread::Current() == network_thread_); |
311 ASSERT(channel == channel_.get()); | 311 RTC_DCHECK(channel == channel_.get()); |
312 LOG_J(LS_VERBOSE, this) | 312 LOG_J(LS_VERBOSE, this) |
313 << "QuicTransportChannel: channel receiving state changed to " | 313 << "QuicTransportChannel: channel receiving state changed to " |
314 << channel_->receiving(); | 314 << channel_->receiving(); |
315 if (quic_state_ == QUIC_TRANSPORT_CONNECTED) { | 315 if (quic_state_ == QUIC_TRANSPORT_CONNECTED) { |
316 // Note: SignalReceivingState fired by set_receiving. | 316 // Note: SignalReceivingState fired by set_receiving. |
317 set_receiving(channel_->receiving()); | 317 set_receiving(channel_->receiving()); |
318 } | 318 } |
319 } | 319 } |
320 | 320 |
321 void QuicTransportChannel::OnReadPacket(TransportChannel* channel, | 321 void QuicTransportChannel::OnReadPacket(TransportChannel* channel, |
322 const char* data, | 322 const char* data, |
323 size_t size, | 323 size_t size, |
324 const rtc::PacketTime& packet_time, | 324 const rtc::PacketTime& packet_time, |
325 int flags) { | 325 int flags) { |
326 ASSERT(rtc::Thread::Current() == network_thread_); | 326 RTC_DCHECK(rtc::Thread::Current() == network_thread_); |
327 ASSERT(channel == channel_.get()); | 327 RTC_DCHECK(channel == channel_.get()); |
328 ASSERT(flags == 0); | 328 RTC_DCHECK(flags == 0); |
329 | 329 |
330 switch (quic_state_) { | 330 switch (quic_state_) { |
331 case QUIC_TRANSPORT_NEW: | 331 case QUIC_TRANSPORT_NEW: |
332 // This would occur if other peer is ready to start QUIC but this peer | 332 // This would occur if other peer is ready to start QUIC but this peer |
333 // hasn't started QUIC. | 333 // hasn't started QUIC. |
334 LOG_J(LS_INFO, this) << "Dropping packet received before QUIC started."; | 334 LOG_J(LS_INFO, this) << "Dropping packet received before QUIC started."; |
335 break; | 335 break; |
336 case QUIC_TRANSPORT_CONNECTING: | 336 case QUIC_TRANSPORT_CONNECTING: |
337 case QUIC_TRANSPORT_CONNECTED: | 337 case QUIC_TRANSPORT_CONNECTED: |
338 // We should only get QUIC or SRTP packets; STUN's already been demuxed. | 338 // We should only get QUIC or SRTP packets; STUN's already been demuxed. |
(...skipping 14 matching lines...) Expand all Loading... |
353 } | 353 } |
354 break; | 354 break; |
355 case QUIC_TRANSPORT_CLOSED: | 355 case QUIC_TRANSPORT_CLOSED: |
356 // This shouldn't be happening. Drop the packet. | 356 // This shouldn't be happening. Drop the packet. |
357 break; | 357 break; |
358 } | 358 } |
359 } | 359 } |
360 | 360 |
361 void QuicTransportChannel::OnSentPacket(TransportChannel* channel, | 361 void QuicTransportChannel::OnSentPacket(TransportChannel* channel, |
362 const rtc::SentPacket& sent_packet) { | 362 const rtc::SentPacket& sent_packet) { |
363 ASSERT(rtc::Thread::Current() == network_thread_); | 363 RTC_DCHECK(rtc::Thread::Current() == network_thread_); |
364 SignalSentPacket(this, sent_packet); | 364 SignalSentPacket(this, sent_packet); |
365 } | 365 } |
366 | 366 |
367 void QuicTransportChannel::OnReadyToSend(TransportChannel* channel) { | 367 void QuicTransportChannel::OnReadyToSend(TransportChannel* channel) { |
368 if (writable()) { | 368 if (writable()) { |
369 SignalReadyToSend(this); | 369 SignalReadyToSend(this); |
370 } | 370 } |
371 } | 371 } |
372 | 372 |
373 void QuicTransportChannel::OnGatheringState(TransportChannelImpl* channel) { | 373 void QuicTransportChannel::OnGatheringState(TransportChannelImpl* channel) { |
374 ASSERT(channel == channel_.get()); | 374 RTC_DCHECK(channel == channel_.get()); |
375 SignalGatheringState(this); | 375 SignalGatheringState(this); |
376 } | 376 } |
377 | 377 |
378 void QuicTransportChannel::OnCandidateGathered(TransportChannelImpl* channel, | 378 void QuicTransportChannel::OnCandidateGathered(TransportChannelImpl* channel, |
379 const Candidate& c) { | 379 const Candidate& c) { |
380 ASSERT(channel == channel_.get()); | 380 RTC_DCHECK(channel == channel_.get()); |
381 SignalCandidateGathered(this, c); | 381 SignalCandidateGathered(this, c); |
382 } | 382 } |
383 | 383 |
384 void QuicTransportChannel::OnRoleConflict(TransportChannelImpl* channel) { | 384 void QuicTransportChannel::OnRoleConflict(TransportChannelImpl* channel) { |
385 ASSERT(channel == channel_.get()); | 385 RTC_DCHECK(channel == channel_.get()); |
386 SignalRoleConflict(this); | 386 SignalRoleConflict(this); |
387 } | 387 } |
388 | 388 |
389 void QuicTransportChannel::OnRouteChange(TransportChannel* channel, | 389 void QuicTransportChannel::OnRouteChange(TransportChannel* channel, |
390 const Candidate& candidate) { | 390 const Candidate& candidate) { |
391 ASSERT(channel == channel_.get()); | 391 RTC_DCHECK(channel == channel_.get()); |
392 SignalRouteChange(this, candidate); | 392 SignalRouteChange(this, candidate); |
393 } | 393 } |
394 | 394 |
395 void QuicTransportChannel::OnSelectedCandidatePairChanged( | 395 void QuicTransportChannel::OnSelectedCandidatePairChanged( |
396 TransportChannel* channel, | 396 TransportChannel* channel, |
397 CandidatePairInterface* selected_candidate_pair, | 397 CandidatePairInterface* selected_candidate_pair, |
398 int last_sent_packet_id, | 398 int last_sent_packet_id, |
399 bool ready_to_send) { | 399 bool ready_to_send) { |
400 ASSERT(channel == channel_.get()); | 400 RTC_DCHECK(channel == channel_.get()); |
401 SignalSelectedCandidatePairChanged(this, selected_candidate_pair, | 401 SignalSelectedCandidatePairChanged(this, selected_candidate_pair, |
402 last_sent_packet_id, ready_to_send); | 402 last_sent_packet_id, ready_to_send); |
403 } | 403 } |
404 | 404 |
405 void QuicTransportChannel::OnChannelStateChanged( | 405 void QuicTransportChannel::OnChannelStateChanged( |
406 TransportChannelImpl* channel) { | 406 TransportChannelImpl* channel) { |
407 ASSERT(channel == channel_.get()); | 407 RTC_DCHECK(channel == channel_.get()); |
408 SignalStateChanged(this); | 408 SignalStateChanged(this); |
409 } | 409 } |
410 | 410 |
411 bool QuicTransportChannel::MaybeStartQuic() { | 411 bool QuicTransportChannel::MaybeStartQuic() { |
412 if (!channel_->writable()) { | 412 if (!channel_->writable()) { |
413 LOG_J(LS_ERROR, this) << "Couldn't start QUIC handshake."; | 413 LOG_J(LS_ERROR, this) << "Couldn't start QUIC handshake."; |
414 return false; | 414 return false; |
415 } | 415 } |
416 if (!CreateQuicSession() || !StartQuicHandshake()) { | 416 if (!CreateQuicSession() || !StartQuicHandshake()) { |
417 LOG_J(LS_WARNING, this) | 417 LOG_J(LS_WARNING, this) |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 quic_compressed_certs_cache_.get(), | 499 quic_compressed_certs_cache_.get(), |
500 use_stateless_rejects_if_peer_supported, | 500 use_stateless_rejects_if_peer_supported, |
501 quic_.get()); | 501 quic_.get()); |
502 quic_->StartServerHandshake(crypto_stream); | 502 quic_->StartServerHandshake(crypto_stream); |
503 LOG_J(LS_INFO, this) << "QuicTransportChannel: Started server handshake."; | 503 LOG_J(LS_INFO, this) << "QuicTransportChannel: Started server handshake."; |
504 } | 504 } |
505 return true; | 505 return true; |
506 } | 506 } |
507 | 507 |
508 bool QuicTransportChannel::HandleQuicPacket(const char* data, size_t size) { | 508 bool QuicTransportChannel::HandleQuicPacket(const char* data, size_t size) { |
509 ASSERT(rtc::Thread::Current() == network_thread_); | 509 RTC_DCHECK(rtc::Thread::Current() == network_thread_); |
510 return quic_->OnReadPacket(data, size); | 510 return quic_->OnReadPacket(data, size); |
511 } | 511 } |
512 | 512 |
513 net::WriteResult QuicTransportChannel::WritePacket( | 513 net::WriteResult QuicTransportChannel::WritePacket( |
514 const char* buffer, | 514 const char* buffer, |
515 size_t buf_len, | 515 size_t buf_len, |
516 const net::IPAddress& self_address, | 516 const net::IPAddress& self_address, |
517 const net::IPEndPoint& peer_address, | 517 const net::IPEndPoint& peer_address, |
518 net::PerPacketOptions* options) { | 518 net::PerPacketOptions* options) { |
519 // QUIC should never call this if IsWriteBlocked, but just in case... | 519 // QUIC should never call this if IsWriteBlocked, but just in case... |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 return quic_->CreateOutgoingDynamicStream(priority); | 589 return quic_->CreateOutgoingDynamicStream(priority); |
590 } | 590 } |
591 return nullptr; | 591 return nullptr; |
592 } | 592 } |
593 | 593 |
594 void QuicTransportChannel::OnIncomingStream(ReliableQuicStream* stream) { | 594 void QuicTransportChannel::OnIncomingStream(ReliableQuicStream* stream) { |
595 SignalIncomingStream(stream); | 595 SignalIncomingStream(stream); |
596 } | 596 } |
597 | 597 |
598 } // namespace cricket | 598 } // namespace cricket |
OLD | NEW |