| Index: webrtc/api/peerconnection.cc
 | 
| diff --git a/webrtc/api/peerconnection.cc b/webrtc/api/peerconnection.cc
 | 
| index 7f1f4523781685f062bfa0f7e8b639fd1cc1b8d4..7ccc6196169ca5a509978711fd8c596110103f9a 100644
 | 
| --- a/webrtc/api/peerconnection.cc
 | 
| +++ b/webrtc/api/peerconnection.cc
 | 
| @@ -570,7 +570,12 @@ bool PeerConnection::Initialize(
 | 
|  
 | 
|    media_controller_.reset(
 | 
|        factory_->CreateMediaController(configuration.media_config));
 | 
| -
 | 
| +#ifdef HAVE_QUIC
 | 
| +  if (configuration.enable_quic) {
 | 
| +    quic_data_transport_.reset(new QuicDataTransport(
 | 
| +        factory_->signaling_thread(), factory_->worker_thread()));
 | 
| +  }
 | 
| +#endif  // HAVE_QUIC
 | 
|    session_.reset(
 | 
|        new WebRtcSession(media_controller_.get(), factory_->signaling_thread(),
 | 
|                          factory_->worker_thread(), port_allocator_.get()));
 | 
| @@ -596,6 +601,10 @@ bool PeerConnection::Initialize(
 | 
|        this, &PeerConnection::OnDataChannelDestroyed);
 | 
|    session_->SignalDataChannelOpenMessage.connect(
 | 
|        this, &PeerConnection::OnDataChannelOpenMessage);
 | 
| +#ifdef HAVE_QUIC
 | 
| +  session_->SignalQuicTransportChannelCreated.connect(
 | 
| +      this, &PeerConnection::OnQuicTransportChannelCreated);
 | 
| +#endif  // HAVE_QUIC
 | 
|    return true;
 | 
|  }
 | 
|  
 | 
| @@ -833,6 +842,23 @@ PeerConnection::CreateDataChannel(
 | 
|      const std::string& label,
 | 
|      const DataChannelInit* config) {
 | 
|    TRACE_EVENT0("webrtc", "PeerConnection::CreateDataChannel");
 | 
| +#ifdef HAVE_QUIC
 | 
| +  if (session_->data_channel_type() == cricket::DCT_QUIC) {
 | 
| +    // TODO(mikescarlett): Handle case when config is NULL.
 | 
| +    if (!config) {
 | 
| +      LOG(LS_ERROR) << "Missing config for QUIC data channel.";
 | 
| +      return nullptr;
 | 
| +    }
 | 
| +    // TODO(mikescarlett): Allow unreliable or ordered QUIC data channels.
 | 
| +    if (!config->reliable || config->ordered) {
 | 
| +      LOG(LS_ERROR) << "QUIC data channel does not implement unreliable or "
 | 
| +                       "ordered delivery.";
 | 
| +      return nullptr;
 | 
| +    }
 | 
| +    return quic_data_transport_->CreateDataChannel(label, config);
 | 
| +  }
 | 
| +#endif  // HAVE_QUIC
 | 
| +
 | 
|    bool first_datachannel = !HasDataChannels();
 | 
|  
 | 
|    std::unique_ptr<InternalDataChannelInit> internal_config;
 | 
| @@ -1500,8 +1526,8 @@ bool PeerConnection::GetOptionsForOffer(
 | 
|        (session_options->has_audio() || session_options->has_video() ||
 | 
|         session_options->has_data());
 | 
|  
 | 
| -  if (session_->data_channel_type() == cricket::DCT_SCTP && HasDataChannels()) {
 | 
| -    session_options->data_channel_type = cricket::DCT_SCTP;
 | 
| +  if (HasDataChannels()) {
 | 
| +    session_options->data_channel_type = session_->data_channel_type();
 | 
|    }
 | 
|    return true;
 | 
|  }
 | 
| @@ -1527,9 +1553,7 @@ void PeerConnection::FinishOptionsForAnswer(
 | 
|    // RTP data channel is handled in MediaSessionOptions::AddStream. SCTP streams
 | 
|    // are not signaled in the SDP so does not go through that path and must be
 | 
|    // handled here.
 | 
| -  if (session_->data_channel_type() == cricket::DCT_SCTP) {
 | 
| -    session_options->data_channel_type = cricket::DCT_SCTP;
 | 
| -  }
 | 
| +  session_options->data_channel_type = session_->data_channel_type();
 | 
|  }
 | 
|  
 | 
|  bool PeerConnection::GetOptionsForAnswer(
 | 
| @@ -1921,7 +1945,12 @@ rtc::scoped_refptr<DataChannel> PeerConnection::InternalCreateDataChannel(
 | 
|  }
 | 
|  
 | 
|  bool PeerConnection::HasDataChannels() const {
 | 
| +#ifdef HAVE_QUIC
 | 
| +  return !rtp_data_channels_.empty() || !sctp_data_channels_.empty() ||
 | 
| +         quic_data_transport_->HasDataChannels();
 | 
| +#else
 | 
|    return !rtp_data_channels_.empty() || !sctp_data_channels_.empty();
 | 
| +#endif  // HAVE_QUIC
 | 
|  }
 | 
|  
 | 
|  void PeerConnection::AllocateSctpSids(rtc::SSLRole role) {
 | 
| @@ -2064,4 +2093,12 @@ DataChannel* PeerConnection::FindDataChannelBySid(int sid) const {
 | 
|    return nullptr;
 | 
|  }
 | 
|  
 | 
| +#ifdef HAVE_QUIC
 | 
| +void PeerConnection::OnQuicTransportChannelCreated(
 | 
| +    cricket::QuicTransportChannel* channel) {
 | 
| +  RTC_DCHECK(signaling_thread()->IsCurrent());
 | 
| +  quic_data_transport_->SetTransportChannel(channel);
 | 
| +}
 | 
| +#endif  // HAVE_QUIC
 | 
| +
 | 
|  }  // namespace webrtc
 | 
| 
 |