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

Side by Side Diff: tools/perf/page_sets/webrtc_track_peerconnections.js

Issue 2450803002: Expose unprefixed RTCPeerConnection (Closed)
Patch Set: Update webrtc_track_peerconnections.js Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.idl ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 // This file overwrites the webkitRTCPeerConnection constructor with a 5 // This file overwrites the RTCPeerConnection constructor with a new constructor
6 // new constructor which tracks all created connections. It does this by 6 // which tracks all created connections. It does this by periodically gathering
7 // periodically gathering statistics on all connections, using the WebRTC 7 // statistics on all connections, using the WebRTC statistics API. All reports
8 // statistics API. All reports are gathered into window.peerConnectionReports, 8 // are gathered into window.peerConnectionReports, which contains one list per
9 // which contains one list per connection. In each list there is a number of 9 // connection. In each list there is a number of report batches, which in turn
10 // report batches, which in turn contains metric names mapped to values. 10 // contains metric names mapped to values.
11 11
12 window.peerConnectionReports = []; 12 window.peerConnectionReports = [];
13 13
14 webkitRTCPeerConnection = (function() { 14 RTCPeerConnection = webkitRTCPeerConnection = (function() {
15 function getReportsAsDicts(getStatsResult) { 15 function getReportsAsDicts(getStatsResult) {
16 var result = []; 16 var result = [];
17 getStatsResult.forEach(function(report) { 17 getStatsResult.forEach(function(report) {
18 var values = {}; 18 var values = {};
19 report.names().forEach(function(name) { 19 report.names().forEach(function(name) {
20 values[name] = report.stat(name); 20 values[name] = report.stat(name);
21 }); 21 });
22 result.push(values); 22 result.push(values);
23 }); 23 });
24 return result; 24 return result;
25 } 25 }
26 26
27 function gatherStatsFromOneConnection(peerConnection) { 27 function gatherStatsFromOneConnection(peerConnection) {
28 var connectionId = window.peerConnectionReports.length; 28 var connectionId = window.peerConnectionReports.length;
29 window.peerConnectionReports.push([]); 29 window.peerConnectionReports.push([]);
30 var pollIntervalMs = 1000; 30 var pollIntervalMs = 1000;
31 31
32 setInterval(function() { 32 setInterval(function() {
33 peerConnection.getStats(function(response) { 33 peerConnection.getStats(function(response) {
34 var reports = getReportsAsDicts(response.result()); 34 var reports = getReportsAsDicts(response.result());
35 window.peerConnectionReports[connectionId].push(reports); 35 window.peerConnectionReports[connectionId].push(reports);
36 }); 36 });
37 }, pollIntervalMs); 37 }, pollIntervalMs);
38 } 38 }
39 39
40 var originalConstructor = webkitRTCPeerConnection; 40 var originalConstructor = RTCPeerConnection;
41 return function() { 41 return function() {
42 // Bind the incoming arguments to the original constructor. 42 // Bind the incoming arguments to the original constructor.
43 var args = [null].concat(Array.prototype.slice.call(arguments)); 43 var args = [null].concat(Array.prototype.slice.call(arguments));
44 var factoryFunction = originalConstructor.bind.apply( 44 var factoryFunction = originalConstructor.bind.apply(
45 originalConstructor, args); 45 originalConstructor, args);
46 46
47 // Create the object and track it. 47 // Create the object and track it.
48 var peerConnection = new factoryFunction(); 48 var peerConnection = new factoryFunction();
49 gatherStatsFromOneConnection(peerConnection); 49 gatherStatsFromOneConnection(peerConnection);
50 return peerConnection; 50 return peerConnection;
51 } 51 }
52 })(); 52 })();
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698