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

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

Issue 1362503003: Use suffixed {uint,int}{8,16,32,64}_t types. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase + revert basictypes.h (to be landed separately just in case of a revert due to unexpected us… Created 5 years, 2 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/packetsocketfactory.h ('k') | webrtc/p2p/base/port.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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 extern const char SSLTCP_PROTOCOL_NAME[]; 45 extern const char SSLTCP_PROTOCOL_NAME[];
46 46
47 // RFC 6544, TCP candidate encoding rules. 47 // RFC 6544, TCP candidate encoding rules.
48 extern const int DISCARD_PORT; 48 extern const int DISCARD_PORT;
49 extern const char TCPTYPE_ACTIVE_STR[]; 49 extern const char TCPTYPE_ACTIVE_STR[];
50 extern const char TCPTYPE_PASSIVE_STR[]; 50 extern const char TCPTYPE_PASSIVE_STR[];
51 extern const char TCPTYPE_SIMOPEN_STR[]; 51 extern const char TCPTYPE_SIMOPEN_STR[];
52 52
53 // The minimum time we will wait before destroying a connection after creating 53 // The minimum time we will wait before destroying a connection after creating
54 // it. 54 // it.
55 const uint32 MIN_CONNECTION_LIFETIME = 10 * 1000; // 10 seconds. 55 const uint32_t MIN_CONNECTION_LIFETIME = 10 * 1000; // 10 seconds.
56 56
57 // The timeout duration when a connection does not receive anything. 57 // The timeout duration when a connection does not receive anything.
58 const uint32 WEAK_CONNECTION_RECEIVE_TIMEOUT = 2500; // 2.5 seconds 58 const uint32_t WEAK_CONNECTION_RECEIVE_TIMEOUT = 2500; // 2.5 seconds
59 59
60 // The length of time we wait before timing out writability on a connection. 60 // The length of time we wait before timing out writability on a connection.
61 const uint32 CONNECTION_WRITE_TIMEOUT = 15 * 1000; // 15 seconds 61 const uint32_t CONNECTION_WRITE_TIMEOUT = 15 * 1000; // 15 seconds
62 62
63 // The length of time we wait before we become unwritable. 63 // The length of time we wait before we become unwritable.
64 const uint32 CONNECTION_WRITE_CONNECT_TIMEOUT = 5 * 1000; // 5 seconds 64 const uint32_t CONNECTION_WRITE_CONNECT_TIMEOUT = 5 * 1000; // 5 seconds
65 65
66 // The number of pings that must fail to respond before we become unwritable. 66 // The number of pings that must fail to respond before we become unwritable.
67 const uint32 CONNECTION_WRITE_CONNECT_FAILURES = 5; 67 const uint32_t CONNECTION_WRITE_CONNECT_FAILURES = 5;
68 68
69 // This is the length of time that we wait for a ping response to come back. 69 // This is the length of time that we wait for a ping response to come back.
70 const int CONNECTION_RESPONSE_TIMEOUT = 5 * 1000; // 5 seconds 70 const int CONNECTION_RESPONSE_TIMEOUT = 5 * 1000; // 5 seconds
71 71
72 enum RelayType { 72 enum RelayType {
73 RELAY_GTURN, // Legacy google relay service. 73 RELAY_GTURN, // Legacy google relay service.
74 RELAY_TURN // Standard (TURN) relay service. 74 RELAY_TURN // Standard (TURN) relay service.
75 }; 75 };
76 76
77 enum IcePriorityValue { 77 enum IcePriorityValue {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 rtc::PacketSocketFactory* factory, 115 rtc::PacketSocketFactory* factory,
116 rtc::Network* network, 116 rtc::Network* network,
117 const rtc::IPAddress& ip, 117 const rtc::IPAddress& ip,
118 const std::string& username_fragment, 118 const std::string& username_fragment,
119 const std::string& password); 119 const std::string& password);
120 Port(rtc::Thread* thread, 120 Port(rtc::Thread* thread,
121 const std::string& type, 121 const std::string& type,
122 rtc::PacketSocketFactory* factory, 122 rtc::PacketSocketFactory* factory,
123 rtc::Network* network, 123 rtc::Network* network,
124 const rtc::IPAddress& ip, 124 const rtc::IPAddress& ip,
125 uint16 min_port, 125 uint16_t min_port,
126 uint16 max_port, 126 uint16_t max_port,
127 const std::string& username_fragment, 127 const std::string& username_fragment,
128 const std::string& password); 128 const std::string& password);
129 virtual ~Port(); 129 virtual ~Port();
130 130
131 virtual const std::string& Type() const { return type_; } 131 virtual const std::string& Type() const { return type_; }
132 virtual rtc::Network* Network() const { return network_; } 132 virtual rtc::Network* Network() const { return network_; }
133 133
134 // Methods to set/get ICE role and tiebreaker values. 134 // Methods to set/get ICE role and tiebreaker values.
135 IceRole GetIceRole() const { return ice_role_; } 135 IceRole GetIceRole() const { return ice_role_; }
136 void SetIceRole(IceRole role) { ice_role_ = role; } 136 void SetIceRole(IceRole role) { ice_role_ = role; }
137 137
138 void SetIceTiebreaker(uint64 tiebreaker) { tiebreaker_ = tiebreaker; } 138 void SetIceTiebreaker(uint64_t tiebreaker) { tiebreaker_ = tiebreaker; }
139 uint64 IceTiebreaker() const { return tiebreaker_; } 139 uint64_t IceTiebreaker() const { return tiebreaker_; }
140 140
141 virtual bool SharedSocket() const { return shared_socket_; } 141 virtual bool SharedSocket() const { return shared_socket_; }
142 void ResetSharedSocket() { shared_socket_ = false; } 142 void ResetSharedSocket() { shared_socket_ = false; }
143 143
144 // The thread on which this port performs its I/O. 144 // The thread on which this port performs its I/O.
145 rtc::Thread* thread() { return thread_; } 145 rtc::Thread* thread() { return thread_; }
146 146
147 // The factory used to create the sockets of this port. 147 // The factory used to create the sockets of this port.
148 rtc::PacketSocketFactory* socket_factory() const { return factory_; } 148 rtc::PacketSocketFactory* socket_factory() const { return factory_; }
149 void set_socket_factory(rtc::PacketSocketFactory* factory) { 149 void set_socket_factory(rtc::PacketSocketFactory* factory) {
(...skipping 10 matching lines...) Expand all
160 void set_component(int component) { component_ = component; } 160 void set_component(int component) { component_ = component; }
161 161
162 bool send_retransmit_count_attribute() const { 162 bool send_retransmit_count_attribute() const {
163 return send_retransmit_count_attribute_; 163 return send_retransmit_count_attribute_;
164 } 164 }
165 void set_send_retransmit_count_attribute(bool enable) { 165 void set_send_retransmit_count_attribute(bool enable) {
166 send_retransmit_count_attribute_ = enable; 166 send_retransmit_count_attribute_ = enable;
167 } 167 }
168 168
169 // Identifies the generation that this port was created in. 169 // Identifies the generation that this port was created in.
170 uint32 generation() { return generation_; } 170 uint32_t generation() { return generation_; }
171 void set_generation(uint32 generation) { generation_ = generation; } 171 void set_generation(uint32_t generation) { generation_ = generation; }
172 172
173 // ICE requires a single username/password per content/media line. So the 173 // ICE requires a single username/password per content/media line. So the
174 // |ice_username_fragment_| of the ports that belongs to the same content will 174 // |ice_username_fragment_| of the ports that belongs to the same content will
175 // be the same. However this causes a small complication with our relay 175 // be the same. However this causes a small complication with our relay
176 // server, which expects different username for RTP and RTCP. 176 // server, which expects different username for RTP and RTCP.
177 // 177 //
178 // To resolve this problem, we implemented the username_fragment(), 178 // To resolve this problem, we implemented the username_fragment(),
179 // which returns a different username (calculated from 179 // which returns a different username (calculated from
180 // |ice_username_fragment_|) for RTCP in the case of ICEPROTO_GOOGLE. And the 180 // |ice_username_fragment_|) for RTCP in the case of ICEPROTO_GOOGLE. And the
181 // username_fragment() simply returns |ice_username_fragment_| when running 181 // username_fragment() simply returns |ice_username_fragment_| when running
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 virtual void EnablePortPackets(); 250 virtual void EnablePortPackets();
251 251
252 // Called if the port has no connections and is no longer useful. 252 // Called if the port has no connections and is no longer useful.
253 void Destroy(); 253 void Destroy();
254 254
255 virtual void OnMessage(rtc::Message *pmsg); 255 virtual void OnMessage(rtc::Message *pmsg);
256 256
257 // Debugging description of this port 257 // Debugging description of this port
258 virtual std::string ToString() const; 258 virtual std::string ToString() const;
259 const rtc::IPAddress& ip() const { return ip_; } 259 const rtc::IPAddress& ip() const { return ip_; }
260 uint16 min_port() { return min_port_; } 260 uint16_t min_port() { return min_port_; }
261 uint16 max_port() { return max_port_; } 261 uint16_t max_port() { return max_port_; }
262 262
263 // Timeout shortening function to speed up unit tests. 263 // Timeout shortening function to speed up unit tests.
264 void set_timeout_delay(int delay) { timeout_delay_ = delay; } 264 void set_timeout_delay(int delay) { timeout_delay_ = delay; }
265 265
266 // This method will return local and remote username fragements from the 266 // This method will return local and remote username fragements from the
267 // stun username attribute if present. 267 // stun username attribute if present.
268 bool ParseStunUsername(const StunMessage* stun_msg, 268 bool ParseStunUsername(const StunMessage* stun_msg,
269 std::string* local_username, 269 std::string* local_username,
270 std::string* remote_username) const; 270 std::string* remote_username) const;
271 void CreateStunUsername(const std::string& remote_username, 271 void CreateStunUsername(const std::string& remote_username,
272 std::string* stun_username_attr_str) const; 272 std::string* stun_username_attr_str) const;
273 273
274 bool MaybeIceRoleConflict(const rtc::SocketAddress& addr, 274 bool MaybeIceRoleConflict(const rtc::SocketAddress& addr,
275 IceMessage* stun_msg, 275 IceMessage* stun_msg,
276 const std::string& remote_ufrag); 276 const std::string& remote_ufrag);
277 277
278 // Called when the socket is currently able to send. 278 // Called when the socket is currently able to send.
279 void OnReadyToSend(); 279 void OnReadyToSend();
280 280
281 // Called when the Connection discovers a local peer reflexive candidate. 281 // Called when the Connection discovers a local peer reflexive candidate.
282 // Returns the index of the new local candidate. 282 // Returns the index of the new local candidate.
283 size_t AddPrflxCandidate(const Candidate& local); 283 size_t AddPrflxCandidate(const Candidate& local);
284 284
285 void set_candidate_filter(uint32 candidate_filter) { 285 void set_candidate_filter(uint32_t candidate_filter) {
286 candidate_filter_ = candidate_filter; 286 candidate_filter_ = candidate_filter;
287 } 287 }
288 288
289 protected: 289 protected:
290 enum { 290 enum {
291 MSG_DEAD = 0, 291 MSG_DEAD = 0,
292 MSG_FIRST_AVAILABLE 292 MSG_FIRST_AVAILABLE
293 }; 293 };
294 294
295 void set_type(const std::string& type) { type_ = type; } 295 void set_type(const std::string& type) { type_ = type; }
296 296
297 void AddAddress(const rtc::SocketAddress& address, 297 void AddAddress(const rtc::SocketAddress& address,
298 const rtc::SocketAddress& base_address, 298 const rtc::SocketAddress& base_address,
299 const rtc::SocketAddress& related_address, 299 const rtc::SocketAddress& related_address,
300 const std::string& protocol, 300 const std::string& protocol,
301 const std::string& relay_protocol, 301 const std::string& relay_protocol,
302 const std::string& tcptype, 302 const std::string& tcptype,
303 const std::string& type, 303 const std::string& type,
304 uint32 type_preference, 304 uint32_t type_preference,
305 uint32 relay_preference, 305 uint32_t relay_preference,
306 bool final); 306 bool final);
307 307
308 // Adds the given connection to the list. (Deleting removes them.) 308 // Adds the given connection to the list. (Deleting removes them.)
309 void AddConnection(Connection* conn); 309 void AddConnection(Connection* conn);
310 310
311 // Called when a packet is received from an unknown address that is not 311 // Called when a packet is received from an unknown address that is not
312 // currently a connection. If this is an authenticated STUN binding request, 312 // currently a connection. If this is an authenticated STUN binding request,
313 // then we will signal the client. 313 // then we will signal the client.
314 void OnReadPacket(const char* data, size_t size, 314 void OnReadPacket(const char* data, size_t size,
315 const rtc::SocketAddress& addr, 315 const rtc::SocketAddress& addr,
(...skipping 10 matching lines...) Expand all
326 326
327 // Checks if the address in addr is compatible with the port's ip. 327 // Checks if the address in addr is compatible with the port's ip.
328 bool IsCompatibleAddress(const rtc::SocketAddress& addr); 328 bool IsCompatibleAddress(const rtc::SocketAddress& addr);
329 329
330 // Returns default DSCP value. 330 // Returns default DSCP value.
331 rtc::DiffServCodePoint DefaultDscpValue() const { 331 rtc::DiffServCodePoint DefaultDscpValue() const {
332 // No change from what MediaChannel set. 332 // No change from what MediaChannel set.
333 return rtc::DSCP_NO_CHANGE; 333 return rtc::DSCP_NO_CHANGE;
334 } 334 }
335 335
336 uint32 candidate_filter() { return candidate_filter_; } 336 uint32_t candidate_filter() { return candidate_filter_; }
337 337
338 private: 338 private:
339 void Construct(); 339 void Construct();
340 // Called when one of our connections deletes itself. 340 // Called when one of our connections deletes itself.
341 void OnConnectionDestroyed(Connection* conn); 341 void OnConnectionDestroyed(Connection* conn);
342 342
343 // Whether this port is dead, and hence, should be destroyed on the controlled 343 // Whether this port is dead, and hence, should be destroyed on the controlled
344 // side. 344 // side.
345 bool dead() const { 345 bool dead() const {
346 return ice_role_ == ICEROLE_CONTROLLED && connections_.empty(); 346 return ice_role_ == ICEROLE_CONTROLLED && connections_.empty();
347 } 347 }
348 348
349 rtc::Thread* thread_; 349 rtc::Thread* thread_;
350 rtc::PacketSocketFactory* factory_; 350 rtc::PacketSocketFactory* factory_;
351 std::string type_; 351 std::string type_;
352 bool send_retransmit_count_attribute_; 352 bool send_retransmit_count_attribute_;
353 rtc::Network* network_; 353 rtc::Network* network_;
354 rtc::IPAddress ip_; 354 rtc::IPAddress ip_;
355 uint16 min_port_; 355 uint16_t min_port_;
356 uint16 max_port_; 356 uint16_t max_port_;
357 std::string content_name_; 357 std::string content_name_;
358 int component_; 358 int component_;
359 uint32 generation_; 359 uint32_t generation_;
360 // In order to establish a connection to this Port (so that real data can be 360 // In order to establish a connection to this Port (so that real data can be
361 // sent through), the other side must send us a STUN binding request that is 361 // sent through), the other side must send us a STUN binding request that is
362 // authenticated with this username_fragment and password. 362 // authenticated with this username_fragment and password.
363 // PortAllocatorSession will provide these username_fragment and password. 363 // PortAllocatorSession will provide these username_fragment and password.
364 // 364 //
365 // Note: we should always use username_fragment() instead of using 365 // Note: we should always use username_fragment() instead of using
366 // |ice_username_fragment_| directly. For the details see the comment on 366 // |ice_username_fragment_| directly. For the details see the comment on
367 // username_fragment(). 367 // username_fragment().
368 std::string ice_username_fragment_; 368 std::string ice_username_fragment_;
369 std::string password_; 369 std::string password_;
370 std::vector<Candidate> candidates_; 370 std::vector<Candidate> candidates_;
371 AddressMap connections_; 371 AddressMap connections_;
372 int timeout_delay_; 372 int timeout_delay_;
373 bool enable_port_packets_; 373 bool enable_port_packets_;
374 IceRole ice_role_; 374 IceRole ice_role_;
375 uint64 tiebreaker_; 375 uint64_t tiebreaker_;
376 bool shared_socket_; 376 bool shared_socket_;
377 // Information to use when going through a proxy. 377 // Information to use when going through a proxy.
378 std::string user_agent_; 378 std::string user_agent_;
379 rtc::ProxyInfo proxy_; 379 rtc::ProxyInfo proxy_;
380 380
381 // Candidate filter is pushed down to Port such that each Port could 381 // Candidate filter is pushed down to Port such that each Port could
382 // make its own decision on how to create candidates. For example, 382 // make its own decision on how to create candidates. For example,
383 // when IceTransportsType is set to relay, both RelayPort and 383 // when IceTransportsType is set to relay, both RelayPort and
384 // TurnPort will hide raddr to avoid local address leakage. 384 // TurnPort will hide raddr to avoid local address leakage.
385 uint32 candidate_filter_; 385 uint32_t candidate_filter_;
386 386
387 friend class Connection; 387 friend class Connection;
388 }; 388 };
389 389
390 // Represents a communication link between a port on the local client and a 390 // Represents a communication link between a port on the local client and a
391 // port on the remote client. 391 // port on the remote client.
392 class Connection : public rtc::MessageHandler, 392 class Connection : public rtc::MessageHandler,
393 public sigslot::has_slots<> { 393 public sigslot::has_slots<> {
394 public: 394 public:
395 struct SentPing { 395 struct SentPing {
396 SentPing(const std::string id, uint32 sent_time) 396 SentPing(const std::string id, uint32_t sent_time)
397 : id(id), 397 : id(id), sent_time(sent_time) {}
398 sent_time(sent_time) {}
399 398
400 std::string id; 399 std::string id;
401 uint32 sent_time; 400 uint32_t sent_time;
402 }; 401 };
403 402
404 // States are from RFC 5245. http://tools.ietf.org/html/rfc5245#section-5.7.4 403 // States are from RFC 5245. http://tools.ietf.org/html/rfc5245#section-5.7.4
405 enum State { 404 enum State {
406 STATE_WAITING = 0, // Check has not been performed, Waiting pair on CL. 405 STATE_WAITING = 0, // Check has not been performed, Waiting pair on CL.
407 STATE_INPROGRESS, // Check has been sent, transaction is in progress. 406 STATE_INPROGRESS, // Check has been sent, transaction is in progress.
408 STATE_SUCCEEDED, // Check already done, produced a successful result. 407 STATE_SUCCEEDED, // Check already done, produced a successful result.
409 STATE_FAILED // Check for this connection failed. 408 STATE_FAILED // Check for this connection failed.
410 }; 409 };
411 410
412 virtual ~Connection(); 411 virtual ~Connection();
413 412
414 // The local port where this connection sends and receives packets. 413 // The local port where this connection sends and receives packets.
415 Port* port() { return port_; } 414 Port* port() { return port_; }
416 const Port* port() const { return port_; } 415 const Port* port() const { return port_; }
417 416
418 // Returns the description of the local port 417 // Returns the description of the local port
419 virtual const Candidate& local_candidate() const; 418 virtual const Candidate& local_candidate() const;
420 419
421 // Returns the description of the remote port to which we communicate. 420 // Returns the description of the remote port to which we communicate.
422 const Candidate& remote_candidate() const { return remote_candidate_; } 421 const Candidate& remote_candidate() const { return remote_candidate_; }
423 422
424 // Returns the pair priority. 423 // Returns the pair priority.
425 uint64 priority() const; 424 uint64_t priority() const;
426 425
427 enum WriteState { 426 enum WriteState {
428 STATE_WRITABLE = 0, // we have received ping responses recently 427 STATE_WRITABLE = 0, // we have received ping responses recently
429 STATE_WRITE_UNRELIABLE = 1, // we have had a few ping failures 428 STATE_WRITE_UNRELIABLE = 1, // we have had a few ping failures
430 STATE_WRITE_INIT = 2, // we have yet to receive a ping response 429 STATE_WRITE_INIT = 2, // we have yet to receive a ping response
431 STATE_WRITE_TIMEOUT = 3, // we have had a large number of ping failures 430 STATE_WRITE_TIMEOUT = 3, // we have had a large number of ping failures
432 }; 431 };
433 432
434 WriteState write_state() const { return write_state_; } 433 WriteState write_state() const { return write_state_; }
435 bool writable() const { return write_state_ == STATE_WRITABLE; } 434 bool writable() const { return write_state_ == STATE_WRITABLE; }
436 bool receiving() const { return receiving_; } 435 bool receiving() const { return receiving_; }
437 436
438 // Determines whether the connection has finished connecting. This can only 437 // Determines whether the connection has finished connecting. This can only
439 // be false for TCP connections. 438 // be false for TCP connections.
440 bool connected() const { return connected_; } 439 bool connected() const { return connected_; }
441 bool weak() const { return !(writable() && receiving() && connected()); } 440 bool weak() const { return !(writable() && receiving() && connected()); }
442 bool active() const { 441 bool active() const {
443 // TODO(honghaiz): Move from using |write_state_| to using |pruned_|. 442 // TODO(honghaiz): Move from using |write_state_| to using |pruned_|.
444 return write_state_ != STATE_WRITE_TIMEOUT; 443 return write_state_ != STATE_WRITE_TIMEOUT;
445 } 444 }
446 // A connection is dead if it can be safely deleted. 445 // A connection is dead if it can be safely deleted.
447 bool dead(uint32 now) const; 446 bool dead(uint32_t now) const;
448 447
449 // Estimate of the round-trip time over this connection. 448 // Estimate of the round-trip time over this connection.
450 uint32 rtt() const { return rtt_; } 449 uint32_t rtt() const { return rtt_; }
451 450
452 size_t sent_total_bytes(); 451 size_t sent_total_bytes();
453 size_t sent_bytes_second(); 452 size_t sent_bytes_second();
454 // Used to track how many packets are discarded in the application socket due 453 // Used to track how many packets are discarded in the application socket due
455 // to errors. 454 // to errors.
456 size_t sent_discarded_packets(); 455 size_t sent_discarded_packets();
457 size_t sent_total_packets(); 456 size_t sent_total_packets();
458 size_t recv_total_bytes(); 457 size_t recv_total_bytes();
459 size_t recv_bytes_second(); 458 size_t recv_bytes_second();
460 sigslot::signal1<Connection*> SignalStateChange; 459 sigslot::signal1<Connection*> SignalStateChange;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 bool use_candidate_attr() const { return use_candidate_attr_; } 493 bool use_candidate_attr() const { return use_candidate_attr_; }
495 void set_use_candidate_attr(bool enable); 494 void set_use_candidate_attr(bool enable);
496 495
497 bool nominated() const { return nominated_; } 496 bool nominated() const { return nominated_; }
498 void set_nominated(bool nominated) { nominated_ = nominated; } 497 void set_nominated(bool nominated) { nominated_ = nominated; }
499 498
500 void set_remote_ice_mode(IceMode mode) { 499 void set_remote_ice_mode(IceMode mode) {
501 remote_ice_mode_ = mode; 500 remote_ice_mode_ = mode;
502 } 501 }
503 502
504 void set_receiving_timeout(uint32 receiving_timeout_ms) { 503 void set_receiving_timeout(uint32_t receiving_timeout_ms) {
505 receiving_timeout_ = receiving_timeout_ms; 504 receiving_timeout_ = receiving_timeout_ms;
506 } 505 }
507 506
508 // Makes the connection go away. 507 // Makes the connection go away.
509 void Destroy(); 508 void Destroy();
510 509
511 // Checks that the state of this connection is up-to-date. The argument is 510 // Checks that the state of this connection is up-to-date. The argument is
512 // the current time, which is compared against various timeouts. 511 // the current time, which is compared against various timeouts.
513 void UpdateState(uint32 now); 512 void UpdateState(uint32_t now);
514 513
515 // Called when this connection should try checking writability again. 514 // Called when this connection should try checking writability again.
516 uint32 last_ping_sent() const { return last_ping_sent_; } 515 uint32_t last_ping_sent() const { return last_ping_sent_; }
517 void Ping(uint32 now); 516 void Ping(uint32_t now);
518 void ReceivedPingResponse(); 517 void ReceivedPingResponse();
519 518
520 // Called whenever a valid ping is received on this connection. This is 519 // Called whenever a valid ping is received on this connection. This is
521 // public because the connection intercepts the first ping for us. 520 // public because the connection intercepts the first ping for us.
522 uint32 last_ping_received() const { return last_ping_received_; } 521 uint32_t last_ping_received() const { return last_ping_received_; }
523 void ReceivedPing(); 522 void ReceivedPing();
524 523
525 // Debugging description of this connection 524 // Debugging description of this connection
526 std::string ToDebugId() const; 525 std::string ToDebugId() const;
527 std::string ToString() const; 526 std::string ToString() const;
528 std::string ToSensitiveString() const; 527 std::string ToSensitiveString() const;
529 // Prints pings_since_last_response_ into a string. 528 // Prints pings_since_last_response_ into a string.
530 void PrintPingsSinceLastResponse(std::string* pings, size_t max); 529 void PrintPingsSinceLastResponse(std::string* pings, size_t max);
531 530
532 bool reported() const { return reported_; } 531 bool reported() const { return reported_; }
(...skipping 15 matching lines...) Expand all
548 void MaybeSetRemoteIceCredentials(const std::string& ice_ufrag, 547 void MaybeSetRemoteIceCredentials(const std::string& ice_ufrag,
549 const std::string& ice_pwd); 548 const std::string& ice_pwd);
550 549
551 // If |remote_candidate_| is peer reflexive and is equivalent to 550 // If |remote_candidate_| is peer reflexive and is equivalent to
552 // |new_candidate| except the type, update |remote_candidate_| to 551 // |new_candidate| except the type, update |remote_candidate_| to
553 // |new_candidate|. 552 // |new_candidate|.
554 void MaybeUpdatePeerReflexiveCandidate(const Candidate& new_candidate); 553 void MaybeUpdatePeerReflexiveCandidate(const Candidate& new_candidate);
555 554
556 // Returns the last received time of any data, stun request, or stun 555 // Returns the last received time of any data, stun request, or stun
557 // response in milliseconds 556 // response in milliseconds
558 uint32 last_received(); 557 uint32_t last_received();
559 558
560 protected: 559 protected:
561 enum { MSG_DELETE = 0, MSG_FIRST_AVAILABLE }; 560 enum { MSG_DELETE = 0, MSG_FIRST_AVAILABLE };
562 561
563 // Constructs a new connection to the given remote port. 562 // Constructs a new connection to the given remote port.
564 Connection(Port* port, size_t index, const Candidate& candidate); 563 Connection(Port* port, size_t index, const Candidate& candidate);
565 564
566 // Called back when StunRequestManager has a stun packet to send 565 // Called back when StunRequestManager has a stun packet to send
567 void OnSendStunPacket(const void* data, size_t size, StunRequest* req); 566 void OnSendStunPacket(const void* data, size_t size, StunRequest* req);
568 567
(...skipping 23 matching lines...) Expand all
592 // By default |use_candidate_attr_| flag will be true, 591 // By default |use_candidate_attr_| flag will be true,
593 // as we will be using aggressive nomination. 592 // as we will be using aggressive nomination.
594 // But when peer is ice-lite, this flag "must" be initialized to false and 593 // But when peer is ice-lite, this flag "must" be initialized to false and
595 // turn on when connection becomes "best connection". 594 // turn on when connection becomes "best connection".
596 bool use_candidate_attr_; 595 bool use_candidate_attr_;
597 // Whether this connection has been nominated by the controlling side via 596 // Whether this connection has been nominated by the controlling side via
598 // the use_candidate attribute. 597 // the use_candidate attribute.
599 bool nominated_; 598 bool nominated_;
600 IceMode remote_ice_mode_; 599 IceMode remote_ice_mode_;
601 StunRequestManager requests_; 600 StunRequestManager requests_;
602 uint32 rtt_; 601 uint32_t rtt_;
603 uint32 last_ping_sent_; // last time we sent a ping to the other side 602 uint32_t last_ping_sent_; // last time we sent a ping to the other side
604 uint32 last_ping_received_; // last time we received a ping from the other 603 uint32_t last_ping_received_; // last time we received a ping from the other
605 // side 604 // side
606 uint32 last_data_received_; 605 uint32_t last_data_received_;
607 uint32 last_ping_response_received_; 606 uint32_t last_ping_response_received_;
608 std::vector<SentPing> pings_since_last_response_; 607 std::vector<SentPing> pings_since_last_response_;
609 608
610 rtc::RateTracker recv_rate_tracker_; 609 rtc::RateTracker recv_rate_tracker_;
611 rtc::RateTracker send_rate_tracker_; 610 rtc::RateTracker send_rate_tracker_;
612 uint32 sent_packets_discarded_; 611 uint32_t sent_packets_discarded_;
613 uint32 sent_packets_total_; 612 uint32_t sent_packets_total_;
614 613
615 private: 614 private:
616 void MaybeAddPrflxCandidate(ConnectionRequest* request, 615 void MaybeAddPrflxCandidate(ConnectionRequest* request,
617 StunMessage* response); 616 StunMessage* response);
618 617
619 bool reported_; 618 bool reported_;
620 State state_; 619 State state_;
621 // Time duration to switch from receiving to not receiving. 620 // Time duration to switch from receiving to not receiving.
622 uint32 receiving_timeout_; 621 uint32_t receiving_timeout_;
623 uint32 time_created_ms_; 622 uint32_t time_created_ms_;
624 623
625 friend class Port; 624 friend class Port;
626 friend class ConnectionRequest; 625 friend class ConnectionRequest;
627 }; 626 };
628 627
629 // ProxyConnection defers all the interesting work to the port 628 // ProxyConnection defers all the interesting work to the port
630 class ProxyConnection : public Connection { 629 class ProxyConnection : public Connection {
631 public: 630 public:
632 ProxyConnection(Port* port, size_t index, const Candidate& candidate); 631 ProxyConnection(Port* port, size_t index, const Candidate& candidate);
633 632
634 virtual int Send(const void* data, size_t size, 633 virtual int Send(const void* data, size_t size,
635 const rtc::PacketOptions& options); 634 const rtc::PacketOptions& options);
636 virtual int GetError() { return error_; } 635 virtual int GetError() { return error_; }
637 636
638 private: 637 private:
639 int error_; 638 int error_;
640 }; 639 };
641 640
642 } // namespace cricket 641 } // namespace cricket
643 642
644 #endif // WEBRTC_P2P_BASE_PORT_H_ 643 #endif // WEBRTC_P2P_BASE_PORT_H_
OLDNEW
« no previous file with comments | « webrtc/p2p/base/packetsocketfactory.h ('k') | webrtc/p2p/base/port.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698