Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2015 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 #ifndef WEBRTC_P2P_BASE_TRANSPORTCONTROLLER_H_ | 11 #ifndef WEBRTC_P2P_BASE_TRANSPORTCONTROLLER_H_ |
| 12 #define WEBRTC_P2P_BASE_TRANSPORTCONTROLLER_H_ | 12 #define WEBRTC_P2P_BASE_TRANSPORTCONTROLLER_H_ |
| 13 | 13 |
| 14 #include <map> | 14 #include <map> |
| 15 #include <memory> | 15 #include <memory> |
| 16 #include <string> | 16 #include <string> |
| 17 #include <vector> | 17 #include <vector> |
| 18 | 18 |
| 19 #include "webrtc/base/asyncinvoker.h" | 19 #include "webrtc/base/asyncinvoker.h" |
| 20 #include "webrtc/base/constructormagic.h" | |
| 20 #include "webrtc/base/sigslot.h" | 21 #include "webrtc/base/sigslot.h" |
| 21 #include "webrtc/base/sslstreamadapter.h" | 22 #include "webrtc/base/sslstreamadapter.h" |
| 22 #include "webrtc/p2p/base/candidate.h" | 23 #include "webrtc/p2p/base/candidate.h" |
| 23 #include "webrtc/p2p/base/dtlstransportchannel.h" | 24 #include "webrtc/p2p/base/dtlstransportchannel.h" |
| 24 #include "webrtc/p2p/base/jseptransport.h" | 25 #include "webrtc/p2p/base/jseptransport.h" |
| 25 #include "webrtc/p2p/base/p2ptransportchannel.h" | 26 #include "webrtc/p2p/base/p2ptransportchannel.h" |
| 26 | 27 |
| 27 namespace rtc { | 28 namespace rtc { |
| 28 class Thread; | 29 class Thread; |
| 29 class PacketTransportInterface; | 30 class PacketTransportInterface; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 private: | 164 private: |
| 164 void OnMessage(rtc::Message* pmsg) override; | 165 void OnMessage(rtc::Message* pmsg) override; |
| 165 | 166 |
| 166 // This structure groups the DTLS and ICE channels, and helps keep track of | 167 // This structure groups the DTLS and ICE channels, and helps keep track of |
| 167 // how many external objects (BaseChannels) reference each channel. | 168 // how many external objects (BaseChannels) reference each channel. |
| 168 struct RefCountedChannel { | 169 struct RefCountedChannel { |
| 169 RefCountedChannel() = default; | 170 RefCountedChannel() = default; |
| 170 // TODO(deadbeef): Change the types of |dtls| and |ice| to | 171 // TODO(deadbeef): Change the types of |dtls| and |ice| to |
| 171 // DtlsTransportChannelWrapper and P2PTransportChannelWrapper, | 172 // DtlsTransportChannelWrapper and P2PTransportChannelWrapper, |
| 172 // once TransportChannelImpl is removed. | 173 // once TransportChannelImpl is removed. |
| 173 explicit RefCountedChannel(TransportChannelImpl* dtls, | 174 RefCountedChannel(TransportChannelImpl* dtls, TransportChannelImpl* ice) |
|
honghaiz3
2016/12/13 19:02:20
Why do we implement our custom RefCounted class in
Taylor Brandstetter
2016/12/13 22:42:36
I think just because no one has bothered to change
| |
| 174 TransportChannelImpl* ice) | |
| 175 : ice_(ice), dtls_(dtls), ref_(0) {} | 175 : ice_(ice), dtls_(dtls), ref_(0) {} |
| 176 | 176 |
| 177 // Move assignment operator and move constructor needed since this goes in | |
| 178 // a vector. | |
| 179 RefCountedChannel(RefCountedChannel&& o) | |
| 180 : ice_(std::move(o.ice_)), dtls_(std::move(o.dtls_)), ref_(o.ref_) { | |
| 181 } | |
| 182 void operator=(RefCountedChannel&& o) { | |
| 183 // Need to delete the DTLS channel first since it depends on ICE. | |
|
honghaiz3
2016/12/13 19:02:20
I wonder if we can better solve the dependency by
Taylor Brandstetter
2016/12/13 22:42:36
We can discuss that separately, but I don't want t
| |
| 184 dtls_ = std::move(o.dtls_); | |
| 185 ice_ = std::move(o.ice_); | |
| 186 ref_ = o.ref_; | |
| 187 } | |
| 188 | |
| 177 void AddRef() { ++ref_; } | 189 void AddRef() { ++ref_; } |
| 178 void DecRef() { | 190 void DecRef() { |
| 179 ASSERT(ref_ > 0); | 191 ASSERT(ref_ > 0); |
| 180 --ref_; | 192 --ref_; |
| 181 } | 193 } |
| 182 int ref() const { return ref_; } | 194 int ref() const { return ref_; } |
| 183 | 195 |
| 184 // Currently, all ICE-related calls still go through this DTLS channel. But | 196 // Currently, all ICE-related calls still go through this DTLS channel. But |
| 185 // that will change once we get rid of TransportChannelImpl, and the DTLS | 197 // that will change once we get rid of TransportChannelImpl, and the DTLS |
| 186 // channel interface no longer includes ICE-specific methods. | 198 // channel interface no longer includes ICE-specific methods. |
| 187 const TransportChannelImpl* dtls() const { return dtls_.get(); } | 199 const TransportChannelImpl* dtls() const { return dtls_.get(); } |
| 188 TransportChannelImpl* dtls() { return dtls_.get(); } | 200 TransportChannelImpl* dtls() { return dtls_.get(); } |
| 189 const TransportChannelImpl* ice() const { return ice_.get(); } | 201 const TransportChannelImpl* ice() const { return ice_.get(); } |
| 190 TransportChannelImpl* ice() { return ice_.get(); } | 202 TransportChannelImpl* ice() { return ice_.get(); } |
| 191 | 203 |
| 192 private: | 204 private: |
| 193 std::unique_ptr<TransportChannelImpl> ice_; | 205 std::unique_ptr<TransportChannelImpl> ice_; |
|
honghaiz3
2016/12/13 19:02:20
Is it an overkill to use smart pointer here?
Since
Taylor Brandstetter
2016/12/13 22:42:36
I prefer to use smart pointers where possible beca
| |
| 194 std::unique_ptr<TransportChannelImpl> dtls_; | 206 std::unique_ptr<TransportChannelImpl> dtls_; |
| 195 int ref_ = 0; | 207 int ref_ = 0; |
| 196 }; | 208 }; |
| 197 | 209 |
| 198 // Helper functions to get a channel or transport, or iterator to it (in case | 210 // Helper functions to get a channel or transport, or iterator to it (in case |
| 199 // it needs to be erased). | 211 // it needs to be erased). |
| 200 std::vector<RefCountedChannel>::iterator GetChannelIterator_n( | 212 std::vector<RefCountedChannel>::iterator GetChannelIterator_n( |
| 201 const std::string& transport_name, | 213 const std::string& transport_name, |
| 202 int component); | 214 int component); |
| 203 std::vector<RefCountedChannel>::const_iterator GetChannelIterator_n( | 215 std::vector<RefCountedChannel>::const_iterator GetChannelIterator_n( |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 IceRole ice_role_ = ICEROLE_CONTROLLING; | 287 IceRole ice_role_ = ICEROLE_CONTROLLING; |
| 276 bool redetermine_role_on_ice_restart_; | 288 bool redetermine_role_on_ice_restart_; |
| 277 uint64_t ice_tiebreaker_ = rtc::CreateRandomId64(); | 289 uint64_t ice_tiebreaker_ = rtc::CreateRandomId64(); |
| 278 rtc::SSLProtocolVersion ssl_max_version_ = rtc::SSL_PROTOCOL_DTLS_12; | 290 rtc::SSLProtocolVersion ssl_max_version_ = rtc::SSL_PROTOCOL_DTLS_12; |
| 279 rtc::scoped_refptr<rtc::RTCCertificate> certificate_; | 291 rtc::scoped_refptr<rtc::RTCCertificate> certificate_; |
| 280 rtc::AsyncInvoker invoker_; | 292 rtc::AsyncInvoker invoker_; |
| 281 // True if QUIC is used instead of DTLS. | 293 // True if QUIC is used instead of DTLS. |
| 282 bool quic_ = false; | 294 bool quic_ = false; |
| 283 | 295 |
| 284 webrtc::MetricsObserverInterface* metrics_observer_ = nullptr; | 296 webrtc::MetricsObserverInterface* metrics_observer_ = nullptr; |
| 297 | |
| 298 RTC_DISALLOW_COPY_AND_ASSIGN(TransportController); | |
| 285 }; | 299 }; |
| 286 | 300 |
| 287 } // namespace cricket | 301 } // namespace cricket |
| 288 | 302 |
| 289 #endif // WEBRTC_P2P_BASE_TRANSPORTCONTROLLER_H_ | 303 #endif // WEBRTC_P2P_BASE_TRANSPORTCONTROLLER_H_ |
| OLD | NEW |