| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 /** | 6 /** |
| 7 * The data of a peer connection update. | 7 * The data of a peer connection update. |
| 8 * @param {number} pid The id of the renderer. | 8 * @param {number} pid The id of the renderer. |
| 9 * @param {number} lid The id of the peer conneciton inside a renderer. | 9 * @param {number} lid The id of the peer conneciton inside a renderer. |
| 10 * @param {string} type The type of the update. | 10 * @param {string} type The type of the update. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 */ | 77 */ |
| 78 addPeerConnectionUpdate: function(peerConnectionElement, update) { | 78 addPeerConnectionUpdate: function(peerConnectionElement, update) { |
| 79 var tableElement = this.ensureUpdateContainer_(peerConnectionElement); | 79 var tableElement = this.ensureUpdateContainer_(peerConnectionElement); |
| 80 | 80 |
| 81 var row = document.createElement('tr'); | 81 var row = document.createElement('tr'); |
| 82 tableElement.firstChild.appendChild(row); | 82 tableElement.firstChild.appendChild(row); |
| 83 | 83 |
| 84 var time = new Date(parseFloat(update.time)); | 84 var time = new Date(parseFloat(update.time)); |
| 85 row.innerHTML = '<td>' + time.toLocaleString() + '</td>'; | 85 row.innerHTML = '<td>' + time.toLocaleString() + '</td>'; |
| 86 | 86 |
| 87 // map internal event names to spec event names. |
| 88 var type = { |
| 89 onRenegotiationNeeded: 'negotiationneeded', |
| 90 signalingStateChange: 'signalingstatechange', |
| 91 iceGatheringStateChange: 'icegatheringstatechange', |
| 92 iceConnectionStateChange: 'iceconnectionstatechange', |
| 93 onIceCandidate: 'icecandidate', |
| 94 stop: 'close' |
| 95 }[update.type] || update.type; |
| 96 |
| 87 if (update.value.length == 0) { | 97 if (update.value.length == 0) { |
| 88 row.innerHTML += '<td>' + update.type + '</td>'; | 98 row.innerHTML += '<td>' + type + '</td>'; |
| 89 return; | 99 return; |
| 90 } | 100 } |
| 91 | 101 |
| 92 row.innerHTML += '<td><details><summary>' + update.type + | 102 row.innerHTML += '<td><details><summary>' + type + |
| 93 '</summary></details></td>'; | 103 '</summary></details></td>'; |
| 94 | 104 |
| 95 var valueContainer = document.createElement('pre'); | 105 var valueContainer = document.createElement('pre'); |
| 96 var details = row.cells[1].childNodes[0]; | 106 var details = row.cells[1].childNodes[0]; |
| 97 details.appendChild(valueContainer); | 107 details.appendChild(valueContainer); |
| 98 valueContainer.textContent = update.value; | 108 |
| 109 var value = update.value; |
| 110 // map internal names and values to names and events from the |
| 111 // specification. This is a display change which shall not |
| 112 // change the JSON dump. |
| 113 if (update.type === 'iceConnectionStateChange') { |
| 114 value = { |
| 115 ICEConnectionStateNew: 'new', |
| 116 ICEConnectionStateChecking: 'checking', |
| 117 ICEConnectionStateConnected: 'connected', |
| 118 ICEConnectionStateCompleted: 'completed', |
| 119 ICEConnectionStateFailed: 'failed', |
| 120 ICEConnectionStateDisconnected: 'disconnected', |
| 121 ICEConnectionStateClosed: 'closed', |
| 122 }[value] || value; |
| 123 } else if (update.type === 'iceGatheringStateChange') { |
| 124 value = { |
| 125 ICEGatheringStateNew: 'new', |
| 126 ICEGatheringStateGathering: 'gathering', |
| 127 ICEGatheringStateComplete: 'complete', |
| 128 }[value] || value; |
| 129 } else if (update.type === 'signalingStateChange') { |
| 130 value = { |
| 131 SignalingStateStable: 'stable', |
| 132 SignalingStateHaveLocalOffer: 'have-local-offer', |
| 133 SignalingStateHaveRemoteOffer: 'have-remote-offer', |
| 134 SignalingStateHaveLocalPrAnswer: 'have-local-pranswer', |
| 135 SignalingStateHaveRemotePrAnswer: 'have-remote-pranswer', |
| 136 SignalingStateClosed: 'closed', |
| 137 }[value] || value; |
| 138 } |
| 139 |
| 140 valueContainer.textContent = value; |
| 99 }, | 141 }, |
| 100 | 142 |
| 101 /** | 143 /** |
| 102 * Makes sure the update log table of the peer connection is created. | 144 * Makes sure the update log table of the peer connection is created. |
| 103 * | 145 * |
| 104 * @param {!Element} peerConnectionElement The root element. | 146 * @param {!Element} peerConnectionElement The root element. |
| 105 * @return {!Element} The log table element. | 147 * @return {!Element} The log table element. |
| 106 * @private | 148 * @private |
| 107 */ | 149 */ |
| 108 ensureUpdateContainer_: function(peerConnectionElement) { | 150 ensureUpdateContainer_: function(peerConnectionElement) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 120 tableContainer.appendChild(tableElement); | 162 tableContainer.appendChild(tableElement); |
| 121 tableElement.innerHTML = '<tr><th>Time</th>' + | 163 tableElement.innerHTML = '<tr><th>Time</th>' + |
| 122 '<th class="update-log-header-event">Event</th></tr>'; | 164 '<th class="update-log-header-event">Event</th></tr>'; |
| 123 } | 165 } |
| 124 return tableElement; | 166 return tableElement; |
| 125 } | 167 } |
| 126 }; | 168 }; |
| 127 | 169 |
| 128 return PeerConnectionUpdateTable; | 170 return PeerConnectionUpdateTable; |
| 129 })(); | 171 })(); |
| OLD | NEW |