author | Shih-Chiang Chien <schien@mozilla.com> |
Fri, 25 Oct 2013 20:04:57 -0400 | |
changeset 166133 | eef27ae8eb3a8e185c89c99a82d36fdd9fc7ee1d |
parent 166132 | 8f125ace663169b472dfb6f64fe3e0cdef963109 |
child 166134 | c37be651071ce167b0f18cfe23a5d28637c61a24 |
push id | 3066 |
push user | akeybl@mozilla.com |
push date | Mon, 09 Dec 2013 19:58:46 +0000 |
treeherder | mozilla-beta@a31a0dce83aa [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | vingtetun, jesup |
bugs | 926289 |
milestone | 27.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/b2g/chrome/content/shell.js +++ b/b2g/chrome/content/shell.js @@ -1254,70 +1254,89 @@ window.addEventListener('ContentStart', type: 'visible-audio-channel-changed', channel: aData }); shell.visibleNormalAudioActive = (aData == 'normal'); }, "visible-audio-channel-changed", false); })(); (function recordingStatusTracker() { - let gRecordingActiveCount = 0; + // Recording status is tracked per process with following data structure: + // {<processId>: {count: <N>, + // requestURL: <requestURL>, + // isApp: <isApp>, + // audioCount: <N>, + // videoCount: <N>}} let gRecordingActiveProcesses = {}; let recordingHandler = function(aSubject, aTopic, aData) { - let oldCount = gRecordingActiveCount; - - let processId = (!aSubject) ? 'main' - : aSubject.QueryInterface(Ci.nsIPropertyBag2).get('childID'); + let props = aSubject.QueryInterface(Ci.nsIPropertyBag2); + let processId = (props.hasKey('childID')) ? props.get('childID') + : 'main'; if (processId && !gRecordingActiveProcesses.hasOwnProperty(processId)) { - gRecordingActiveProcesses[processId] = 0; + gRecordingActiveProcesses[processId] = {count: 0, + requestURL: props.get('requestURL'), + isApp: props.get('isApp'), + audioCount: 0, + videoCount: 0 }; } let currentActive = gRecordingActiveProcesses[processId]; + let wasActive = (currentActive['count'] > 0); + let wasAudioActive = (currentActive['audioCount'] > 0); + let wasVideoActive = (currentActive['videoCount'] > 0); + switch (aData) { case 'starting': - gRecordingActiveCount++; - currentActive++; + currentActive['count']++; + currentActive['audioCount'] += (props.get('isAudio')) ? 1 : 0; + currentActive['videoCount'] += (props.get('isVideo')) ? 1 : 0; break; case 'shutdown': - // Bug 928206 will make shutdown be sent even if no starting. - if (currentActive > 0) { - gRecordingActiveCount--; - currentActive--; - } + currentActive['count']--; + currentActive['audioCount'] -= (props.get('isAudio')) ? 1 : 0; + currentActive['videoCount'] -= (props.get('isVideo')) ? 1 : 0; break; case 'content-shutdown': - gRecordingActiveCount -= currentActive; - currentActive = 0; + currentActive['count'] = 0; + currentActive['audioCount'] = 0; + currentActive['videoCount'] = 0; break; } - if (currentActive > 0) { + if (currentActive['count'] > 0) { gRecordingActiveProcesses[processId] = currentActive; } else { delete gRecordingActiveProcesses[processId]; } - // We need to track changes from N <-> 0 - if ((oldCount === 0 && gRecordingActiveCount > 0) || - (gRecordingActiveCount === 0 && oldCount > 0)) { + // We need to track changes if any active state is changed. + let isActive = (currentActive['count'] > 0); + let isAudioActive = (currentActive['audioCount'] > 0); + let isVideoActive = (currentActive['videoCount'] > 0); + if ((isActive != wasActive) || + (isAudioActive != wasAudioActive) || + (isVideoActive != wasVideoActive)) { shell.sendChromeEvent({ type: 'recording-status', - active: (gRecordingActiveCount > 0) + active: isActive, + requestURL: currentActive['requestURL'], + isApp: currentActive['isApp'], + isAudio: isAudioActive, + isVideo: isVideoActive }); } }; Services.obs.addObserver(recordingHandler, 'recording-device-events', false); Services.obs.addObserver(recordingHandler, 'recording-device-ipc-events', false); Services.obs.addObserver(function(aSubject, aTopic, aData) { // send additional recording events if content process is being killed - let props = aSubject.QueryInterface(Ci.nsIPropertyBag2); - let childId = aSubject.get('childID'); - if (gRecordingActiveProcesses.hasOwnProperty(childId) >= 0) { + let processId = aSubject.QueryInterface(Ci.nsIPropertyBag2).get('childID'); + if (gRecordingActiveProcesses.hasOwnProperty(processId)) { Services.obs.notifyObservers(aSubject, 'recording-device-ipc-events', 'content-shutdown'); } }, 'ipc:content-shutdown', false); })(); (function volumeStateTracker() { Services.obs.addObserver(function(aSubject, aTopic, aData) { shell.sendChromeEvent({