mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Uses postMessage transfers
This commit is contained in:
parent
945e370d4f
commit
4ce6cb8b0f
6 changed files with 95 additions and 12 deletions
|
@ -1104,6 +1104,7 @@ function MessageHandler(name, comObj) {
|
|||
this.name = name;
|
||||
this.comObj = comObj;
|
||||
this.callbackIndex = 1;
|
||||
this.postMessageTransfers = true;
|
||||
var callbacks = this.callbacks = {};
|
||||
var ah = this.actionHandler = {};
|
||||
|
||||
|
@ -1170,8 +1171,9 @@ MessageHandler.prototype = {
|
|||
* @param {String} actionName Action to call.
|
||||
* @param {JSON} data JSON data to send.
|
||||
* @param {function} [callback] Optional callback that will handle a reply.
|
||||
* @param {Array} [transfers] Optional list of transfers/ArrayBuffers
|
||||
*/
|
||||
send: function messageHandlerSend(actionName, data, callback) {
|
||||
send: function messageHandlerSend(actionName, data, callback, transfers) {
|
||||
var message = {
|
||||
action: actionName,
|
||||
data: data
|
||||
|
@ -1181,7 +1183,11 @@ MessageHandler.prototype = {
|
|||
this.callbacks[callbackId] = callback;
|
||||
message.callbackId = callbackId;
|
||||
}
|
||||
this.comObj.postMessage(message);
|
||||
if (transfers && this.postMessageTransfers) {
|
||||
this.comObj.postMessage(message, transfers);
|
||||
} else {
|
||||
this.comObj.postMessage(message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue