Skip to content

Commit

Permalink
Handle null urls in PeerConnectionTrackerHost
Browse files Browse the repository at this point in the history
As shown by crbug.com/1274640, the provided URL for the document
hosting a PeerConnection can be null. Situations like a page with
an opaque origin could potentially lead to this.
As the result is only used for the WebRtcInternals debugging page,
just handling it gracefully as an empty string will be fine.

Bug: 1274640
Change-Id: I584c9f7aec9884d823504a6f5639387585538751
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3310607
Commit-Queue: Tony Herre <toprice@chromium.org>
Reviewed-by: Alex Gough <ajgo@chromium.org>
Reviewed-by: Thomas Guilbert <tguilbert@chromium.org>
Cr-Commit-Position: refs/heads/main@{#947594}
  • Loading branch information
Tony Herre authored and Chromium LUCI CQ committed Dec 2, 2021
1 parent 4b2b853 commit 883aa8c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,11 @@ void PeerConnectionTrackerHost::AddPeerConnection(
blink::mojom::PeerConnectionInfoPtr info) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);

const std::string& url =
(info->url == absl::nullopt) ? std::string() : *info->url;

for (auto& observer : GetObserverList()) {
observer.OnPeerConnectionAdded(frame_id_, info->lid, peer_pid_, info->url,
observer.OnPeerConnectionAdded(frame_id_, info->lid, peer_pid_, url,
info->rtc_configuration, info->constraints);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ struct PeerConnectionInfo {

// The URL of the blink::WebLocalFrame within which this peer connection
// lives. Used for debugging purposes (displayed by WebRTC-Internals).
string url;
// May be null for eg pages with opaque URLs.
// TODO(1274640): Use a mojo URL instead of a string.
string? url;
};

// This interface collects data about each peer connection and sends it to the
Expand Down

0 comments on commit 883aa8c

Please sign in to comment.