Skip to content

Commit

Permalink
Merge pull request #15641 from Snuffleupagus/rm-PdfManager-onLoadedSt…
Browse files Browse the repository at this point in the history
…ream

Remove the `PdfManager.onLoadedStream` method (PR 15616 follow-up)
  • Loading branch information
timvandermeij authored Oct 29, 2022
2 parents 5b46400 + caef47a commit eeca44d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 24 deletions.
12 changes: 5 additions & 7 deletions src/core/chunked_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,6 @@ class ChunkedStreamManager {
this._loadedStreamCapability = createPromiseCapability();
}

onLoadedStream() {
return this._loadedStreamCapability.promise;
}

sendRequest(begin, end) {
const rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
if (!rangeReader.isStreamingSupported) {
Expand Down Expand Up @@ -327,9 +323,11 @@ class ChunkedStreamManager {
* Get all the chunks that are not yet loaded and group them into
* contiguous ranges to load in as few requests as possible.
*/
requestAllChunks() {
const missingChunks = this.stream.getMissingChunks();
this._requestChunks(missingChunks);
requestAllChunks(noFetch = false) {
if (!noFetch) {
const missingChunks = this.stream.getMissingChunks();
this._requestChunks(missingChunks);
}
return this._loadedStreamCapability.promise;
}

Expand Down
20 changes: 4 additions & 16 deletions src/core/pdf_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ class BasePdfManager {
return shadow(this, "docBaseUrl", catalog.baseUrl || this._docBaseUrl);
}

onLoadedStream() {
unreachable("Abstract method `onLoadedStream` called");
}

ensureDoc(prop, args) {
return this.ensure(this.pdfDocument, prop, args);
}
Expand Down Expand Up @@ -103,7 +99,7 @@ class BasePdfManager {
unreachable("Abstract method `requestRange` called");
}

requestLoadedStream() {
requestLoadedStream(noFetch = false) {
unreachable("Abstract method `requestLoadedStream` called");
}

Expand Down Expand Up @@ -156,11 +152,7 @@ class LocalPdfManager extends BasePdfManager {
return Promise.resolve();
}

requestLoadedStream() {
return this._loadedStreamPromise;
}

onLoadedStream() {
requestLoadedStream(noFetch = false) {
return this._loadedStreamPromise;
}

Expand Down Expand Up @@ -214,18 +206,14 @@ class NetworkPdfManager extends BasePdfManager {
return this.streamManager.requestRange(begin, end);
}

requestLoadedStream() {
return this.streamManager.requestAllChunks();
requestLoadedStream(noFetch = false) {
return this.streamManager.requestAllChunks(noFetch);
}

sendProgressiveData(chunk) {
this.streamManager.onReceiveData({ chunk });
}

onLoadedStream() {
return this.streamManager.onLoadedStream();
}

terminate(reason) {
this.streamManager.abort(reason);
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ class WorkerMessageHandler {
}
pdfManager = newPdfManager;

pdfManager.onLoadedStream().then(function (stream) {
pdfManager.requestLoadedStream(/* noFetch = */ true).then(stream => {
handler.send("DataLoaded", { length: stream.bytes.byteLength });
});
})
Expand Down

0 comments on commit eeca44d

Please sign in to comment.