OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2010 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 125 |
126 void StartGettingPorts() override { | 126 void StartGettingPorts() override { |
127 if (!port_) { | 127 if (!port_) { |
128 rtc::Network& network = | 128 rtc::Network& network = |
129 (rtc::HasIPv6Enabled() && (flags() & PORTALLOCATOR_ENABLE_IPV6)) | 129 (rtc::HasIPv6Enabled() && (flags() & PORTALLOCATOR_ENABLE_IPV6)) |
130 ? ipv6_network_ | 130 ? ipv6_network_ |
131 : ipv4_network_; | 131 : ipv4_network_; |
132 port_.reset(TestUDPPort::Create(worker_thread_, factory_, &network, | 132 port_.reset(TestUDPPort::Create(worker_thread_, factory_, &network, |
133 network.GetBestIP(), 0, 0, username(), | 133 network.GetBestIP(), 0, 0, username(), |
134 password(), std::string(), false)); | 134 password(), std::string(), false)); |
| 135 port_->SignalDestroyed.connect( |
| 136 this, &FakePortAllocatorSession::OnPortDestroyed); |
135 AddPort(port_.get()); | 137 AddPort(port_.get()); |
136 } | 138 } |
137 ++port_config_count_; | 139 ++port_config_count_; |
138 running_ = true; | 140 running_ = true; |
139 } | 141 } |
140 | 142 |
141 void StopGettingPorts() override { running_ = false; } | 143 void StopGettingPorts() override { running_ = false; } |
142 bool IsGettingPorts() override { return running_; } | 144 bool IsGettingPorts() override { return running_; } |
143 void ClearGettingPorts() override {} | 145 void ClearGettingPorts() override {} |
144 std::vector<PortInterface*> ReadyPorts() const override { | 146 std::vector<PortInterface*> ReadyPorts() const override { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 SignalPortReady(this, port); | 183 SignalPortReady(this, port); |
182 } | 184 } |
183 void OnPortComplete(cricket::Port* port) { | 185 void OnPortComplete(cricket::Port* port) { |
184 const std::vector<Candidate>& candidates = port->Candidates(); | 186 const std::vector<Candidate>& candidates = port->Candidates(); |
185 candidates_.insert(candidates_.end(), candidates.begin(), candidates.end()); | 187 candidates_.insert(candidates_.end(), candidates.begin(), candidates.end()); |
186 SignalCandidatesReady(this, candidates); | 188 SignalCandidatesReady(this, candidates); |
187 | 189 |
188 allocation_done_ = true; | 190 allocation_done_ = true; |
189 SignalCandidatesAllocationDone(this); | 191 SignalCandidatesAllocationDone(this); |
190 } | 192 } |
| 193 void OnPortDestroyed(cricket::PortInterface* port) { |
| 194 // Don't want to double-delete port if it deletes itself. |
| 195 port_.release(); |
| 196 } |
191 | 197 |
192 rtc::Thread* worker_thread_; | 198 rtc::Thread* worker_thread_; |
193 rtc::PacketSocketFactory* factory_; | 199 rtc::PacketSocketFactory* factory_; |
194 rtc::Network ipv4_network_; | 200 rtc::Network ipv4_network_; |
195 rtc::Network ipv6_network_; | 201 rtc::Network ipv6_network_; |
196 std::unique_ptr<cricket::Port> port_; | 202 std::unique_ptr<cricket::Port> port_; |
197 bool running_; | 203 bool running_; |
198 int port_config_count_; | 204 int port_config_count_; |
199 std::vector<Candidate> candidates_; | 205 std::vector<Candidate> candidates_; |
200 std::vector<PortInterface*> ready_ports_; | 206 std::vector<PortInterface*> ready_ports_; |
(...skipping 29 matching lines...) Expand all Loading... |
230 | 236 |
231 private: | 237 private: |
232 rtc::Thread* worker_thread_; | 238 rtc::Thread* worker_thread_; |
233 rtc::PacketSocketFactory* factory_; | 239 rtc::PacketSocketFactory* factory_; |
234 std::unique_ptr<rtc::BasicPacketSocketFactory> owned_factory_; | 240 std::unique_ptr<rtc::BasicPacketSocketFactory> owned_factory_; |
235 }; | 241 }; |
236 | 242 |
237 } // namespace cricket | 243 } // namespace cricket |
238 | 244 |
239 #endif // WEBRTC_P2P_BASE_FAKEPORTALLOCATOR_H_ | 245 #endif // WEBRTC_P2P_BASE_FAKEPORTALLOCATOR_H_ |
OLD | NEW |