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; |
| 25 |
24 // Manages a set of STUN requests, sending and resending until we receive a | 26 // Manages a set of STUN requests, sending and resending until we receive a |
25 // response or determine that the request has timed out. | 27 // response or determine that the request has timed out. |
26 class StunRequestManager { | 28 class StunRequestManager { |
27 public: | 29 public: |
28 StunRequestManager(rtc::Thread* thread); | 30 StunRequestManager(rtc::Thread* thread); |
29 ~StunRequestManager(); | 31 ~StunRequestManager(); |
30 | 32 |
31 // Starts sending the given request (perhaps after a delay). | 33 // Starts sending the given request (perhaps after a delay). |
32 void Send(StunRequest* request); | 34 void Send(StunRequest* request); |
33 void SendDelayed(StunRequest* request, int delay); | 35 void SendDelayed(StunRequest* request, int delay); |
34 | 36 |
35 // Sends all pending requests right away. Only for testing. | 37 // If |msg_type| is kAllRequests, sends all pending requests right away. |
36 void Flush(); | 38 // Otherwise, sends those that have a matching type right away. |
| 39 // Only for testing. |
| 40 void Flush(int msg_type); |
37 | 41 |
38 // Removes a stun request that was added previously. This will happen | 42 // Removes a stun request that was added previously. This will happen |
39 // automatically when a request succeeds, fails, or times out. | 43 // automatically when a request succeeds, fails, or times out. |
40 void Remove(StunRequest* request); | 44 void Remove(StunRequest* request); |
41 | 45 |
42 // Removes all stun requests that were added previously. | 46 // Removes all stun requests that were added previously. |
43 void Clear(); | 47 void Clear(); |
44 | 48 |
45 // Determines whether the given message is a response to one of the | 49 // Determines whether the given message is a response to one of the |
46 // outstanding requests, and if so, processes it appropriately. | 50 // outstanding requests, and if so, processes it appropriately. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 StunRequestManager* manager_; | 126 StunRequestManager* manager_; |
123 StunMessage* msg_; | 127 StunMessage* msg_; |
124 uint32_t tstamp_; | 128 uint32_t tstamp_; |
125 | 129 |
126 friend class StunRequestManager; | 130 friend class StunRequestManager; |
127 }; | 131 }; |
128 | 132 |
129 } // namespace cricket | 133 } // namespace cricket |
130 | 134 |
131 #endif // WEBRTC_P2P_BASE_STUNREQUEST_H_ | 135 #endif // WEBRTC_P2P_BASE_STUNREQUEST_H_ |
OLD | NEW |