Skip to content

Commit

Permalink
Add webrtc metric for parsing ice candidates
Browse files Browse the repository at this point in the history
Logs if parsing the ice candidate message was successful.

Bug: 1021984
Change-Id: I5c7adaed6e3fef5e7e5417f8edd6d11381e6f95f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2014942
Reviewed-by: Alexei Svitkine <asvitkine@chromium.org>
Reviewed-by: Richard Knoll <knollr@chromium.org>
Commit-Queue: Himanshu Jaju <himanshujaju@chromium.org>
Cr-Commit-Position: refs/heads/master@{#734978}
  • Loading branch information
Himanshu Jaju authored and Commit Bot committed Jan 24, 2020
1 parent 9325f96 commit a80417b
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 7 deletions.
1 change: 1 addition & 0 deletions chrome/services/sharing/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ source_set("sharing") {

public_deps = [
"//base",
"//chrome/services/sharing/public/cpp",
"//chrome/services/sharing/public/mojom",
"//mojo/public/cpp/bindings",
]
Expand Down
12 changes: 12 additions & 0 deletions chrome/services/sharing/public/cpp/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

source_set("cpp") {
sources = [
"sharing_webrtc_metrics.cc",
"sharing_webrtc_metrics.h",
]

public_deps = [ "//base" ]
}
18 changes: 18 additions & 0 deletions chrome/services/sharing/public/cpp/sharing_webrtc_metrics.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/services/sharing/public/cpp/sharing_webrtc_metrics.h"

#include "base/metrics/histogram_functions.h"
#include "base/strings/strcat.h"

namespace {
// Common prefix for all webrtc metric in Sharing service.
const char kMetricsPrefix[] = "Sharing.WebRtc.";
} // namespace

void LogWebRtcAddIceCandidate(bool success) {
base::UmaHistogramBoolean(base::StrCat({kMetricsPrefix, "AddIceCandidate"}),
success);
}
11 changes: 11 additions & 0 deletions chrome/services/sharing/public/cpp/sharing_webrtc_metrics.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_SERVICES_SHARING_PUBLIC_CPP_SHARING_WEBRTC_METRICS_H_
#define CHROME_SERVICES_SHARING_PUBLIC_CPP_SHARING_WEBRTC_METRICS_H_

// Logs whether adding ice candidate was successful.
void LogWebRtcAddIceCandidate(bool success);

#endif // CHROME_SERVICES_SHARING_PUBLIC_CPP_SHARING_WEBRTC_METRICS_H_
12 changes: 5 additions & 7 deletions chrome/services/sharing/webrtc/sharing_webrtc_connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "base/callback.h"
#include "base/memory/ptr_util.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/services/sharing/public/cpp/sharing_webrtc_metrics.h"
#include "third_party/webrtc/api/jsep.h"

namespace {
Expand Down Expand Up @@ -454,16 +455,13 @@ void SharingWebRtcConnection::AddIceCandidates(
webrtc::CreateIceCandidate(
ice_candidate->sdp_mid, ice_candidate->sdp_mline_index,
ice_candidate->candidate, /*error=*/nullptr));

if (candidate) {
peer_connection_->AddIceCandidate(
std::move(candidate), [](webrtc::RTCError error) {
if (!error.ok()) {
LOG(ERROR) << "Failed to add IceCandidate: " << error.message()
<< " (" << webrtc::ToString(error.type()) << ")";
}
});
std::move(candidate),
[](webrtc::RTCError error) { LogWebRtcAddIceCandidate(error.ok()); });
} else {
LOG(ERROR) << "Skipping invalid IceCandidate";
LogWebRtcAddIceCandidate(false);
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions tools/metrics/histograms/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143501,6 +143501,16 @@ should be kept until we remove incident reporting. -->
</summary>
</histogram>

<histogram name="Sharing.WebRtc.AddIceCandidate" enum="BooleanSuccess"
expires_after="M84">
<owner>himanshujaju@chromium.org</owner>
<owner>knollr@chromium.org</owner>
<summary>
Result of parsing received ice candidate. Logged when trying to add received
ice candidate.
</summary>
</histogram>

<histogram name="ShortcutsProvider.DatabaseSize" units="units"
expires_after="2018-08-30">
<owner>mpearson@chromium.org</owner>
Expand Down

0 comments on commit a80417b

Please sign in to comment.