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

Unified Diff: webrtc/p2p/client/basicportallocator.cc

Issue 2386783002: Add UMA metrics for ICE regathering reasons. (Closed)
Patch Set: Address comments 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 side-by-side diff with in-line comments
Download patch
« webrtc/p2p/base/portallocator.h ('K') | « webrtc/p2p/client/basicportallocator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/client/basicportallocator.cc
diff --git a/webrtc/p2p/client/basicportallocator.cc b/webrtc/p2p/client/basicportallocator.cc
index dba68f177e5120a496a39d603d622971ac776ac4..237c649beaa47c8194677e4767b8dd3f60cff784 100644
--- a/webrtc/p2p/client/basicportallocator.cc
+++ b/webrtc/p2p/client/basicportallocator.cc
@@ -14,6 +14,7 @@
#include <string>
#include <vector>
+#include "webrtc/api/peerconnectioninterface.h"
#include "webrtc/p2p/base/basicpacketsocketfactory.h"
#include "webrtc/p2p/base/common.h"
#include "webrtc/p2p/base/port.h"
@@ -156,8 +157,11 @@ BasicPortAllocator::~BasicPortAllocator() {
PortAllocatorSession* BasicPortAllocator::CreateSessionInternal(
const std::string& content_name, int component,
const std::string& ice_ufrag, const std::string& ice_pwd) {
- return new BasicPortAllocatorSession(
+ PortAllocatorSession* session = new BasicPortAllocatorSession(
this, content_name, component, ice_ufrag, ice_pwd);
+ session->SignalIceRegatheringReason.connect(
+ this, &BasicPortAllocator::ReportIceRegatheringReason);
+ return session;
}
void BasicPortAllocator::AddTurnServer(const RelayServerConfig& turn_server) {
@@ -167,6 +171,15 @@ void BasicPortAllocator::AddTurnServer(const RelayServerConfig& turn_server) {
prune_turn_ports());
}
+void BasicPortAllocator::ReportIceRegatheringReason(
pthatcher2 2016/10/04 06:03:17 Similarly, I think calling this ReportIceRegatheri
honghaiz3 2016/10/05 05:01:53 This method is removed.
+ IceRegatheringReason reason) {
+ if (metrics_observer()) {
+ metrics_observer()->IncrementEnumCounter(
+ webrtc::kEnumCounterIceRegatheringReason, static_cast<int>(reason),
+ static_cast<int>(IceRegatheringReason::MAX_VALUE));
+ }
+}
+
// BasicPortAllocatorSession
BasicPortAllocatorSession::BasicPortAllocatorSession(
BasicPortAllocator* allocator,
@@ -247,7 +260,7 @@ void BasicPortAllocatorSession::StartGettingPorts() {
network_thread_->Post(RTC_FROM_HERE, this, MSG_CONFIG_START);
- LOG(LS_INFO) << "Pruning turn ports "
+ LOG(LS_INFO) << "Start getting ports with prune_turn_ports "
<< (prune_turn_ports_ ? "enabled" : "disabled");
}
@@ -302,6 +315,8 @@ void BasicPortAllocatorSession::RegatherOnFailedNetworks() {
return;
}
+ LOG(LS_INFO) << "Regather candidates on failed networks";
+
// Mark a sequence as "network failed" if its network is in the list of failed
// networks, so that it won't be considered as equivalent when the session
// regathers ports and candidates.
@@ -321,7 +336,10 @@ void BasicPortAllocatorSession::RegatherOnFailedNetworks() {
PrunePortsAndRemoveCandidates(ports_to_prune);
}
- if (allocation_started_ && network_manager_started_) {
+ if (allocation_started_ && network_manager_started_ && !IsStopped()) {
+ SignalIceRegatheringReason(
+ IceRegatheringReason::CONTINUAL_GATHERING_BY_NETWORK_FAILURE);
pthatcher2 2016/10/04 06:03:17 Actually, this makes it feel like we have two diff
honghaiz3 2016/10/05 05:01:53 Done.
+
DoAllocate();
}
}
@@ -501,7 +519,7 @@ void BasicPortAllocatorSession::AllocatePorts() {
}
void BasicPortAllocatorSession::OnAllocate() {
- if (network_manager_started_)
+ if (network_manager_started_ && !IsStopped())
DoAllocate();
allocation_started_ = true;
@@ -553,10 +571,6 @@ std::vector<rtc::Network*> BasicPortAllocatorSession::GetNetworks() {
void BasicPortAllocatorSession::DoAllocate() {
bool done_signal_needed = false;
std::vector<rtc::Network*> networks = GetNetworks();
-
- if (IsStopped()) {
- return;
- }
if (networks.empty()) {
LOG(LS_WARNING) << "Machine has no networks; no ports will be allocated";
done_signal_needed = true;
@@ -627,12 +641,19 @@ void BasicPortAllocatorSession::OnNetworksChanged() {
PrunePortsAndRemoveCandidates(ports_to_prune);
}
+ if (allocation_started_ && !IsStopped()) {
+ if (network_manager_started_) {
+ // If the network manager has started, it must be a regathering.
+ SignalIceRegatheringReason(
+ IceRegatheringReason::CONTINUAL_GATHERING_BY_NETWORK_CHANGE);
+ }
+ DoAllocate();
+ }
+
if (!network_manager_started_) {
- LOG(LS_INFO) << "Network manager is started";
+ LOG(LS_INFO) << "Network manager has started";
network_manager_started_ = true;
}
- if (allocation_started_)
- DoAllocate();
}
void BasicPortAllocatorSession::DisableEquivalentPhases(
« webrtc/p2p/base/portallocator.h ('K') | « webrtc/p2p/client/basicportallocator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698