Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Side by Side Diff: webrtc/p2p/base/port.cc

Issue 1648813004: Remove candidates when doing continual gathering (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "webrtc/p2p/base/port.h" 11 #include "webrtc/p2p/base/port.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <vector> 14 #include <vector>
15 15
16 #include "webrtc/p2p/base/common.h" 16 #include "webrtc/p2p/base/common.h"
17 #include "webrtc/p2p/base/portallocator.h" 17 #include "webrtc/p2p/base/portallocator.h"
18 #include "webrtc/base/base64.h" 18 #include "webrtc/base/base64.h"
19 #include "webrtc/base/crc32.h" 19 #include "webrtc/base/crc32.h"
20 #include "webrtc/base/helpers.h" 20 #include "webrtc/base/helpers.h"
21 #include "webrtc/base/logging.h" 21 #include "webrtc/base/logging.h"
22 #include "webrtc/base/messagedigest.h" 22 #include "webrtc/base/messagedigest.h"
23 #include "webrtc/base/network.h"
23 #include "webrtc/base/scoped_ptr.h" 24 #include "webrtc/base/scoped_ptr.h"
24 #include "webrtc/base/stringencode.h" 25 #include "webrtc/base/stringencode.h"
25 #include "webrtc/base/stringutils.h" 26 #include "webrtc/base/stringutils.h"
26 27
27 namespace { 28 namespace {
28 29
29 // Determines whether we have seen at least the given maximum number of 30 // Determines whether we have seen at least the given maximum number of
30 // pings fail to have a response. 31 // pings fail to have a response.
31 inline bool TooManyFailures( 32 inline bool TooManyFailures(
32 const std::vector<cricket::Connection::SentPing>& pings_since_last_response, 33 const std::vector<cricket::Connection::SentPing>& pings_since_last_response,
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 189
189 void Port::Construct() { 190 void Port::Construct() {
190 // TODO(pthatcher): Remove this old behavior once we're sure no one 191 // TODO(pthatcher): Remove this old behavior once we're sure no one
191 // relies on it. If the username_fragment and password are empty, 192 // relies on it. If the username_fragment and password are empty,
192 // we should just create one. 193 // we should just create one.
193 if (ice_username_fragment_.empty()) { 194 if (ice_username_fragment_.empty()) {
194 ASSERT(password_.empty()); 195 ASSERT(password_.empty());
195 ice_username_fragment_ = rtc::CreateRandomString(ICE_UFRAG_LENGTH); 196 ice_username_fragment_ = rtc::CreateRandomString(ICE_UFRAG_LENGTH);
196 password_ = rtc::CreateRandomString(ICE_PWD_LENGTH); 197 password_ = rtc::CreateRandomString(ICE_PWD_LENGTH);
197 } 198 }
199 network_->SignalInactive.connect(this, &Port::OnNetworkInactive);
198 LOG_J(LS_INFO, this) << "Port created"; 200 LOG_J(LS_INFO, this) << "Port created";
199 } 201 }
200 202
201 Port::~Port() { 203 Port::~Port() {
202 // Delete all of the remaining connections. We copy the list up front 204 // Delete all of the remaining connections. We copy the list up front
203 // because each deletion will cause it to be modified. 205 // because each deletion will cause it to be modified.
204 206
205 std::vector<Connection*> list; 207 std::vector<Connection*> list;
206 208
207 AddressMap::iterator iter = connections_.begin(); 209 AddressMap::iterator iter = connections_.begin();
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 << " to " << addr.ToSensitiveString(); 623 << " to " << addr.ToSensitiveString();
622 } 624 }
623 625
624 void Port::OnMessage(rtc::Message *pmsg) { 626 void Port::OnMessage(rtc::Message *pmsg) {
625 ASSERT(pmsg->message_id == MSG_DEAD); 627 ASSERT(pmsg->message_id == MSG_DEAD);
626 if (dead()) { 628 if (dead()) {
627 Destroy(); 629 Destroy();
628 } 630 }
629 } 631 }
630 632
633 void Port::OnNetworkInactive(const rtc::Network* network) {
634 ASSERT(network == network_);
635 SignalNetworkInactive(this);
636 }
637
631 std::string Port::ToString() const { 638 std::string Port::ToString() const {
632 std::stringstream ss; 639 std::stringstream ss;
633 ss << "Port[" << content_name_ << ":" << component_ 640 ss << "Port[" << content_name_ << ":" << component_
634 << ":" << generation_ << ":" << type_ 641 << ":" << generation_ << ":" << type_
635 << ":" << network_->ToString() << "]"; 642 << ":" << network_->ToString() << "]";
636 return ss.str(); 643 return ss.str();
637 } 644 }
638 645
639 void Port::EnablePortPackets() { 646 void Port::EnablePortPackets() {
640 enable_port_packets_ = true; 647 enable_port_packets_ = true;
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
1420 ASSERT(sent < 0); 1427 ASSERT(sent < 0);
1421 error_ = port_->GetError(); 1428 error_ = port_->GetError();
1422 sent_packets_discarded_++; 1429 sent_packets_discarded_++;
1423 } else { 1430 } else {
1424 send_rate_tracker_.AddSamples(sent); 1431 send_rate_tracker_.AddSamples(sent);
1425 } 1432 }
1426 return sent; 1433 return sent;
1427 } 1434 }
1428 1435
1429 } // namespace cricket 1436 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698