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 |
11 #include "webrtc/api/quicdatatransport.h" | 11 #include "webrtc/api/quicdatatransport.h" |
12 | 12 |
13 #include "webrtc/base/logging.h" | 13 #include "webrtc/base/logging.h" |
14 #include "webrtc/p2p/quic/quictransportchannel.h" | 14 #include "webrtc/p2p/quic/quictransportchannel.h" |
15 #include "webrtc/p2p/quic/reliablequicstream.h" | 15 #include "webrtc/p2p/quic/reliablequicstream.h" |
16 | 16 |
17 namespace webrtc { | 17 namespace webrtc { |
18 | 18 |
19 QuicDataTransport::QuicDataTransport(rtc::Thread* signaling_thread, | 19 QuicDataTransport::QuicDataTransport(rtc::Thread* signaling_thread, |
20 rtc::Thread* worker_thread) | 20 rtc::Thread* worker_thread, |
21 : signaling_thread_(signaling_thread), worker_thread_(worker_thread) { | 21 rtc::Thread* network_thread) |
| 22 : signaling_thread_(signaling_thread), |
| 23 worker_thread_(worker_thread), |
| 24 network_thread_(network_thread) { |
22 RTC_DCHECK(signaling_thread_); | 25 RTC_DCHECK(signaling_thread_); |
23 RTC_DCHECK(worker_thread_); | 26 RTC_DCHECK(worker_thread_); |
| 27 RTC_DCHECK(network_thread_); |
24 } | 28 } |
25 | 29 |
26 QuicDataTransport::~QuicDataTransport() {} | 30 QuicDataTransport::~QuicDataTransport() {} |
27 | 31 |
28 bool QuicDataTransport::SetTransportChannel( | 32 bool QuicDataTransport::SetTransportChannel( |
29 cricket::QuicTransportChannel* channel) { | 33 cricket::QuicTransportChannel* channel) { |
30 if (!channel) { | 34 if (!channel) { |
31 LOG(LS_ERROR) << "|channel| is NULL. Cannot set transport channel."; | 35 LOG(LS_ERROR) << "|channel| is NULL. Cannot set transport channel."; |
32 return false; | 36 return false; |
33 } | 37 } |
(...skipping 27 matching lines...) Expand all Loading... |
61 rtc::scoped_refptr<DataChannelInterface> QuicDataTransport::CreateDataChannel( | 65 rtc::scoped_refptr<DataChannelInterface> QuicDataTransport::CreateDataChannel( |
62 const std::string& label, | 66 const std::string& label, |
63 const DataChannelInit* config) { | 67 const DataChannelInit* config) { |
64 if (config == nullptr) { | 68 if (config == nullptr) { |
65 return nullptr; | 69 return nullptr; |
66 } | 70 } |
67 if (data_channel_by_id_.find(config->id) != data_channel_by_id_.end()) { | 71 if (data_channel_by_id_.find(config->id) != data_channel_by_id_.end()) { |
68 LOG(LS_ERROR) << "QUIC data channel already exists with id " << config->id; | 72 LOG(LS_ERROR) << "QUIC data channel already exists with id " << config->id; |
69 return nullptr; | 73 return nullptr; |
70 } | 74 } |
71 rtc::scoped_refptr<QuicDataChannel> data_channel( | 75 rtc::scoped_refptr<QuicDataChannel> data_channel(new QuicDataChannel( |
72 new QuicDataChannel(signaling_thread_, worker_thread_, label, *config)); | 76 signaling_thread_, worker_thread_, network_thread_, label, *config)); |
73 if (quic_transport_channel_) { | 77 if (quic_transport_channel_) { |
74 if (!data_channel->SetTransportChannel(quic_transport_channel_)) { | 78 if (!data_channel->SetTransportChannel(quic_transport_channel_)) { |
75 LOG(LS_ERROR) | 79 LOG(LS_ERROR) |
76 << "Cannot set QUIC transport channel for QUIC data channel " | 80 << "Cannot set QUIC transport channel for QUIC data channel " |
77 << config->id; | 81 << config->id; |
78 } | 82 } |
79 } | 83 } |
80 | 84 |
81 data_channel_by_id_[data_channel->id()] = data_channel; | 85 data_channel_by_id_[data_channel->id()] = data_channel; |
82 return data_channel; | 86 return data_channel; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 } | 141 } |
138 QuicDataChannel* data_channel = data_channel_kv->second; | 142 QuicDataChannel* data_channel = data_channel_kv->second; |
139 QuicDataChannel::Message message; | 143 QuicDataChannel::Message message; |
140 message.id = message_id; | 144 message.id = message_id; |
141 message.buffer = rtc::CopyOnWriteBuffer(data, len); | 145 message.buffer = rtc::CopyOnWriteBuffer(data, len); |
142 message.stream = stream; | 146 message.stream = stream; |
143 data_channel->OnIncomingMessage(std::move(message)); | 147 data_channel->OnIncomingMessage(std::move(message)); |
144 } | 148 } |
145 | 149 |
146 } // namespace webrtc | 150 } // namespace webrtc |
OLD | NEW |