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

Unified Diff: content/browser/resources/media/webrtc_internals.js

Issue 405683003: Adds the UserMedia requests to the UI of chrome://webrtc-internals. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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
Index: content/browser/resources/media/webrtc_internals.js
diff --git a/content/browser/resources/media/webrtc_internals.js b/content/browser/resources/media/webrtc_internals.js
index 53a04f4c6865592e64a19e8cbe303b346a8d7280..96bd4c1d98ab2c33646c0a1e6272503a994069db 100644
--- a/content/browser/resources/media/webrtc_internals.js
+++ b/content/browser/resources/media/webrtc_internals.js
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+var USER_MEDIA_TAB_ID = 'user-media-tab-id';
+
var tabView = null;
var ssrcInfoManager = null;
var peerConnectionUpdateTable = null;
@@ -138,6 +140,21 @@ function extractSsrcInfo(data) {
/**
+ * A helper function for appending a child element to |parent|.
+ *
+ * @param {!Element} parent The parent element.
+ * @param {string} tag The child element tag.
+ * @param {string} text The textContent of the new DIV.
+ * @return {!Element} the new DIV element.
+ */
+function appendChildWithText(parent, tag, text) {
+ var child = document.createElement(tag);
+ child.textContent = text;
+ parent.appendChild(child);
+ return child;
+}
+
+/**
* Helper for adding a peer connection update.
*
* @param {Element} peerConnectionElement
@@ -186,7 +203,7 @@ function addPeerConnection(data) {
var peerConnectionElement = $(id);
if (!peerConnectionElement) {
- peerConnectionElement = tabView.addTab(id, data.url);
+ peerConnectionElement = tabView.addTab(id, data.url + ' [' + id + ']');
}
peerConnectionElement.innerHTML =
'<p>' + data.url + ' ' + data.servers + ' ' + data.constraints +
@@ -258,8 +275,26 @@ function addStats(data) {
* origin {string}, audio {string}, video {string}.
*/
function addGetUserMedia(data) {
- // TODO(jiayl): add the getUserMedia info to the tabbed UI.
userMediaRequests.push(data);
+
+ if (!$(USER_MEDIA_TAB_ID)) {
+ tabView.addTab(USER_MEDIA_TAB_ID, 'GetUserMedia Requests');
+ }
+
+ var requestDiv = document.createElement('div');
+ requestDiv.className = 'user-media-request-div-class';
+ requestDiv.rid = data.rid;
+ $(USER_MEDIA_TAB_ID).appendChild(requestDiv);
+
+ appendChildWithText(requestDiv, 'div', 'Caller origin: ' + data.origin);
+ appendChildWithText(requestDiv, 'div', 'Caller process id: ' + data.pid);
+ appendChildWithText(requestDiv, 'span', 'Audio Constraints').style.fontWeight
+ = 'bold';
+ appendChildWithText(requestDiv, 'div', data.audio);
+
+ appendChildWithText(requestDiv, 'span', 'Video Constraints').style.fontWeight
+ = 'bold';
+ appendChildWithText(requestDiv, 'div', data.video);
}
@@ -269,11 +304,19 @@ function addGetUserMedia(data) {
* @param {!Object} data The object containing rid {number}, the render id.
*/
function removeGetUserMediaForRenderer(data) {
- // TODO(jiayl): remove the getUserMedia info from the tabbed UI.
for (var i = userMediaRequests.length - 1; i >= 0; --i) {
if (userMediaRequests[i].rid == data.rid)
userMediaRequests.splice(i, 1);
}
+
+ var requests = $(USER_MEDIA_TAB_ID).childNodes;
+ for (var i = 0; i < requests.length; ++i) {
+ if (requests[i].rid == data.rid)
+ $(USER_MEDIA_TAB_ID).removeChild(requests[i]);
+
+ }
+ if ($(USER_MEDIA_TAB_ID).childNodes.length == 0)
+ tabView.removeTab(USER_MEDIA_TAB_ID);
}
« no previous file with comments | « content/browser/resources/media/webrtc_internals.css ('k') | content/renderer/media/peer_connection_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698