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

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

Issue 1207563002: Add flakiness check if there is no received packets in a certain period. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Address more comments Created 5 years, 5 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/session.cc ('k') | webrtc/p2p/base/transport.cc » ('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 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 } 46 }
47 47
48 namespace cricket { 48 namespace cricket {
49 49
50 class PortAllocator; 50 class PortAllocator;
51 class TransportChannel; 51 class TransportChannel;
52 class TransportChannelImpl; 52 class TransportChannelImpl;
53 53
54 typedef std::vector<Candidate> Candidates; 54 typedef std::vector<Candidate> Candidates;
55 55
56 // For "writable" and "readable", we need to differentiate between 56 // For "writable", "readable", and "receiving", we need to differentiate between
57 // none, all, and some. 57 // none, all, and some.
58 enum TransportState { 58 enum TransportState {
59 TRANSPORT_STATE_NONE = 0, 59 TRANSPORT_STATE_NONE = 0,
60 TRANSPORT_STATE_SOME, 60 TRANSPORT_STATE_SOME,
61 TRANSPORT_STATE_ALL 61 TRANSPORT_STATE_ALL
62 }; 62 };
63 63
64 // When checking transport state, we need to differentiate between
65 // "readable", "writable", or "receiving" check.
66 enum TransportStateType {
67 TRANSPORT_READABLE_STATE = 0,
68 TRANSPORT_WRITABLE_STATE,
69 TRANSPORT_RECEIVING_STATE
70 };
71
64 // Stats that we can return about the connections for a transport channel. 72 // Stats that we can return about the connections for a transport channel.
65 // TODO(hta): Rename to ConnectionStats 73 // TODO(hta): Rename to ConnectionStats
66 struct ConnectionInfo { 74 struct ConnectionInfo {
67 ConnectionInfo() 75 ConnectionInfo()
68 : best_connection(false), 76 : best_connection(false),
69 writable(false), 77 writable(false),
70 readable(false), 78 readable(false),
71 timeout(false), 79 timeout(false),
72 new_connection(false), 80 new_connection(false),
73 rtt(0), 81 rtt(0),
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 bool any_channels_writable() const { 173 bool any_channels_writable() const {
166 return (writable_ == TRANSPORT_STATE_SOME || 174 return (writable_ == TRANSPORT_STATE_SOME ||
167 writable_ == TRANSPORT_STATE_ALL); 175 writable_ == TRANSPORT_STATE_ALL);
168 } 176 }
169 bool all_channels_readable() const { 177 bool all_channels_readable() const {
170 return (readable_ == TRANSPORT_STATE_ALL); 178 return (readable_ == TRANSPORT_STATE_ALL);
171 } 179 }
172 bool all_channels_writable() const { 180 bool all_channels_writable() const {
173 return (writable_ == TRANSPORT_STATE_ALL); 181 return (writable_ == TRANSPORT_STATE_ALL);
174 } 182 }
183 bool any_channel_receiving() const {
184 return (receiving_ == TRANSPORT_STATE_SOME ||
185 receiving_ == TRANSPORT_STATE_ALL);
186 }
187
175 sigslot::signal1<Transport*> SignalReadableState; 188 sigslot::signal1<Transport*> SignalReadableState;
176 sigslot::signal1<Transport*> SignalWritableState; 189 sigslot::signal1<Transport*> SignalWritableState;
190 sigslot::signal1<Transport*> SignalReceivingState;
177 sigslot::signal1<Transport*> SignalCompleted; 191 sigslot::signal1<Transport*> SignalCompleted;
178 sigslot::signal1<Transport*> SignalFailed; 192 sigslot::signal1<Transport*> SignalFailed;
179 193
180 // Returns whether the client has requested the channels to connect. 194 // Returns whether the client has requested the channels to connect.
181 bool connect_requested() const { return connect_requested_; } 195 bool connect_requested() const { return connect_requested_; }
182 196
183 void SetIceRole(IceRole role); 197 void SetIceRole(IceRole role);
184 IceRole ice_role() const { return ice_role_; } 198 IceRole ice_role() const { return ice_role_; }
185 199
186 void SetIceTiebreaker(uint64 IceTiebreaker) { tiebreaker_ = IceTiebreaker; } 200 void SetIceTiebreaker(uint64 IceTiebreaker) { tiebreaker_ = IceTiebreaker; }
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 int ref_; 370 int ref_;
357 }; 371 };
358 372
359 // Candidate component => ChannelMapEntry 373 // Candidate component => ChannelMapEntry
360 typedef std::map<int, ChannelMapEntry> ChannelMap; 374 typedef std::map<int, ChannelMapEntry> ChannelMap;
361 375
362 // Called when the state of a channel changes. 376 // Called when the state of a channel changes.
363 void OnChannelReadableState(TransportChannel* channel); 377 void OnChannelReadableState(TransportChannel* channel);
364 void OnChannelWritableState(TransportChannel* channel); 378 void OnChannelWritableState(TransportChannel* channel);
365 379
380 // Called when the receiving state of a channel changes.
381 void OnChannelReceivingState(TransportChannel* channel);
382
366 // Called when a channel requests signaling. 383 // Called when a channel requests signaling.
367 void OnChannelRequestSignaling(TransportChannelImpl* channel); 384 void OnChannelRequestSignaling(TransportChannelImpl* channel);
368 385
369 // Called when a candidate is ready from remote peer. 386 // Called when a candidate is ready from remote peer.
370 void OnRemoteCandidate(const Candidate& candidate); 387 void OnRemoteCandidate(const Candidate& candidate);
371 // Called when a candidate is ready from channel. 388 // Called when a candidate is ready from channel.
372 void OnChannelCandidateReady(TransportChannelImpl* channel, 389 void OnChannelCandidateReady(TransportChannelImpl* channel,
373 const Candidate& candidate); 390 const Candidate& candidate);
374 void OnChannelRouteChange(TransportChannel* channel, 391 void OnChannelRouteChange(TransportChannel* channel,
375 const Candidate& remote_candidate); 392 const Candidate& remote_candidate);
(...skipping 10 matching lines...) Expand all
386 // particular thread (s = signaling, w = worker). The above methods post or 403 // particular thread (s = signaling, w = worker). The above methods post or
387 // send a message to invoke this version. 404 // send a message to invoke this version.
388 TransportChannelImpl* CreateChannel_w(int component); 405 TransportChannelImpl* CreateChannel_w(int component);
389 void DestroyChannel_w(int component); 406 void DestroyChannel_w(int component);
390 void ConnectChannels_w(); 407 void ConnectChannels_w();
391 void ResetChannels_w(); 408 void ResetChannels_w();
392 void DestroyAllChannels_w(); 409 void DestroyAllChannels_w();
393 void OnRemoteCandidate_w(const Candidate& candidate); 410 void OnRemoteCandidate_w(const Candidate& candidate);
394 void OnChannelReadableState_s(); 411 void OnChannelReadableState_s();
395 void OnChannelWritableState_s(); 412 void OnChannelWritableState_s();
413 void OnChannelReceivingState_s();
396 void OnChannelRequestSignaling_s(); 414 void OnChannelRequestSignaling_s();
397 void OnConnecting_s(); 415 void OnConnecting_s();
398 void OnChannelRouteChange_s(const TransportChannel* channel, 416 void OnChannelRouteChange_s(const TransportChannel* channel,
399 const Candidate& remote_candidate); 417 const Candidate& remote_candidate);
400 void OnChannelCandidatesAllocationDone_s(); 418 void OnChannelCandidatesAllocationDone_s();
401 419
402 // Helper function that invokes the given function on every channel. 420 // Helper function that invokes the given function on every channel.
403 typedef void (TransportChannelImpl::* TransportChannelFunc)(); 421 typedef void (TransportChannelImpl::* TransportChannelFunc)();
404 void CallChannels_w(TransportChannelFunc func); 422 void CallChannels_w(TransportChannelFunc func);
405 423
406 // Computes the OR of the channel's read or write state (argument picks). 424 // Computes the AND and OR of the channel's read/write/receiving state
407 TransportState GetTransportState_s(bool read); 425 // (argument picks the operation).
426 TransportState GetTransportState_s(TransportStateType type);
408 427
409 void OnChannelCandidateReady_s(); 428 void OnChannelCandidateReady_s();
410 429
411 void SetIceRole_w(IceRole role); 430 void SetIceRole_w(IceRole role);
412 void SetRemoteIceMode_w(IceMode mode); 431 void SetRemoteIceMode_w(IceMode mode);
413 bool SetLocalTransportDescription_w(const TransportDescription& desc, 432 bool SetLocalTransportDescription_w(const TransportDescription& desc,
414 ContentAction action, 433 ContentAction action,
415 std::string* error_desc); 434 std::string* error_desc);
416 bool SetRemoteTransportDescription_w(const TransportDescription& desc, 435 bool SetRemoteTransportDescription_w(const TransportDescription& desc,
417 ContentAction action, 436 ContentAction action,
418 std::string* error_desc); 437 std::string* error_desc);
419 bool GetStats_w(TransportStats* infos); 438 bool GetStats_w(TransportStats* infos);
420 bool GetRemoteCertificate_w(rtc::SSLCertificate** cert); 439 bool GetRemoteCertificate_w(rtc::SSLCertificate** cert);
421 440
422 // Sends SignalCompleted if we are now in that state. 441 // Sends SignalCompleted if we are now in that state.
423 void MaybeCompleted_w(); 442 void MaybeCompleted_w();
424 443
425 rtc::Thread* const signaling_thread_; 444 rtc::Thread* const signaling_thread_;
426 rtc::Thread* const worker_thread_; 445 rtc::Thread* const worker_thread_;
427 const std::string content_name_; 446 const std::string content_name_;
428 const std::string type_; 447 const std::string type_;
429 PortAllocator* const allocator_; 448 PortAllocator* const allocator_;
430 bool destroyed_; 449 bool destroyed_;
431 TransportState readable_; 450 TransportState readable_;
432 TransportState writable_; 451 TransportState writable_;
452 TransportState receiving_;
433 bool was_writable_; 453 bool was_writable_;
434 bool connect_requested_; 454 bool connect_requested_;
435 IceRole ice_role_; 455 IceRole ice_role_;
436 uint64 tiebreaker_; 456 uint64 tiebreaker_;
437 TransportProtocol protocol_; 457 TransportProtocol protocol_;
438 IceMode remote_ice_mode_; 458 IceMode remote_ice_mode_;
439 rtc::scoped_ptr<TransportDescription> local_description_; 459 rtc::scoped_ptr<TransportDescription> local_description_;
440 rtc::scoped_ptr<TransportDescription> remote_description_; 460 rtc::scoped_ptr<TransportDescription> remote_description_;
441 461
442 // TODO(tommi): Make sure we only use this on the worker thread. 462 // TODO(tommi): Make sure we only use this on the worker thread.
443 ChannelMap channels_; 463 ChannelMap channels_;
444 // Buffers the ready_candidates so that SignalCanidatesReady can 464 // Buffers the ready_candidates so that SignalCanidatesReady can
445 // provide them in multiples. 465 // provide them in multiples.
446 std::vector<Candidate> ready_candidates_; 466 std::vector<Candidate> ready_candidates_;
447 // Protects changes to channels and messages 467 // Protects changes to channels and messages
448 rtc::CriticalSection crit_; 468 rtc::CriticalSection crit_;
449 469
450 DISALLOW_COPY_AND_ASSIGN(Transport); 470 DISALLOW_COPY_AND_ASSIGN(Transport);
451 }; 471 };
452 472
453 // Extract a TransportProtocol from a TransportDescription. 473 // Extract a TransportProtocol from a TransportDescription.
454 TransportProtocol TransportProtocolFromDescription( 474 TransportProtocol TransportProtocolFromDescription(
455 const TransportDescription* desc); 475 const TransportDescription* desc);
456 476
457 } // namespace cricket 477 } // namespace cricket
458 478
459 #endif // WEBRTC_P2P_BASE_TRANSPORT_H_ 479 #endif // WEBRTC_P2P_BASE_TRANSPORT_H_
OLDNEW
« no previous file with comments | « webrtc/p2p/base/session.cc ('k') | webrtc/p2p/base/transport.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698