Files
palemoon27/dom/requestsync/RequestSyncManager.js
T
roytam1 10f5941b9c import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1246051 - have MediaQueue<T>::Peek/PeekFront return a RefPtr<> to avoid dangling pointers per comment 0. r=gerald. (00f334efb1)
- Bug 1264199: P1. Perform audio conversion in the MSDM taskqueue and ahead of use. r=kinetik (001936e3ea)
- Bug 1267983 - include MediaQueue.h; r=jwwang (036107d765)
- Bug 1264199: P0. Fix nsDequeue/MediaQueue methods constness. r=jwwang (9aa33dfcb5)
- Bug 1264199: P0.1. Export SaferMultDiv method. r=gerald (0b7a35ae4d)
- Bug 1264199: P2. Ensure the AudioStream only ever receive the same content format. r=kinetik (a180d09279)
- Bug 1264199: P3. Attempt to minimize audio quality loss and unnecessary processing. r=kinetik (29d57b5a33)
- Bug 1264199: P4. Add mono to stereo upmix to AudioConverter. r=rillian (49c029bd86)
- Bug 1264199: P5. Perform all downmixing operations in DecodedAudioDataSink. r=kinetik (05a479f095)
- Bug 1264199: P6. Drain resampler when changing format or reaching the end. r=kinetik (8639102a94)
- Bug 1264199: P8. Handle potential resampling errors. r=kinetik (1267e4e73d)
- Bug 1264199: P9. Include pending frames in HasUnplayedFrames calculation. r=jwwang (ce7097fc90)
2024-08-28 23:32:14 +08:00

135 lines
4.1 KiB
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
'use strict';
function debug(s) {
//dump('DEBUG RequestSyncManager: ' + s + '\n');
}
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
Cu.import('resource://gre/modules/RequestSyncApp.jsm');
Cu.import('resource://gre/modules/RequestSyncTask.jsm');
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
"@mozilla.org/childprocessmessagemanager;1",
"nsIMessageSender");
function RequestSyncManager() {
debug('created');
}
RequestSyncManager.prototype = {
__proto__: DOMRequestIpcHelper.prototype,
classDescription: 'RequestSyncManager XPCOM Component',
classID: Components.ID('{e6f55080-e549-4e30-9d00-15f240fb763c}'),
contractID: '@mozilla.org/dom/request-sync-manager;1',
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference,
Ci.nsIObserver,
Ci.nsIDOMGlobalPropertyInitializer]),
_messages: [ "RequestSyncManager:Registrations:Return",
"RequestSyncManager:SetPolicy:Return",
"RequestSyncManager:RunTask:Return" ],
init: function(aWindow) {
debug("init");
// DOMRequestIpcHelper.initHelper sets this._window
this.initDOMRequestHelper(aWindow, this._messages);
},
sendMessage: function(aMsg, aObj) {
let self = this;
return this.createPromiseWithId(function(aResolverId) {
aObj.requestID = aResolverId;
cpmm.sendAsyncMessage(aMsg, aObj, null,
self._window.document.nodePrincipal);
});
},
registrations: function() {
debug('registrations');
return this.sendMessage("RequestSyncManager:Registrations", {});
},
setPolicy: function(aTask, aOrigin, aManifestURL, aIsInIsolatedMozBrowserElement,
aState, aOverwrittenMinInterval) {
debug('setPolicy');
return this.sendMessage("RequestSyncManager:SetPolicy",
{ task: aTask,
origin: aOrigin,
manifestURL: aManifestURL,
isInBrowserElement: aIsInIsolatedMozBrowserElement,
state: aState,
overwrittenMinInterval: aOverwrittenMinInterval });
},
runTask: function(aTask, aOrigin, aManifestURL, aIsInIsolatedMozBrowserElement) {
debug('runTask');
return this.sendMessage("RequestSyncManager:RunTask",
{ task: aTask,
origin: aOrigin,
manifestURL: aManifestURL,
isInBrowserElement: aIsInIsolatedMozBrowserElement });
},
registrationsResult: function(aData) {
debug("registrationsResult");
let results = new this._window.Array();
for (let i = 0; i < aData.length; ++i) {
if (!("app" in aData[i])) {
dump("ERROR - Serialization error in RequestSyncManager.\n");
continue;
}
let app = new RequestSyncApp(aData[i].app);
let exposedApp =
this._window.RequestSyncApp._create(this._window, app);
let task = new RequestSyncTask(this, this._window, exposedApp, aData[i]);
let exposedTask =
this._window.RequestSyncTask._create(this._window, task);
results.push(exposedTask);
}
return results;
},
receiveMessage: function(aMessage) {
debug('receiveMessage');
let req = this.getPromiseResolver(aMessage.data.requestID);
if (!req) {
return;
}
if ('error' in aMessage.data) {
req.reject(Cu.cloneInto(aMessage.data.error, this._window));
return;
}
if (aMessage.name == 'RequestSyncManager:Registrations:Return') {
req.resolve(this.registrationsResult(aMessage.data.results));
return;
}
if ('results' in aMessage.data) {
req.resolve(Cu.cloneInto(aMessage.data.results, this._window));
return;
}
req.resolve();
}
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RequestSyncManager]);