Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(880)

Side by Side Diff: webrtc/p2p/base/fakesession.h

Issue 1304043008: Replacing SSLIdentity* with scoped_refptr<RTCCertificate> in TransportChannel layer (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Making overriding "virtual" methods use the override keyword Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/p2p/base/dtlstransportchannel_unittest.cc ('k') | webrtc/p2p/base/p2ptransportchannel.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2009 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2009 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 29 matching lines...) Expand all
40 // SetDestination. 40 // SetDestination.
41 // TODO(hbos): Move implementation to .cc file, this and other classes in file. 41 // TODO(hbos): Move implementation to .cc file, this and other classes in file.
42 class FakeTransportChannel : public TransportChannelImpl, 42 class FakeTransportChannel : public TransportChannelImpl,
43 public rtc::MessageHandler { 43 public rtc::MessageHandler {
44 public: 44 public:
45 explicit FakeTransportChannel(Transport* transport, 45 explicit FakeTransportChannel(Transport* transport,
46 const std::string& content_name, 46 const std::string& content_name,
47 int component) 47 int component)
48 : TransportChannelImpl(content_name, component), 48 : TransportChannelImpl(content_name, component),
49 transport_(transport), 49 transport_(transport),
50 dest_(NULL), 50 dest_(nullptr),
51 state_(STATE_INIT), 51 state_(STATE_INIT),
52 async_(false), 52 async_(false),
53 identity_(NULL),
54 do_dtls_(false), 53 do_dtls_(false),
55 role_(ICEROLE_UNKNOWN), 54 role_(ICEROLE_UNKNOWN),
56 tiebreaker_(0), 55 tiebreaker_(0),
57 remote_ice_mode_(ICEMODE_FULL), 56 remote_ice_mode_(ICEMODE_FULL),
58 dtls_fingerprint_("", NULL, 0), 57 dtls_fingerprint_("", nullptr, 0),
59 ssl_role_(rtc::SSL_CLIENT), 58 ssl_role_(rtc::SSL_CLIENT),
60 connection_count_(0) { 59 connection_count_(0) {
61 } 60 }
62 ~FakeTransportChannel() { 61 ~FakeTransportChannel() {
63 Reset(); 62 Reset();
64 } 63 }
65 64
66 uint64 IceTiebreaker() const { return tiebreaker_; } 65 uint64 IceTiebreaker() const { return tiebreaker_; }
67 IceMode remote_ice_mode() const { return remote_ice_mode_; } 66 IceMode remote_ice_mode() const { return remote_ice_mode_; }
68 const std::string& ice_ufrag() const { return ice_ufrag_; } 67 const std::string& ice_ufrag() const { return ice_ufrag_; }
69 const std::string& ice_pwd() const { return ice_pwd_; } 68 const std::string& ice_pwd() const { return ice_pwd_; }
70 const std::string& remote_ice_ufrag() const { return remote_ice_ufrag_; } 69 const std::string& remote_ice_ufrag() const { return remote_ice_ufrag_; }
71 const std::string& remote_ice_pwd() const { return remote_ice_pwd_; } 70 const std::string& remote_ice_pwd() const { return remote_ice_pwd_; }
72 const rtc::SSLFingerprint& dtls_fingerprint() const { 71 const rtc::SSLFingerprint& dtls_fingerprint() const {
73 return dtls_fingerprint_; 72 return dtls_fingerprint_;
74 } 73 }
75 74
76 void SetAsync(bool async) { 75 void SetAsync(bool async) {
77 async_ = async; 76 async_ = async;
78 } 77 }
79 78
80 virtual Transport* GetTransport() { 79 Transport* GetTransport() override {
81 return transport_; 80 return transport_;
82 } 81 }
83 82
84 virtual TransportChannelState GetState() const { 83 TransportChannelState GetState() const override {
85 if (connection_count_ == 0) { 84 if (connection_count_ == 0) {
86 return TransportChannelState::STATE_FAILED; 85 return TransportChannelState::STATE_FAILED;
87 } 86 }
88 87
89 if (connection_count_ == 1) { 88 if (connection_count_ == 1) {
90 return TransportChannelState::STATE_COMPLETED; 89 return TransportChannelState::STATE_COMPLETED;
91 } 90 }
92 91
93 return TransportChannelState::STATE_FAILED; 92 return TransportChannelState::STATE_FAILED;
94 } 93 }
95 94
96 virtual void SetIceRole(IceRole role) { role_ = role; } 95 void SetIceRole(IceRole role) override { role_ = role; }
97 virtual IceRole GetIceRole() const { return role_; } 96 IceRole GetIceRole() const override { return role_; }
98 virtual void SetIceTiebreaker(uint64 tiebreaker) { tiebreaker_ = tiebreaker; } 97 void SetIceTiebreaker(uint64 tiebreaker) override {
99 virtual void SetIceCredentials(const std::string& ice_ufrag, 98 tiebreaker_ = tiebreaker;
100 const std::string& ice_pwd) { 99 }
100 void SetIceCredentials(const std::string& ice_ufrag,
101 const std::string& ice_pwd) override {
101 ice_ufrag_ = ice_ufrag; 102 ice_ufrag_ = ice_ufrag;
102 ice_pwd_ = ice_pwd; 103 ice_pwd_ = ice_pwd;
103 } 104 }
104 virtual void SetRemoteIceCredentials(const std::string& ice_ufrag, 105 void SetRemoteIceCredentials(const std::string& ice_ufrag,
105 const std::string& ice_pwd) { 106 const std::string& ice_pwd) override {
106 remote_ice_ufrag_ = ice_ufrag; 107 remote_ice_ufrag_ = ice_ufrag;
107 remote_ice_pwd_ = ice_pwd; 108 remote_ice_pwd_ = ice_pwd;
108 } 109 }
109 110
110 virtual void SetRemoteIceMode(IceMode mode) { remote_ice_mode_ = mode; } 111 void SetRemoteIceMode(IceMode mode) override { remote_ice_mode_ = mode; }
111 virtual bool SetRemoteFingerprint(const std::string& alg, const uint8* digest, 112 bool SetRemoteFingerprint(const std::string& alg, const uint8* digest,
112 size_t digest_len) { 113 size_t digest_len) override {
113 dtls_fingerprint_ = rtc::SSLFingerprint(alg, digest, digest_len); 114 dtls_fingerprint_ = rtc::SSLFingerprint(alg, digest, digest_len);
114 return true; 115 return true;
115 } 116 }
116 virtual bool SetSslRole(rtc::SSLRole role) { 117 bool SetSslRole(rtc::SSLRole role) override {
117 ssl_role_ = role; 118 ssl_role_ = role;
118 return true; 119 return true;
119 } 120 }
120 virtual bool GetSslRole(rtc::SSLRole* role) const { 121 bool GetSslRole(rtc::SSLRole* role) const override {
121 *role = ssl_role_; 122 *role = ssl_role_;
122 return true; 123 return true;
123 } 124 }
124 125
125 virtual void Connect() { 126 void Connect() override {
126 if (state_ == STATE_INIT) { 127 if (state_ == STATE_INIT) {
127 state_ = STATE_CONNECTING; 128 state_ = STATE_CONNECTING;
128 } 129 }
129 } 130 }
130 virtual void Reset() { 131 virtual void Reset() {
131 if (state_ != STATE_INIT) { 132 if (state_ != STATE_INIT) {
132 state_ = STATE_INIT; 133 state_ = STATE_INIT;
133 if (dest_) { 134 if (dest_) {
134 dest_->state_ = STATE_INIT; 135 dest_->state_ = STATE_INIT;
135 dest_->dest_ = NULL; 136 dest_->dest_ = NULL;
136 dest_ = NULL; 137 dest_ = NULL;
137 } 138 }
138 } 139 }
139 } 140 }
140 141
141 void SetWritable(bool writable) { 142 void SetWritable(bool writable) {
142 set_writable(writable); 143 set_writable(writable);
143 } 144 }
144 145
145 void SetDestination(FakeTransportChannel* dest) { 146 void SetDestination(FakeTransportChannel* dest) {
146 if (state_ == STATE_CONNECTING && dest) { 147 if (state_ == STATE_CONNECTING && dest) {
147 // This simulates the delivery of candidates. 148 // This simulates the delivery of candidates.
148 dest_ = dest; 149 dest_ = dest;
149 dest_->dest_ = this; 150 dest_->dest_ = this;
150 if (identity_ && dest_->identity_) { 151 if (certificate_ && dest_->certificate_) {
151 do_dtls_ = true; 152 do_dtls_ = true;
152 dest_->do_dtls_ = true; 153 dest_->do_dtls_ = true;
153 NegotiateSrtpCiphers(); 154 NegotiateSrtpCiphers();
154 } 155 }
155 state_ = STATE_CONNECTED; 156 state_ = STATE_CONNECTED;
156 dest_->state_ = STATE_CONNECTED; 157 dest_->state_ = STATE_CONNECTED;
157 set_writable(true); 158 set_writable(true);
158 dest_->set_writable(true); 159 dest_->set_writable(true);
159 } else if (state_ == STATE_CONNECTED && !dest) { 160 } else if (state_ == STATE_CONNECTED && !dest) {
160 // Simulates loss of connectivity, by asymmetrically forgetting dest_. 161 // Simulates loss of connectivity, by asymmetrically forgetting dest_.
161 dest_ = NULL; 162 dest_ = NULL;
162 state_ = STATE_CONNECTING; 163 state_ = STATE_CONNECTING;
163 set_writable(false); 164 set_writable(false);
164 } 165 }
165 } 166 }
166 167
167 void SetConnectionCount(size_t connection_count) { 168 void SetConnectionCount(size_t connection_count) {
168 size_t old_connection_count = connection_count_; 169 size_t old_connection_count = connection_count_;
169 connection_count_ = connection_count; 170 connection_count_ = connection_count;
170 if (connection_count_ < old_connection_count) 171 if (connection_count_ < old_connection_count)
171 SignalConnectionRemoved(this); 172 SignalConnectionRemoved(this);
172 } 173 }
173 174
174 void SetReceiving(bool receiving) { 175 void SetReceiving(bool receiving) {
175 set_receiving(receiving); 176 set_receiving(receiving);
176 } 177 }
177 178
178 void SetReceivingTimeout(int timeout) override {} 179 void SetReceivingTimeout(int timeout) override {}
179 180
180 virtual int SendPacket(const char* data, size_t len, 181 int SendPacket(const char* data, size_t len,
181 const rtc::PacketOptions& options, int flags) { 182 const rtc::PacketOptions& options, int flags) override {
182 if (state_ != STATE_CONNECTED) { 183 if (state_ != STATE_CONNECTED) {
183 return -1; 184 return -1;
184 } 185 }
185 186
186 if (flags != PF_SRTP_BYPASS && flags != 0) { 187 if (flags != PF_SRTP_BYPASS && flags != 0) {
187 return -1; 188 return -1;
188 } 189 }
189 190
190 PacketMessageData* packet = new PacketMessageData(data, len); 191 PacketMessageData* packet = new PacketMessageData(data, len);
191 if (async_) { 192 if (async_) {
192 rtc::Thread::Current()->Post(this, 0, packet); 193 rtc::Thread::Current()->Post(this, 0, packet);
193 } else { 194 } else {
194 rtc::Thread::Current()->Send(this, 0, packet); 195 rtc::Thread::Current()->Send(this, 0, packet);
195 } 196 }
196 return static_cast<int>(len); 197 return static_cast<int>(len);
197 } 198 }
198 virtual int SetOption(rtc::Socket::Option opt, int value) { 199 int SetOption(rtc::Socket::Option opt, int value) override {
199 return true; 200 return true;
200 } 201 }
201 virtual bool GetOption(rtc::Socket::Option opt, int* value) { 202 bool GetOption(rtc::Socket::Option opt, int* value) override {
202 return true; 203 return true;
203 } 204 }
204 virtual int GetError() { 205 int GetError() override {
205 return 0; 206 return 0;
206 } 207 }
207 208
208 virtual void OnSignalingReady() { 209 void OnSignalingReady() override {
209 } 210 }
210 virtual void OnCandidate(const Candidate& candidate) { 211 void OnCandidate(const Candidate& candidate) override {
211 } 212 }
212 213
213 virtual void OnMessage(rtc::Message* msg) { 214 void OnMessage(rtc::Message* msg) override {
214 PacketMessageData* data = static_cast<PacketMessageData*>( 215 PacketMessageData* data = static_cast<PacketMessageData*>(
215 msg->pdata); 216 msg->pdata);
216 dest_->SignalReadPacket(dest_, data->packet.data<char>(), 217 dest_->SignalReadPacket(dest_, data->packet.data<char>(),
217 data->packet.size(), rtc::CreatePacketTime(0), 0); 218 data->packet.size(), rtc::CreatePacketTime(0), 0);
218 delete data; 219 delete data;
219 } 220 }
220 221
221 bool SetLocalIdentity(rtc::SSLIdentity* identity) { 222 bool SetLocalCertificate(
222 identity_ = identity; 223 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) override {
224 certificate_ = certificate;
223 return true; 225 return true;
224 } 226 }
225 227
226 228 void SetRemoteSSLCertificate(rtc::FakeSSLCertificate* cert) {
227 void SetRemoteCertificate(rtc::FakeSSLCertificate* cert) {
228 remote_cert_ = cert; 229 remote_cert_ = cert;
229 } 230 }
230 231
231 virtual bool IsDtlsActive() const { 232 bool IsDtlsActive() const override {
232 return do_dtls_; 233 return do_dtls_;
233 } 234 }
234 235
235 virtual bool SetSrtpCiphers(const std::vector<std::string>& ciphers) { 236 bool SetSrtpCiphers(const std::vector<std::string>& ciphers) override {
236 srtp_ciphers_ = ciphers; 237 srtp_ciphers_ = ciphers;
237 return true; 238 return true;
238 } 239 }
239 240
240 virtual bool GetSrtpCipher(std::string* cipher) { 241 bool GetSrtpCipher(std::string* cipher) override {
241 if (!chosen_srtp_cipher_.empty()) { 242 if (!chosen_srtp_cipher_.empty()) {
242 *cipher = chosen_srtp_cipher_; 243 *cipher = chosen_srtp_cipher_;
243 return true; 244 return true;
244 } 245 }
245 return false; 246 return false;
246 } 247 }
247 248
248 virtual bool GetSslCipher(std::string* cipher) { 249 bool GetSslCipher(std::string* cipher) override {
249 return false; 250 return false;
250 } 251 }
251 252
252 virtual bool GetLocalIdentity(rtc::SSLIdentity** identity) const { 253 rtc::scoped_refptr<rtc::RTCCertificate>
253 if (!identity_) 254 GetLocalCertificate() const override {
254 return false; 255 return certificate_;
255
256 *identity = identity_->GetReference();
257 return true;
258 } 256 }
259 257
260 virtual bool GetRemoteCertificate(rtc::SSLCertificate** cert) const { 258 bool GetRemoteSSLCertificate(rtc::SSLCertificate** cert) const override {
261 if (!remote_cert_) 259 if (!remote_cert_)
262 return false; 260 return false;
263 261
264 *cert = remote_cert_->GetReference(); 262 *cert = remote_cert_->GetReference();
265 return true; 263 return true;
266 } 264 }
267 265
268 virtual bool ExportKeyingMaterial(const std::string& label, 266 bool ExportKeyingMaterial(const std::string& label,
269 const uint8* context, 267 const uint8* context,
270 size_t context_len, 268 size_t context_len,
271 bool use_context, 269 bool use_context,
272 uint8* result, 270 uint8* result,
273 size_t result_len) { 271 size_t result_len) override {
274 if (!chosen_srtp_cipher_.empty()) { 272 if (!chosen_srtp_cipher_.empty()) {
275 memset(result, 0xff, result_len); 273 memset(result, 0xff, result_len);
276 return true; 274 return true;
277 } 275 }
278 276
279 return false; 277 return false;
280 } 278 }
281 279
282 virtual void NegotiateSrtpCiphers() { 280 virtual void NegotiateSrtpCiphers() {
283 for (std::vector<std::string>::const_iterator it1 = srtp_ciphers_.begin(); 281 for (std::vector<std::string>::const_iterator it1 = srtp_ciphers_.begin();
(...skipping 16 matching lines...) Expand all
300 infos->push_back(info); 298 infos->push_back(info);
301 return true; 299 return true;
302 } 300 }
303 301
304 private: 302 private:
305 enum State { STATE_INIT, STATE_CONNECTING, STATE_CONNECTED }; 303 enum State { STATE_INIT, STATE_CONNECTING, STATE_CONNECTED };
306 Transport* transport_; 304 Transport* transport_;
307 FakeTransportChannel* dest_; 305 FakeTransportChannel* dest_;
308 State state_; 306 State state_;
309 bool async_; 307 bool async_;
310 rtc::SSLIdentity* identity_; 308 rtc::scoped_refptr<rtc::RTCCertificate> certificate_;
311 rtc::FakeSSLCertificate* remote_cert_; 309 rtc::FakeSSLCertificate* remote_cert_;
312 bool do_dtls_; 310 bool do_dtls_;
313 std::vector<std::string> srtp_ciphers_; 311 std::vector<std::string> srtp_ciphers_;
314 std::string chosen_srtp_cipher_; 312 std::string chosen_srtp_cipher_;
315 IceRole role_; 313 IceRole role_;
316 uint64 tiebreaker_; 314 uint64 tiebreaker_;
317 std::string ice_ufrag_; 315 std::string ice_ufrag_;
318 std::string ice_pwd_; 316 std::string ice_pwd_;
319 std::string remote_ice_ufrag_; 317 std::string remote_ice_ufrag_;
320 std::string remote_ice_pwd_; 318 std::string remote_ice_pwd_;
(...skipping 22 matching lines...) Expand all
343 DestroyAllChannels(); 341 DestroyAllChannels();
344 } 342 }
345 343
346 const ChannelMap& channels() const { return channels_; } 344 const ChannelMap& channels() const { return channels_; }
347 345
348 void SetAsync(bool async) { async_ = async; } 346 void SetAsync(bool async) { async_ = async; }
349 void SetDestination(FakeTransport* dest) { 347 void SetDestination(FakeTransport* dest) {
350 dest_ = dest; 348 dest_ = dest;
351 for (ChannelMap::iterator it = channels_.begin(); it != channels_.end(); 349 for (ChannelMap::iterator it = channels_.begin(); it != channels_.end();
352 ++it) { 350 ++it) {
353 // TODO(hbos): SetLocalCertificate 351 it->second->SetLocalCertificate(certificate_);
354 it->second->SetLocalIdentity(
355 certificate_ ? certificate_->identity() : nullptr);
356 SetChannelDestination(it->first, it->second); 352 SetChannelDestination(it->first, it->second);
357 } 353 }
358 } 354 }
359 355
360 void SetWritable(bool writable) { 356 void SetWritable(bool writable) {
361 for (ChannelMap::iterator it = channels_.begin(); it != channels_.end(); 357 for (ChannelMap::iterator it = channels_.begin(); it != channels_.end();
362 ++it) { 358 ++it) {
363 it->second->SetWritable(writable); 359 it->second->SetWritable(writable);
364 } 360 }
365 } 361 }
366 362
367 void set_certificate( 363 void set_certificate(
368 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) { 364 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) {
369 certificate_ = certificate; 365 certificate_ = certificate;
370 } 366 }
371 367
372 using Transport::local_description; 368 using Transport::local_description;
373 using Transport::remote_description; 369 using Transport::remote_description;
374 370
375 protected: 371 protected:
376 virtual TransportChannelImpl* CreateTransportChannel(int component) { 372 TransportChannelImpl* CreateTransportChannel(int component) override {
377 if (channels_.find(component) != channels_.end()) { 373 if (channels_.find(component) != channels_.end()) {
378 return NULL; 374 return NULL;
379 } 375 }
380 FakeTransportChannel* channel = 376 FakeTransportChannel* channel =
381 new FakeTransportChannel(this, content_name(), component); 377 new FakeTransportChannel(this, content_name(), component);
382 channel->SetAsync(async_); 378 channel->SetAsync(async_);
383 SetChannelDestination(component, channel); 379 SetChannelDestination(component, channel);
384 channels_[component] = channel; 380 channels_[component] = channel;
385 return channel; 381 return channel;
386 } 382 }
387 virtual void DestroyTransportChannel(TransportChannelImpl* channel) { 383 void DestroyTransportChannel(TransportChannelImpl* channel) override {
388 channels_.erase(channel->component()); 384 channels_.erase(channel->component());
389 delete channel; 385 delete channel;
390 } 386 }
391 void SetCertificate_w( 387 void SetCertificate_w(
392 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) override { 388 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) override {
393 certificate_ = certificate; 389 certificate_ = certificate;
394 } 390 }
395 bool GetCertificate_w( 391 bool GetCertificate_w(
396 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) override { 392 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) override {
397 if (!certificate_) 393 if (!certificate_)
398 return false; 394 return false;
399 395
400 *certificate = certificate_; 396 *certificate = certificate_;
401 return true; 397 return true;
402 } 398 }
403 399
404 private: 400 private:
405 FakeTransportChannel* GetFakeChannel(int component) { 401 FakeTransportChannel* GetFakeChannel(int component) {
406 ChannelMap::iterator it = channels_.find(component); 402 ChannelMap::iterator it = channels_.find(component);
407 return (it != channels_.end()) ? it->second : NULL; 403 return (it != channels_.end()) ? it->second : NULL;
408 } 404 }
409 void SetChannelDestination(int component, 405 void SetChannelDestination(int component,
410 FakeTransportChannel* channel) { 406 FakeTransportChannel* channel) {
411 FakeTransportChannel* dest_channel = NULL; 407 FakeTransportChannel* dest_channel = NULL;
412 if (dest_) { 408 if (dest_) {
413 dest_channel = dest_->GetFakeChannel(component); 409 dest_channel = dest_->GetFakeChannel(component);
414 if (dest_channel) { 410 if (dest_channel)
415 // TODO(hbos): SetLocalCertificate 411 dest_channel->SetLocalCertificate(dest_->certificate_);
416 dest_channel->SetLocalIdentity(
417 dest_->certificate_ ? dest_->certificate_->identity() : nullptr);
418 }
419 } 412 }
420 channel->SetDestination(dest_channel); 413 channel->SetDestination(dest_channel);
421 } 414 }
422 415
423 // Note, this is distinct from the Channel map owned by Transport. 416 // Note, this is distinct from the Channel map owned by Transport.
424 // This map just tracks the FakeTransportChannels created by this class. 417 // This map just tracks the FakeTransportChannels created by this class.
425 ChannelMap channels_; 418 ChannelMap channels_;
426 FakeTransport* dest_; 419 FakeTransport* dest_;
427 bool async_; 420 bool async_;
428 rtc::scoped_refptr<rtc::RTCCertificate> certificate_; 421 rtc::scoped_refptr<rtc::RTCCertificate> certificate_;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 // Simulate the exchange of candidates. 453 // Simulate the exchange of candidates.
461 CompleteNegotiation(); 454 CompleteNegotiation();
462 dest->CompleteNegotiation(); 455 dest->CompleteNegotiation();
463 for (TransportMap::const_iterator it = transport_proxies().begin(); 456 for (TransportMap::const_iterator it = transport_proxies().begin();
464 it != transport_proxies().end(); ++it) { 457 it != transport_proxies().end(); ++it) {
465 static_cast<FakeTransport*>(it->second->impl())->SetDestination( 458 static_cast<FakeTransport*>(it->second->impl())->SetDestination(
466 dest->GetTransport(it->first)); 459 dest->GetTransport(it->first));
467 } 460 }
468 } 461 }
469 462
470 virtual TransportChannel* CreateChannel( 463 TransportChannel* CreateChannel(const std::string& content_name,
471 const std::string& content_name, 464 int component) override {
472 int component) {
473 if (fail_create_channel_) { 465 if (fail_create_channel_) {
474 return NULL; 466 return NULL;
475 } 467 }
476 return BaseSession::CreateChannel(content_name, component); 468 return BaseSession::CreateChannel(content_name, component);
477 } 469 }
478 470
479 void set_fail_channel_creation(bool fail_channel_creation) { 471 void set_fail_channel_creation(bool fail_channel_creation) {
480 fail_create_channel_ = fail_channel_creation; 472 fail_create_channel_ = fail_channel_creation;
481 } 473 }
482 474
483 // TODO: Hoist this into Session when we re-work the Session code. 475 // TODO: Hoist this into Session when we re-work the Session code.
484 void set_ssl_rtccertificate( 476 void set_ssl_rtccertificate(
485 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) { 477 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) {
486 for (TransportMap::const_iterator it = transport_proxies().begin(); 478 for (TransportMap::const_iterator it = transport_proxies().begin();
487 it != transport_proxies().end(); ++it) { 479 it != transport_proxies().end(); ++it) {
488 // We know that we have a FakeTransport* 480 // We know that we have a FakeTransport*
489 481
490 static_cast<FakeTransport*>(it->second->impl())->set_certificate 482 static_cast<FakeTransport*>(it->second->impl())->set_certificate
491 (certificate); 483 (certificate);
492 } 484 }
493 } 485 }
494 486
495 protected: 487 protected:
496 virtual Transport* CreateTransport(const std::string& content_name) { 488 Transport* CreateTransport(const std::string& content_name) override {
497 return new FakeTransport(signaling_thread(), worker_thread(), content_name); 489 return new FakeTransport(signaling_thread(), worker_thread(), content_name);
498 } 490 }
499 491
500 void CompleteNegotiation() { 492 void CompleteNegotiation() {
501 for (TransportMap::const_iterator it = transport_proxies().begin(); 493 for (TransportMap::const_iterator it = transport_proxies().begin();
502 it != transport_proxies().end(); ++it) { 494 it != transport_proxies().end(); ++it) {
503 it->second->CompleteNegotiation(); 495 it->second->CompleteNegotiation();
504 it->second->ConnectChannels(); 496 it->second->ConnectChannels();
505 } 497 }
506 } 498 }
507 499
508 private: 500 private:
509 bool fail_create_channel_; 501 bool fail_create_channel_;
510 }; 502 };
511 503
512 } // namespace cricket 504 } // namespace cricket
513 505
514 #endif // WEBRTC_P2P_BASE_FAKESESSION_H_ 506 #endif // WEBRTC_P2P_BASE_FAKESESSION_H_
OLDNEW
« no previous file with comments | « webrtc/p2p/base/dtlstransportchannel_unittest.cc ('k') | webrtc/p2p/base/p2ptransportchannel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698