Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2015 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 class StunProber { | 130 class StunProber { |
| 131 public: | 131 public: |
| 132 enum Status { // Used in UMA_HISTOGRAM_ENUMERATION. | 132 enum Status { // Used in UMA_HISTOGRAM_ENUMERATION. |
| 133 SUCCESS, // Successfully received bytes from the server. | 133 SUCCESS, // Successfully received bytes from the server. |
| 134 GENERIC_FAILURE, // Generic failure. | 134 GENERIC_FAILURE, // Generic failure. |
| 135 RESOLVE_FAILED, // Host resolution failed. | 135 RESOLVE_FAILED, // Host resolution failed. |
| 136 WRITE_FAILED, // Sending a message to the server failed. | 136 WRITE_FAILED, // Sending a message to the server failed. |
| 137 READ_FAILED, // Reading the reply from the server failed. | 137 READ_FAILED, // Reading the reply from the server failed. |
| 138 }; | 138 }; |
| 139 | 139 |
| 140 enum NATTYPE { | |
|
pthatcher2
2015/06/05 22:39:41
NatType, please.
guoweis_webrtc
2015/06/07 17:29:40
Done.
| |
| 141 NATTYPE_UNKNOWN, | |
| 142 NATTYPE_NO_NAT, | |
| 143 NATTYPE_NAT_TYPE_UNKNOWN, | |
| 144 NATTYPE_SYM_NAT, | |
| 145 NATTYPE_NON_SYM_NAT | |
| 146 }; | |
| 147 | |
| 140 struct Stats { | 148 struct Stats { |
| 141 Stats() {} | 149 Stats() {} |
| 150 | |
| 142 int num_request_sent = 0; | 151 int num_request_sent = 0; |
| 143 int num_response_received = 0; | 152 int num_response_received = 0; |
| 144 bool behind_nat = false; | 153 NATTYPE nat_type = NATTYPE_UNKNOWN; |
| 145 bool symmetric_nat = false; | |
| 146 int average_rtt_ms = -1; | 154 int average_rtt_ms = -1; |
| 147 int success_percent = 0; | 155 int success_percent = 0; |
| 148 int target_request_interval_ns = 0; | 156 int target_request_interval_ns = 0; |
| 149 int actual_request_interval_ns = 0; | 157 int actual_request_interval_ns = 0; |
| 150 | 158 |
| 151 // Also report whether this trial can't be considered truly as shared | 159 // Also report whether this trial can't be considered truly as shared |
| 152 // mode. Share mode only makes sense when we have multiple IP resolved and | 160 // mode. Share mode only makes sense when we have multiple IP resolved and |
| 153 // successfully probed. | 161 // successfully probed. |
| 154 bool shared_socket_mode = false; | 162 bool shared_socket_mode = false; |
| 155 | 163 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 181 bool Start(const std::vector<rtc::SocketAddress>& servers, | 189 bool Start(const std::vector<rtc::SocketAddress>& servers, |
| 182 bool shared_socket_mode, | 190 bool shared_socket_mode, |
| 183 int stun_ta_interval_ms, | 191 int stun_ta_interval_ms, |
| 184 int requests_per_ip, | 192 int requests_per_ip, |
| 185 int timeout_ms, | 193 int timeout_ms, |
| 186 const AsyncCallback finish_callback); | 194 const AsyncCallback finish_callback); |
| 187 | 195 |
| 188 // Method to retrieve the Stats once |finish_callback| is invoked. Returning | 196 // Method to retrieve the Stats once |finish_callback| is invoked. Returning |
| 189 // false when the result is inconclusive, for example, whether it's behind a | 197 // false when the result is inconclusive, for example, whether it's behind a |
| 190 // NAT or not. | 198 // NAT or not. |
| 191 bool GetStats(Stats* stats); | 199 bool GetStats(Stats* stats) const; |
| 192 | 200 |
| 193 private: | 201 private: |
| 194 // A requester tracks the requests and responses from a single socket to many | 202 // A requester tracks the requests and responses from a single socket to many |
| 195 // STUN servers. | 203 // STUN servers. |
| 196 class Requester; | 204 class Requester; |
| 197 | 205 |
| 198 void OnServerResolved(int index, int result); | 206 void OnServerResolved(int index, int result); |
| 199 | 207 |
| 200 bool Done() { | 208 bool Done() { |
| 201 return num_request_sent_ >= requests_per_ip_ * all_servers_ips_.size(); | 209 return num_request_sent_ >= requests_per_ip_ * all_servers_ips_.size(); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 std::vector<Requester*> requesters_; | 278 std::vector<Requester*> requesters_; |
| 271 | 279 |
| 272 rtc::ThreadChecker thread_checker_; | 280 rtc::ThreadChecker thread_checker_; |
| 273 | 281 |
| 274 DISALLOW_COPY_AND_ASSIGN(StunProber); | 282 DISALLOW_COPY_AND_ASSIGN(StunProber); |
| 275 }; | 283 }; |
| 276 | 284 |
| 277 } // namespace stunprober | 285 } // namespace stunprober |
| 278 | 286 |
| 279 #endif // WEBRTC_P2P_STUNPROBER_STUNPROBER_H_ | 287 #endif // WEBRTC_P2P_STUNPROBER_STUNPROBER_H_ |
| OLD | NEW |