| 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 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 request->set_origin(origin_); | 46 request->set_origin(origin_); |
| 47 request->Construct(); | 47 request->Construct(); |
| 48 requests_[request->id()] = request; | 48 requests_[request->id()] = request; |
| 49 if (delay > 0) { | 49 if (delay > 0) { |
| 50 thread_->PostDelayed(delay, request, MSG_STUN_SEND, NULL); | 50 thread_->PostDelayed(delay, request, MSG_STUN_SEND, NULL); |
| 51 } else { | 51 } else { |
| 52 thread_->Send(request, MSG_STUN_SEND, NULL); | 52 thread_->Send(request, MSG_STUN_SEND, NULL); |
| 53 } | 53 } |
| 54 } | 54 } |
| 55 | 55 |
| 56 void StunRequestManager::Flush() { |
| 57 for (const auto kv : requests_) { |
| 58 StunRequest* request = kv.second; |
| 59 thread_->Clear(request, MSG_STUN_SEND); |
| 60 thread_->Send(request, MSG_STUN_SEND, NULL); |
| 61 } |
| 62 } |
| 63 |
| 56 void StunRequestManager::Remove(StunRequest* request) { | 64 void StunRequestManager::Remove(StunRequest* request) { |
| 57 ASSERT(request->manager() == this); | 65 ASSERT(request->manager() == this); |
| 58 RequestMap::iterator iter = requests_.find(request->id()); | 66 RequestMap::iterator iter = requests_.find(request->id()); |
| 59 if (iter != requests_.end()) { | 67 if (iter != requests_.end()) { |
| 60 ASSERT(iter->second == request); | 68 ASSERT(iter->second == request); |
| 61 requests_.erase(iter); | 69 requests_.erase(iter); |
| 62 thread_->Clear(request); | 70 thread_->Clear(request); |
| 63 } | 71 } |
| 64 } | 72 } |
| 65 | 73 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 } | 216 } |
| 209 | 217 |
| 210 int StunRequest::resend_delay() { | 218 int StunRequest::resend_delay() { |
| 211 if (count_ == 0) { | 219 if (count_ == 0) { |
| 212 return 0; | 220 return 0; |
| 213 } | 221 } |
| 214 return DELAY_UNIT * std::min(1 << (count_-1), DELAY_MAX_FACTOR); | 222 return DELAY_UNIT * std::min(1 << (count_-1), DELAY_MAX_FACTOR); |
| 215 } | 223 } |
| 216 | 224 |
| 217 } // namespace cricket | 225 } // namespace cricket |
| OLD | NEW |