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
3 // found in the LICENSE file.
7 * Provides the UI for dump creation.
9 var DumpCreator
= (function() {
11 * @param {Element} containerElement The parent element of the dump creation
15 function DumpCreator(containerElement
) {
17 * The root element of the dump creation UI.
21 this.root_
= document
.createElement('details');
23 this.root_
.className
= 'peer-connection-dump-root';
24 containerElement
.appendChild(this.root_
);
25 var summary
= document
.createElement('summary');
26 this.root_
.appendChild(summary
);
27 summary
.textContent
= 'Create Dump';
28 var content
= document
.createElement('div');
29 this.root_
.appendChild(content
);
31 content
.innerHTML
= '<div><a><button>' +
32 'Download the PeerConnection updates and stats data' +
33 '</button></a></div>' +
34 '<p><label><input type=checkbox>' +
35 'Enable diagnostic audio recordings.</label></p>' +
36 '<p>A diagnostic audio recording is used for analyzing audio' +
37 ' problems. It contains the audio played out from the speaker and' +
38 ' recorded from the microphone and is saved to the local disk.' +
39 ' Checking this box will enable the recording for an ongoing WebRTC' +
40 ' call and for future WebRTC calls. When the box is unchecked or this' +
41 ' page is closed, this recording functionality will be disabled for' +
42 ' future WebRTC calls, but an ongoing call will continue to record' +
43 ' until the call is ended. Only recording in one tab is supported.' +
44 ' If several tabs are running WebRTC calls, the resulting file will' +
45 ' be invalid. To restart the dump, the tab with the call being' +
46 ' recorded must be closed and recording disabled and enabled again.' +
47 ' When enabling, you select a file to save the dump to. Choose a' +
48 ' non-existing file name. Selecting an existing file will append to' +
49 ' it, not overwrite it, rendering the file invalid. </p>';
51 content
.getElementsByTagName('a')[0].addEventListener(
52 'click', this.onDownloadData_
.bind(this));
53 content
.getElementsByTagName('input')[0].addEventListener(
54 'click', this.onAecRecordingChanged_
.bind(this));
57 DumpCreator
.prototype = {
58 // Mark the AEC recording checkbox checked.
59 enableAecRecording: function() {
60 this.root_
.getElementsByTagName('input')[0].checked
= true;
63 // Mark the AEC recording checkbox unchecked.
64 disableAecRecording: function() {
65 this.root_
.getElementsByTagName('input')[0].checked
= false;
69 * Downloads the PeerConnection updates and stats data as a file.
73 onDownloadData_: function() {
76 'getUserMedia': userMediaRequests
,
77 'PeerConnections': peerConnectionDataStore
,
79 var textBlob
= new Blob([JSON
.stringify(dump_object
, null, ' ')],
80 {type
: 'octet/stream'});
81 var URL
= window
.URL
.createObjectURL(textBlob
);
83 this.root_
.getElementsByTagName('a')[0].href
= URL
;
84 // The default action of the anchor will download the URL.
88 * Handles the event of toggling the AEC recording state.
92 onAecRecordingChanged_: function() {
93 var enabled
= this.root_
.getElementsByTagName('input')[0].checked
;
95 chrome
.send('enableAecRecording');
97 chrome
.send('disableAecRecording');