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

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

Issue 2386783002: Add UMA metrics for ICE regathering reasons. (Closed)
Patch Set: Add const to the pooled_sessions method. Created 4 years, 2 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
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.h ('k') | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/p2ptransportchannel.h" 11 #include "webrtc/p2p/base/p2ptransportchannel.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <set> 14 #include <set>
15 15
16 #include "webrtc/api/peerconnectioninterface.h"
16 #include "webrtc/base/common.h" 17 #include "webrtc/base/common.h"
17 #include "webrtc/base/crc32.h" 18 #include "webrtc/base/crc32.h"
18 #include "webrtc/base/logging.h" 19 #include "webrtc/base/logging.h"
19 #include "webrtc/base/stringencode.h" 20 #include "webrtc/base/stringencode.h"
20 #include "webrtc/p2p/base/candidate.h" 21 #include "webrtc/p2p/base/candidate.h"
21 #include "webrtc/p2p/base/candidatepairinterface.h" 22 #include "webrtc/p2p/base/candidatepairinterface.h"
22 #include "webrtc/p2p/base/common.h" 23 #include "webrtc/p2p/base/common.h"
23 #include "webrtc/p2p/base/relayport.h" // For RELAY_PORT_TYPE. 24 #include "webrtc/p2p/base/relayport.h" // For RELAY_PORT_TYPE.
24 #include "webrtc/p2p/base/stunport.h" // For STUN_PORT_TYPE. 25 #include "webrtc/p2p/base/stunport.h" // For STUN_PORT_TYPE.
25 #include "webrtc/system_wrappers/include/field_trial.h" 26 #include "webrtc/system_wrappers/include/field_trial.h"
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 config_.default_nomination_mode = config.default_nomination_mode; 429 config_.default_nomination_mode = config.default_nomination_mode;
429 LOG(LS_INFO) << "Set default nomination mode to " 430 LOG(LS_INFO) << "Set default nomination mode to "
430 << static_cast<int>(config_.default_nomination_mode); 431 << static_cast<int>(config_.default_nomination_mode);
431 } 432 }
432 } 433 }
433 434
434 const IceConfig& P2PTransportChannel::config() const { 435 const IceConfig& P2PTransportChannel::config() const {
435 return config_; 436 return config_;
436 } 437 }
437 438
439 void P2PTransportChannel::SetMetricsObserver(
440 webrtc::MetricsObserverInterface* observer) {
441 metrics_observer_ = observer;
442 }
443
438 void P2PTransportChannel::MaybeStartGathering() { 444 void P2PTransportChannel::MaybeStartGathering() {
439 if (ice_parameters_.ufrag.empty() || ice_parameters_.pwd.empty()) { 445 if (ice_parameters_.ufrag.empty() || ice_parameters_.pwd.empty()) {
440 LOG(LS_ERROR) << "Cannot gather candidates because ICE parameters are empty" 446 LOG(LS_ERROR) << "Cannot gather candidates because ICE parameters are empty"
441 << " ufrag: " << ice_parameters_.ufrag 447 << " ufrag: " << ice_parameters_.ufrag
442 << " pwd: " << ice_parameters_.pwd; 448 << " pwd: " << ice_parameters_.pwd;
443 return; 449 return;
444 } 450 }
445 // Start gathering if we never started before, or if an ICE restart occurred. 451 // Start gathering if we never started before, or if an ICE restart occurred.
446 if (allocator_sessions_.empty() || 452 if (allocator_sessions_.empty() ||
447 IceCredentialsChanged(allocator_sessions_.back()->ice_ufrag(), 453 IceCredentialsChanged(allocator_sessions_.back()->ice_ufrag(),
448 allocator_sessions_.back()->ice_pwd(), 454 allocator_sessions_.back()->ice_pwd(),
449 ice_parameters_.ufrag, ice_parameters_.pwd)) { 455 ice_parameters_.ufrag, ice_parameters_.pwd)) {
450 if (gathering_state_ != kIceGatheringGathering) { 456 if (gathering_state_ != kIceGatheringGathering) {
451 gathering_state_ = kIceGatheringGathering; 457 gathering_state_ = kIceGatheringGathering;
452 SignalGatheringState(this); 458 SignalGatheringState(this);
453 } 459 }
460
461 if (metrics_observer_ && !allocator_sessions_.empty()) {
462 IceRestartState state;
463 if (writable()) {
464 state = IceRestartState::CONNECTED;
465 } else if (IsGettingPorts()) {
466 state = IceRestartState::CONNECTING;
467 } else {
468 state = IceRestartState::DISCONNECTED;
469 }
470 metrics_observer_->IncrementEnumCounter(
471 webrtc::kEnumCounterIceRestart, static_cast<int>(state),
472 static_cast<int>(IceRestartState::MAX_VALUE));
473 }
474
454 // Time for a new allocator. 475 // Time for a new allocator.
455 std::unique_ptr<PortAllocatorSession> pooled_session = 476 std::unique_ptr<PortAllocatorSession> pooled_session =
456 allocator_->TakePooledSession(transport_name(), component(), 477 allocator_->TakePooledSession(transport_name(), component(),
457 ice_parameters_.ufrag, 478 ice_parameters_.ufrag,
458 ice_parameters_.pwd); 479 ice_parameters_.pwd);
459 if (pooled_session) { 480 if (pooled_session) {
460 AddAllocatorSession(std::move(pooled_session)); 481 AddAllocatorSession(std::move(pooled_session));
461 PortAllocatorSession* raw_pooled_session = 482 PortAllocatorSession* raw_pooled_session =
462 allocator_sessions_.back().get(); 483 allocator_sessions_.back().get();
463 // Process the pooled session's existing candidates/ports, if they exist. 484 // Process the pooled session's existing candidates/ports, if they exist.
464 OnCandidatesReady(raw_pooled_session, 485 OnCandidatesReady(raw_pooled_session,
465 raw_pooled_session->ReadyCandidates()); 486 raw_pooled_session->ReadyCandidates());
466 for (PortInterface* port : allocator_sessions_.back()->ReadyPorts()) { 487 for (PortInterface* port : allocator_sessions_.back()->ReadyPorts()) {
467 OnPortReady(raw_pooled_session, port); 488 OnPortReady(raw_pooled_session, port);
468 } 489 }
469 if (allocator_sessions_.back()->CandidatesAllocationDone()) { 490 if (allocator_sessions_.back()->CandidatesAllocationDone()) {
470 OnCandidatesAllocationDone(raw_pooled_session); 491 OnCandidatesAllocationDone(raw_pooled_session);
471 } 492 }
472 } else { 493 } else {
473 AddAllocatorSession(allocator_->CreateSession( 494 AddAllocatorSession(allocator_->CreateSession(
474 transport_name(), component(), ice_parameters_.ufrag, 495 transport_name(), component(), ice_parameters_.ufrag,
475 ice_parameters_.pwd)); 496 ice_parameters_.pwd));
476 LOG(LS_INFO) << "Start getting ports";
477 allocator_sessions_.back()->StartGettingPorts(); 497 allocator_sessions_.back()->StartGettingPorts();
478 } 498 }
479 } 499 }
480 } 500 }
481 501
482 // A new port is available, attempt to make connections for it 502 // A new port is available, attempt to make connections for it
483 void P2PTransportChannel::OnPortReady(PortAllocatorSession *session, 503 void P2PTransportChannel::OnPortReady(PortAllocatorSession *session,
484 PortInterface* port) { 504 PortInterface* port) {
485 ASSERT(network_thread_ == rtc::Thread::Current()); 505 ASSERT(network_thread_ == rtc::Thread::Current());
486 506
(...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after
1967 1987
1968 // During the initial state when nothing has been pinged yet, return the first 1988 // During the initial state when nothing has been pinged yet, return the first
1969 // one in the ordered |connections_|. 1989 // one in the ordered |connections_|.
1970 return *(std::find_if(connections_.begin(), connections_.end(), 1990 return *(std::find_if(connections_.begin(), connections_.end(),
1971 [conn1, conn2](Connection* conn) { 1991 [conn1, conn2](Connection* conn) {
1972 return conn == conn1 || conn == conn2; 1992 return conn == conn1 || conn == conn2;
1973 })); 1993 }));
1974 } 1994 }
1975 1995
1976 } // namespace cricket 1996 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.h ('k') | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698