[Pkg-javascript-commits] [pdf.js] 75/210: Remove LegacyPromise in src/core/worker.js
David Prévot
taffit at moszumanska.debian.org
Thu Jun 5 14:21:03 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch upstream
in repository pdf.js.
commit 87d38b0692489a2122cd744b4460c427abc51f5c
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date: Fri May 2 01:38:49 2014 +0200
Remove LegacyPromise in src/core/worker.js
---
src/core/pdf_manager.js | 9 +++++++--
src/core/worker.js | 37 ++++++++++++++++++-------------------
2 files changed, 25 insertions(+), 21 deletions(-)
diff --git a/src/core/pdf_manager.js b/src/core/pdf_manager.js
index 904670c..b390055 100644
--- a/src/core/pdf_manager.js
+++ b/src/core/pdf_manager.js
@@ -67,11 +67,16 @@ var BasePdfManager = (function BasePdfManagerClosure() {
updatePassword: function BasePdfManager_updatePassword(password) {
this.pdfDocument.xref.password = this.password = password;
- if (this.passwordChangedPromise) {
- this.passwordChangedPromise.resolve();
+ if (this._passwordChangedCapability) {
+ this._passwordChangedCapability.resolve();
}
},
+ passwordChanged: function BasePdfManager_passwordChanged() {
+ this._passwordChangedCapability = createPromiseCapability();
+ return this._passwordChangedCapability.promise;
+ },
+
terminate: function BasePdfManager_terminate() {
return new NotImplementedException();
}
diff --git a/src/core/worker.js b/src/core/worker.js
index 78a88f4..2b15e52 100644
--- a/src/core/worker.js
+++ b/src/core/worker.js
@@ -17,7 +17,7 @@
/* globals error, globalScope, InvalidPDFException, info,
MissingPDFException, PasswordException, PDFJS, Promise,
UnknownErrorException, NetworkManager, LocalPdfManager,
- NetworkPdfManager, XRefParseException, LegacyPromise,
+ NetworkPdfManager, XRefParseException, createPromiseCapability,
isInt, PasswordResponses, MessageHandler, Ref, RANGE_CHUNK_SIZE */
'use strict';
@@ -27,7 +27,7 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
var pdfManager;
function loadDocument(recoveryMode) {
- var loadDocumentPromise = new LegacyPromise();
+ var loadDocumentCapability = createPromiseCapability();
var parseSuccess = function parseSuccess() {
var numPagesPromise = pdfManager.ensureDoc('numPages');
@@ -50,13 +50,13 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
encrypted: !!results[5],
javaScript: results[6]
};
- loadDocumentPromise.resolve(doc);
+ loadDocumentCapability.resolve(doc);
},
parseFailure);
};
var parseFailure = function parseFailure(e) {
- loadDocumentPromise.reject(e);
+ loadDocumentCapability.reject(e);
};
pdfManager.ensureDoc('checkHeader', []).then(function() {
@@ -66,30 +66,30 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
}, parseFailure);
}, parseFailure);
- return loadDocumentPromise;
+ return loadDocumentCapability.promise;
}
function getPdfManager(data) {
- var pdfManagerPromise = new LegacyPromise();
+ var pdfManagerCapability = createPromiseCapability();
var source = data.source;
var disableRange = data.disableRange;
if (source.data) {
try {
pdfManager = new LocalPdfManager(source.data, source.password);
- pdfManagerPromise.resolve();
+ pdfManagerCapability.resolve();
} catch (ex) {
- pdfManagerPromise.reject(ex);
+ pdfManagerCapability.reject(ex);
}
- return pdfManagerPromise;
+ return pdfManagerCapability.promise;
} else if (source.chunkedViewerLoading) {
try {
pdfManager = new NetworkPdfManager(source, handler);
- pdfManagerPromise.resolve();
+ pdfManagerCapability.resolve();
} catch (ex) {
- pdfManagerPromise.reject(ex);
+ pdfManagerCapability.reject(ex);
}
- return pdfManagerPromise;
+ return pdfManagerCapability.promise;
}
var networkManager = new NetworkManager(source.url, {
@@ -134,9 +134,9 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
try {
pdfManager = new NetworkPdfManager(source, handler);
- pdfManagerPromise.resolve(pdfManager);
+ pdfManagerCapability.resolve(pdfManager);
} catch (ex) {
- pdfManagerPromise.reject(ex);
+ pdfManagerCapability.reject(ex);
}
},
@@ -144,9 +144,9 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
// the data is array, instantiating directly from it
try {
pdfManager = new LocalPdfManager(args.chunk, source.password);
- pdfManagerPromise.resolve();
+ pdfManagerCapability.resolve();
} catch (ex) {
- pdfManagerPromise.reject(ex);
+ pdfManagerCapability.reject(ex);
}
},
@@ -170,7 +170,7 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
}
});
- return pdfManagerPromise;
+ return pdfManagerCapability.promise;
}
handler.on('test', function wphSetupTest(data) {
@@ -253,8 +253,7 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
if (ex instanceof PasswordException) {
// after password exception prepare to receive a new password
// to repeat loading
- pdfManager.passwordChangedPromise = new LegacyPromise();
- pdfManager.passwordChangedPromise.then(pdfManagerReady);
+ pdfManager.passwordChanged().then(pdfManagerReady);
}
onFailure(ex);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git
More information about the Pkg-javascript-commits
mailing list