Remove the PdfManager.onLoadedStream
method (PR 15616 follow-up)
After the clean-up in PR 15616, the `PdfManager.onLoadedStream` method now only has a single call-site. Hence why this patch suggests that we remove this method and replace it with an *optional* parameter in `PdfManager.requestLoadedStream` instead. By making the new behaviour opt-in, we'll thus not change any existing call-site.
This commit is contained in:
parent
5b46400240
commit
caef47a0cf
@ -282,10 +282,6 @@ class ChunkedStreamManager {
|
|||||||
this._loadedStreamCapability = createPromiseCapability();
|
this._loadedStreamCapability = createPromiseCapability();
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoadedStream() {
|
|
||||||
return this._loadedStreamCapability.promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
sendRequest(begin, end) {
|
sendRequest(begin, end) {
|
||||||
const rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
|
const rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
|
||||||
if (!rangeReader.isStreamingSupported) {
|
if (!rangeReader.isStreamingSupported) {
|
||||||
@ -327,9 +323,11 @@ class ChunkedStreamManager {
|
|||||||
* Get all the chunks that are not yet loaded and group them into
|
* Get all the chunks that are not yet loaded and group them into
|
||||||
* contiguous ranges to load in as few requests as possible.
|
* contiguous ranges to load in as few requests as possible.
|
||||||
*/
|
*/
|
||||||
requestAllChunks() {
|
requestAllChunks(noFetch = false) {
|
||||||
|
if (!noFetch) {
|
||||||
const missingChunks = this.stream.getMissingChunks();
|
const missingChunks = this.stream.getMissingChunks();
|
||||||
this._requestChunks(missingChunks);
|
this._requestChunks(missingChunks);
|
||||||
|
}
|
||||||
return this._loadedStreamCapability.promise;
|
return this._loadedStreamCapability.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,10 +55,6 @@ class BasePdfManager {
|
|||||||
return shadow(this, "docBaseUrl", catalog.baseUrl || this._docBaseUrl);
|
return shadow(this, "docBaseUrl", catalog.baseUrl || this._docBaseUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoadedStream() {
|
|
||||||
unreachable("Abstract method `onLoadedStream` called");
|
|
||||||
}
|
|
||||||
|
|
||||||
ensureDoc(prop, args) {
|
ensureDoc(prop, args) {
|
||||||
return this.ensure(this.pdfDocument, prop, args);
|
return this.ensure(this.pdfDocument, prop, args);
|
||||||
}
|
}
|
||||||
@ -103,7 +99,7 @@ class BasePdfManager {
|
|||||||
unreachable("Abstract method `requestRange` called");
|
unreachable("Abstract method `requestRange` called");
|
||||||
}
|
}
|
||||||
|
|
||||||
requestLoadedStream() {
|
requestLoadedStream(noFetch = false) {
|
||||||
unreachable("Abstract method `requestLoadedStream` called");
|
unreachable("Abstract method `requestLoadedStream` called");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,11 +152,7 @@ class LocalPdfManager extends BasePdfManager {
|
|||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
requestLoadedStream() {
|
requestLoadedStream(noFetch = false) {
|
||||||
return this._loadedStreamPromise;
|
|
||||||
}
|
|
||||||
|
|
||||||
onLoadedStream() {
|
|
||||||
return this._loadedStreamPromise;
|
return this._loadedStreamPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,18 +206,14 @@ class NetworkPdfManager extends BasePdfManager {
|
|||||||
return this.streamManager.requestRange(begin, end);
|
return this.streamManager.requestRange(begin, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
requestLoadedStream() {
|
requestLoadedStream(noFetch = false) {
|
||||||
return this.streamManager.requestAllChunks();
|
return this.streamManager.requestAllChunks(noFetch);
|
||||||
}
|
}
|
||||||
|
|
||||||
sendProgressiveData(chunk) {
|
sendProgressiveData(chunk) {
|
||||||
this.streamManager.onReceiveData({ chunk });
|
this.streamManager.onReceiveData({ chunk });
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoadedStream() {
|
|
||||||
return this.streamManager.onLoadedStream();
|
|
||||||
}
|
|
||||||
|
|
||||||
terminate(reason) {
|
terminate(reason) {
|
||||||
this.streamManager.abort(reason);
|
this.streamManager.abort(reason);
|
||||||
}
|
}
|
||||||
|
@ -420,7 +420,7 @@ class WorkerMessageHandler {
|
|||||||
}
|
}
|
||||||
pdfManager = newPdfManager;
|
pdfManager = newPdfManager;
|
||||||
|
|
||||||
pdfManager.onLoadedStream().then(function (stream) {
|
pdfManager.requestLoadedStream(/* noFetch = */ true).then(stream => {
|
||||||
handler.send("DataLoaded", { length: stream.bytes.byteLength });
|
handler.send("DataLoaded", { length: stream.bytes.byteLength });
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user