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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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() == worker_thread_); | 276 ASSERT(rtc::Thread::Current() == worker_thread_); |
277 ASSERT(channel == channel_); | 277 ASSERT(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 13 matching lines...) Expand all Loading... |
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() == worker_thread_); | 310 ASSERT(rtc::Thread::Current() == worker_thread_); |
311 ASSERT(channel == channel_); | 311 ASSERT(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() == worker_thread_); | 326 ASSERT(rtc::Thread::Current() == worker_thread_); |
327 ASSERT(channel == channel_); | 327 ASSERT(channel == channel_.get()); |
328 ASSERT(flags == 0); | 328 ASSERT(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: |
(...skipping 26 matching lines...) Expand all Loading... |
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_); | 374 ASSERT(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_); | 380 ASSERT(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_); | 385 ASSERT(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_); | 391 ASSERT(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 ASSERT(channel == channel_); | 399 ASSERT(channel == channel_.get()); |
400 SignalSelectedCandidatePairChanged(this, selected_candidate_pair, | 400 SignalSelectedCandidatePairChanged(this, selected_candidate_pair, |
401 last_sent_packet_id); | 401 last_sent_packet_id); |
402 } | 402 } |
403 | 403 |
404 void QuicTransportChannel::OnConnectionRemoved(TransportChannelImpl* channel) { | 404 void QuicTransportChannel::OnConnectionRemoved(TransportChannelImpl* channel) { |
405 ASSERT(channel == channel_); | 405 ASSERT(channel == channel_.get()); |
406 SignalConnectionRemoved(this); | 406 SignalConnectionRemoved(this); |
407 } | 407 } |
408 | 408 |
409 bool QuicTransportChannel::MaybeStartQuic() { | 409 bool QuicTransportChannel::MaybeStartQuic() { |
410 if (!channel_->writable()) { | 410 if (!channel_->writable()) { |
411 LOG_J(LS_ERROR, this) << "Couldn't start QUIC handshake."; | 411 LOG_J(LS_ERROR, this) << "Couldn't start QUIC handshake."; |
412 return false; | 412 return false; |
413 } | 413 } |
414 if (!CreateQuicSession() || !StartQuicHandshake()) { | 414 if (!CreateQuicSession() || !StartQuicHandshake()) { |
415 LOG_J(LS_WARNING, this) | 415 LOG_J(LS_WARNING, this) |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 return quic_->CreateOutgoingDynamicStream(priority); | 587 return quic_->CreateOutgoingDynamicStream(priority); |
588 } | 588 } |
589 return nullptr; | 589 return nullptr; |
590 } | 590 } |
591 | 591 |
592 void QuicTransportChannel::OnIncomingStream(ReliableQuicStream* stream) { | 592 void QuicTransportChannel::OnIncomingStream(ReliableQuicStream* stream) { |
593 SignalIncomingStream(stream); | 593 SignalIncomingStream(stream); |
594 } | 594 } |
595 | 595 |
596 } // namespace cricket | 596 } // namespace cricket |
OLD | NEW |