| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 return net::QUIC_SUCCESS; | 119 return net::QUIC_SUCCESS; |
| 120 } | 120 } |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 } // namespace | 123 } // namespace |
| 124 | 124 |
| 125 namespace cricket { | 125 namespace cricket { |
| 126 | 126 |
| 127 QuicTransportChannel::QuicTransportChannel(TransportChannelImpl* channel) | 127 QuicTransportChannel::QuicTransportChannel(TransportChannelImpl* channel) |
| 128 : TransportChannelImpl(channel->transport_name(), channel->component()), | 128 : TransportChannelImpl(channel->transport_name(), channel->component()), |
| 129 worker_thread_(rtc::Thread::Current()), | 129 network_thread_(rtc::Thread::Current()), |
| 130 channel_(channel), | 130 channel_(channel), |
| 131 helper_(worker_thread_) { | 131 helper_(network_thread_) { |
| 132 channel_->SignalWritableState.connect(this, | 132 channel_->SignalWritableState.connect(this, |
| 133 &QuicTransportChannel::OnWritableState); | 133 &QuicTransportChannel::OnWritableState); |
| 134 channel_->SignalReadPacket.connect(this, &QuicTransportChannel::OnReadPacket); | 134 channel_->SignalReadPacket.connect(this, &QuicTransportChannel::OnReadPacket); |
| 135 channel_->SignalSentPacket.connect(this, &QuicTransportChannel::OnSentPacket); | 135 channel_->SignalSentPacket.connect(this, &QuicTransportChannel::OnSentPacket); |
| 136 channel_->SignalReadyToSend.connect(this, | 136 channel_->SignalReadyToSend.connect(this, |
| 137 &QuicTransportChannel::OnReadyToSend); | 137 &QuicTransportChannel::OnReadyToSend); |
| 138 channel_->SignalGatheringState.connect( | 138 channel_->SignalGatheringState.connect( |
| 139 this, &QuicTransportChannel::OnGatheringState); | 139 this, &QuicTransportChannel::OnGatheringState); |
| 140 channel_->SignalCandidateGathered.connect( | 140 channel_->SignalCandidateGathered.connect( |
| 141 this, &QuicTransportChannel::OnCandidateGathered); | 141 this, &QuicTransportChannel::OnCandidateGathered); |
| (...skipping 124 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() == worker_thread_); | 276 ASSERT(rtc::Thread::Current() == network_thread_); |
| 277 ASSERT(channel == channel_.get()); | 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(); |
| (...skipping 13 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() == worker_thread_); | 310 ASSERT(rtc::Thread::Current() == network_thread_); |
| 311 ASSERT(channel == channel_.get()); | 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() == network_thread_); |
| 327 ASSERT(channel == channel_.get()); | 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: |
| (...skipping 16 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() == worker_thread_); | 363 ASSERT(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) { |
| (...skipping 125 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() == worker_thread_); | 509 ASSERT(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 |