| OLD | NEW |
| 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 |
| 11 #ifndef WEBRTC_P2P_BASE_STUNREQUEST_H_ | 11 #ifndef WEBRTC_P2P_BASE_STUNREQUEST_H_ |
| 12 #define WEBRTC_P2P_BASE_STUNREQUEST_H_ | 12 #define WEBRTC_P2P_BASE_STUNREQUEST_H_ |
| 13 | 13 |
| 14 #include <map> | 14 #include <map> |
| 15 #include <string> | 15 #include <string> |
| 16 #include "webrtc/p2p/base/stun.h" | 16 #include "webrtc/p2p/base/stun.h" |
| 17 #include "webrtc/base/sigslot.h" | 17 #include "webrtc/base/sigslot.h" |
| 18 #include "webrtc/base/thread.h" | 18 #include "webrtc/base/thread.h" |
| 19 | 19 |
| 20 namespace cricket { | 20 namespace cricket { |
| 21 | 21 |
| 22 class StunRequest; | 22 class StunRequest; |
| 23 | 23 |
| 24 const int kAllRequests = 0; | 24 const int kAllRequests = 0; |
| 25 | 25 |
| 26 // Total max timeouts: 39.75 seconds |
| 27 // For years, this was 9.5 seconds, but for networks that experience moments of |
| 28 // high RTT (such as 40s on 2G networks), this doesn't work well. |
| 29 const int STUN_TOTAL_TIMEOUT = 39750; // milliseconds |
| 30 |
| 26 // Manages a set of STUN requests, sending and resending until we receive a | 31 // Manages a set of STUN requests, sending and resending until we receive a |
| 27 // response or determine that the request has timed out. | 32 // response or determine that the request has timed out. |
| 28 class StunRequestManager { | 33 class StunRequestManager { |
| 29 public: | 34 public: |
| 30 StunRequestManager(rtc::Thread* thread); | 35 StunRequestManager(rtc::Thread* thread); |
| 31 ~StunRequestManager(); | 36 ~StunRequestManager(); |
| 32 | 37 |
| 33 // Starts sending the given request (perhaps after a delay). | 38 // Starts sending the given request (perhaps after a delay). |
| 34 void Send(StunRequest* request); | 39 void Send(StunRequest* request); |
| 35 void SendDelayed(StunRequest* request, int delay); | 40 void SendDelayed(StunRequest* request, int delay); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 StunRequestManager* manager_; | 135 StunRequestManager* manager_; |
| 131 StunMessage* msg_; | 136 StunMessage* msg_; |
| 132 int64_t tstamp_; | 137 int64_t tstamp_; |
| 133 | 138 |
| 134 friend class StunRequestManager; | 139 friend class StunRequestManager; |
| 135 }; | 140 }; |
| 136 | 141 |
| 137 } // namespace cricket | 142 } // namespace cricket |
| 138 | 143 |
| 139 #endif // WEBRTC_P2P_BASE_STUNREQUEST_H_ | 144 #endif // WEBRTC_P2P_BASE_STUNREQUEST_H_ |
| OLD | NEW |