mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 01:58:06 +02:00
Cleanup: removing main thread loading fallback code
This commit is contained in:
parent
0dd445bf18
commit
0b1111f368
2 changed files with 4 additions and 54 deletions
|
@ -3,8 +3,6 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
var useMainThreadToDownload = false;
|
||||
|
||||
function MessageHandler(name, comObj) {
|
||||
this.name = name;
|
||||
this.comObj = comObj;
|
||||
|
@ -85,9 +83,8 @@ MessageHandler.prototype = {
|
|||
var WorkerMessageHandler = {
|
||||
setup: function wphSetup(handler) {
|
||||
var pdfModel = null;
|
||||
var pdfModelSource = null;
|
||||
|
||||
function loadDocument(pdfData) {
|
||||
function loadDocument(pdfData, pdfModelSource) {
|
||||
// Create only the model of the PDFDoc, which is enough for
|
||||
// processing the content of the pdf.
|
||||
var pdfPassword = pdfModelSource.password;
|
||||
|
@ -127,28 +124,13 @@ var WorkerMessageHandler = {
|
|||
});
|
||||
|
||||
handler.on('GetDocRequest', function wphSetupDoc(data) {
|
||||
var pdfData = data.data;
|
||||
loadDocument(pdfData);
|
||||
});
|
||||
|
||||
handler.on('FetchDocRequest', function wphSetupFetchDoc(data) {
|
||||
var source = data.source;
|
||||
pdfModelSource = source;
|
||||
|
||||
if (source.data) {
|
||||
// the data is array, instantiating directly from it
|
||||
loadDocument(source.data);
|
||||
loadDocument(source.data, source);
|
||||
return;
|
||||
}
|
||||
|
||||
if (useMainThreadToDownload) {
|
||||
// fallback to main thread to download PDF
|
||||
handler.send('FetchDoc', {
|
||||
url: source.url,
|
||||
httpHeaders: source.httpHeaders
|
||||
});
|
||||
}
|
||||
|
||||
PDFJS.getPdf(
|
||||
{
|
||||
url: source.url,
|
||||
|
@ -167,7 +149,7 @@ var WorkerMessageHandler = {
|
|||
headers: source.httpHeaders
|
||||
},
|
||||
function getPDFLoad(data) {
|
||||
loadDocument(data);
|
||||
loadDocument(data, source);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue