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

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

Issue 1356103002: Revert of Replace readable with receiving where receiving means receiving anything (stun ping, response or da… (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: 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/port_unittest.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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 } 47 }
48 48
49 namespace cricket { 49 namespace cricket {
50 50
51 class PortAllocator; 51 class PortAllocator;
52 class TransportChannel; 52 class TransportChannel;
53 class TransportChannelImpl; 53 class TransportChannelImpl;
54 54
55 typedef std::vector<Candidate> Candidates; 55 typedef std::vector<Candidate> Candidates;
56 56
57 // For "writable" and "receiving", we need to differentiate between 57 // For "writable", "readable", and "receiving", we need to differentiate between
58 // none, all, and some. 58 // none, all, and some.
59 enum TransportState { 59 enum TransportState {
60 TRANSPORT_STATE_NONE = 0, 60 TRANSPORT_STATE_NONE = 0,
61 TRANSPORT_STATE_SOME, 61 TRANSPORT_STATE_SOME,
62 TRANSPORT_STATE_ALL 62 TRANSPORT_STATE_ALL
63 }; 63 };
64 64
65 // When checking transport state, we need to differentiate between 65 // When checking transport state, we need to differentiate between
66 // "writable" or "receiving" check. 66 // "readable", "writable", or "receiving" check.
67 enum TransportStateType { 67 enum TransportStateType {
68 TRANSPORT_WRITABLE_STATE = 0, 68 TRANSPORT_READABLE_STATE = 0,
69 TRANSPORT_WRITABLE_STATE,
69 TRANSPORT_RECEIVING_STATE 70 TRANSPORT_RECEIVING_STATE
70 }; 71 };
71 72
72 // Stats that we can return about the connections for a transport channel. 73 // Stats that we can return about the connections for a transport channel.
73 // TODO(hta): Rename to ConnectionStats 74 // TODO(hta): Rename to ConnectionStats
74 struct ConnectionInfo { 75 struct ConnectionInfo {
75 ConnectionInfo() 76 ConnectionInfo()
76 : best_connection(false), 77 : best_connection(false),
77 writable(false), 78 writable(false),
78 receiving(false), 79 readable(false),
79 timeout(false), 80 timeout(false),
80 new_connection(false), 81 new_connection(false),
81 rtt(0), 82 rtt(0),
82 sent_total_bytes(0), 83 sent_total_bytes(0),
83 sent_bytes_second(0), 84 sent_bytes_second(0),
84 sent_discarded_packets(0), 85 sent_discarded_packets(0),
85 sent_total_packets(0), 86 sent_total_packets(0),
86 recv_total_bytes(0), 87 recv_total_bytes(0),
87 recv_bytes_second(0), 88 recv_bytes_second(0),
88 key(NULL) {} 89 key(NULL) {}
89 90
90 bool best_connection; // Is this the best connection we have? 91 bool best_connection; // Is this the best connection we have?
91 bool writable; // Has this connection received a STUN response? 92 bool writable; // Has this connection received a STUN response?
92 bool receiving; // Has this connection received anything? 93 bool readable; // Has this connection received a STUN request?
93 bool timeout; // Has this connection timed out? 94 bool timeout; // Has this connection timed out?
94 bool new_connection; // Is this a newly created connection? 95 bool new_connection; // Is this a newly created connection?
95 size_t rtt; // The STUN RTT for this connection. 96 size_t rtt; // The STUN RTT for this connection.
96 size_t sent_total_bytes; // Total bytes sent on this connection. 97 size_t sent_total_bytes; // Total bytes sent on this connection.
97 size_t sent_bytes_second; // Bps over the last measurement interval. 98 size_t sent_bytes_second; // Bps over the last measurement interval.
98 size_t sent_discarded_packets; // Number of outgoing packets discarded due to 99 size_t sent_discarded_packets; // Number of outgoing packets discarded due to
99 // socket errors. 100 // socket errors.
100 size_t sent_total_packets; // Number of total outgoing packets attempted for 101 size_t sent_total_packets; // Number of total outgoing packets attempted for
101 // sending. 102 // sending.
102 103
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 rtc::Thread* signaling_thread() const { return signaling_thread_; } 149 rtc::Thread* signaling_thread() const { return signaling_thread_; }
149 // Returns the worker thread. The actual networking is done on this thread. 150 // Returns the worker thread. The actual networking is done on this thread.
150 rtc::Thread* worker_thread() const { return worker_thread_; } 151 rtc::Thread* worker_thread() const { return worker_thread_; }
151 152
152 // Returns the content_name of this transport. 153 // Returns the content_name of this transport.
153 const std::string& content_name() const { return content_name_; } 154 const std::string& content_name() const { return content_name_; }
154 155
155 // Returns the port allocator object for this transport. 156 // Returns the port allocator object for this transport.
156 PortAllocator* port_allocator() { return allocator_; } 157 PortAllocator* port_allocator() { return allocator_; }
157 158
158 // Returns the states of this manager. These bits are the ORs 159 // Returns the readable and states of this manager. These bits are the ORs
159 // of the corresponding bits on the managed channels. Each time one of these 160 // of the corresponding bits on the managed channels. Each time one of these
160 // states changes, a signal is raised. 161 // states changes, a signal is raised.
161 // TODO(honghaiz): Replace uses of writable() with any_channels_writable(). 162 // TODO: Replace uses of readable() and writable() with
163 // any_channels_readable() and any_channels_writable().
164 bool readable() const { return any_channels_readable(); }
162 bool writable() const { return any_channels_writable(); } 165 bool writable() const { return any_channels_writable(); }
163 bool was_writable() const { return was_writable_; } 166 bool was_writable() const { return was_writable_; }
167 bool any_channels_readable() const {
168 return (readable_ == TRANSPORT_STATE_SOME ||
169 readable_ == TRANSPORT_STATE_ALL);
170 }
164 bool any_channels_writable() const { 171 bool any_channels_writable() const {
165 return (writable_ == TRANSPORT_STATE_SOME || 172 return (writable_ == TRANSPORT_STATE_SOME ||
166 writable_ == TRANSPORT_STATE_ALL); 173 writable_ == TRANSPORT_STATE_ALL);
167 } 174 }
175 bool all_channels_readable() const {
176 return (readable_ == TRANSPORT_STATE_ALL);
177 }
168 bool all_channels_writable() const { 178 bool all_channels_writable() const {
169 return (writable_ == TRANSPORT_STATE_ALL); 179 return (writable_ == TRANSPORT_STATE_ALL);
170 } 180 }
171 bool any_channel_receiving() const { 181 bool any_channel_receiving() const {
172 return (receiving_ == TRANSPORT_STATE_SOME || 182 return (receiving_ == TRANSPORT_STATE_SOME ||
173 receiving_ == TRANSPORT_STATE_ALL); 183 receiving_ == TRANSPORT_STATE_ALL);
174 } 184 }
175 185
186 sigslot::signal1<Transport*> SignalReadableState;
176 sigslot::signal1<Transport*> SignalWritableState; 187 sigslot::signal1<Transport*> SignalWritableState;
177 sigslot::signal1<Transport*> SignalReceivingState; 188 sigslot::signal1<Transport*> SignalReceivingState;
178 sigslot::signal1<Transport*> SignalCompleted; 189 sigslot::signal1<Transport*> SignalCompleted;
179 sigslot::signal1<Transport*> SignalFailed; 190 sigslot::signal1<Transport*> SignalFailed;
180 191
181 // Returns whether the client has requested the channels to connect. 192 // Returns whether the client has requested the channels to connect.
182 bool connect_requested() const { return connect_requested_; } 193 bool connect_requested() const { return connect_requested_; }
183 194
184 void SetIceRole(IceRole role); 195 void SetIceRole(IceRole role);
185 IceRole ice_role() const { return ice_role_; } 196 IceRole ice_role() const { return ice_role_; }
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 367
357 private: 368 private:
358 TransportChannelImpl *impl_; 369 TransportChannelImpl *impl_;
359 bool candidates_allocated_; 370 bool candidates_allocated_;
360 int ref_; 371 int ref_;
361 }; 372 };
362 373
363 // Candidate component => ChannelMapEntry 374 // Candidate component => ChannelMapEntry
364 typedef std::map<int, ChannelMapEntry> ChannelMap; 375 typedef std::map<int, ChannelMapEntry> ChannelMap;
365 376
366 // Called when the write state of a channel changes. 377 // Called when the state of a channel changes.
378 void OnChannelReadableState(TransportChannel* channel);
367 void OnChannelWritableState(TransportChannel* channel); 379 void OnChannelWritableState(TransportChannel* channel);
368 380
369 // Called when the receiving state of a channel changes. 381 // Called when the receiving state of a channel changes.
370 void OnChannelReceivingState(TransportChannel* channel); 382 void OnChannelReceivingState(TransportChannel* channel);
371 383
372 // Called when a channel requests signaling. 384 // Called when a channel requests signaling.
373 void OnChannelRequestSignaling(TransportChannelImpl* channel); 385 void OnChannelRequestSignaling(TransportChannelImpl* channel);
374 386
375 // Called when a candidate is ready from remote peer. 387 // Called when a candidate is ready from remote peer.
376 void OnRemoteCandidate(const Candidate& candidate); 388 void OnRemoteCandidate(const Candidate& candidate);
(...skipping 13 matching lines...) Expand all
390 402
391 // These are versions of the above methods that are called only on a 403 // These are versions of the above methods that are called only on a
392 // particular thread (s = signaling, w = worker). The above methods post or 404 // particular thread (s = signaling, w = worker). The above methods post or
393 // send a message to invoke this version. 405 // send a message to invoke this version.
394 TransportChannelImpl* CreateChannel_w(int component); 406 TransportChannelImpl* CreateChannel_w(int component);
395 void DestroyChannel_w(int component); 407 void DestroyChannel_w(int component);
396 void ConnectChannels_w(); 408 void ConnectChannels_w();
397 void ResetChannels_w(); 409 void ResetChannels_w();
398 void DestroyAllChannels_w(); 410 void DestroyAllChannels_w();
399 void OnRemoteCandidate_w(const Candidate& candidate); 411 void OnRemoteCandidate_w(const Candidate& candidate);
412 void OnChannelReadableState_s();
400 void OnChannelWritableState_s(); 413 void OnChannelWritableState_s();
401 void OnChannelReceivingState_s(); 414 void OnChannelReceivingState_s();
402 void OnChannelRequestSignaling_s(); 415 void OnChannelRequestSignaling_s();
403 void OnConnecting_s(); 416 void OnConnecting_s();
404 void OnChannelRouteChange_s(const TransportChannel* channel, 417 void OnChannelRouteChange_s(const TransportChannel* channel,
405 const Candidate& remote_candidate); 418 const Candidate& remote_candidate);
406 void OnChannelCandidatesAllocationDone_s(); 419 void OnChannelCandidatesAllocationDone_s();
407 420
408 // Helper function that invokes the given function on every channel. 421 // Helper function that invokes the given function on every channel.
409 typedef void (TransportChannelImpl::* TransportChannelFunc)(); 422 typedef void (TransportChannelImpl::* TransportChannelFunc)();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 // Protects changes to channels and messages 469 // Protects changes to channels and messages
457 rtc::CriticalSection crit_; 470 rtc::CriticalSection crit_;
458 471
459 RTC_DISALLOW_COPY_AND_ASSIGN(Transport); 472 RTC_DISALLOW_COPY_AND_ASSIGN(Transport);
460 }; 473 };
461 474
462 475
463 } // namespace cricket 476 } // namespace cricket
464 477
465 #endif // WEBRTC_P2P_BASE_TRANSPORT_H_ 478 #endif // WEBRTC_P2P_BASE_TRANSPORT_H_
OLDNEW
« no previous file with comments | « webrtc/p2p/base/port_unittest.cc ('k') | webrtc/p2p/base/transport.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698