Skip to content

Simplify the NetworkManager class, and inline it in the PDFNetworkStream class#20595

Merged
timvandermeij merged 2 commits intomozilla:masterfrom
Snuffleupagus:NetworkManager-simplify
Jan 29, 2026
Merged

Simplify the NetworkManager class, and inline it in the PDFNetworkStream class#20595
timvandermeij merged 2 commits intomozilla:masterfrom
Snuffleupagus:NetworkManager-simplify

Conversation

@Snuffleupagus
Copy link
Collaborator

No description provided.

Store pending requests in a `WeakMap`, which allows working directly with the `XMLHttpRequest`-data and removes the need for a couple of methods.

Simplify the `PDFNetworkStreamRangeRequestReader.prototype._onDone` method, since after removing `moz-chunked-arraybuffer` support (see PR 10678) it's never called without an argument.

Stop sending the `begin`-property to the `onDone`-callbacks since it's unused. Originally this code was shared with the Firefox PDF Viewer, many years ago, and then that property mattered.

Re-factor the `status` validation, to avoid checking for a "bad" range-request response unconditionally.
…lass

The `NetworkManager` is very old code at this point, and it predates the introduction of the streaming functionality by many years.
To simplify things, especially with upcoming re-factoring patches, let's move this functionality into private (and semi-private) methods in the `PDFNetworkStream` class to avoid having to deal with too many different scopes.
@Snuffleupagus
Copy link
Collaborator Author

Given that the Fetch API is used by default, since many years, running the unit-tests ought to suffice here.

/botio unittest

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_unittest from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.241.84.105:8877/72bb424af01c2ba/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

Command cmd_unittest from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.193.163.58:8877/04397e20c76c2b1/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/72bb424af01c2ba/output.txt

Total script time: 2.72 mins

  • Unit Tests: Passed

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/04397e20c76c2b1/output.txt

Total script time: 8.49 mins

  • Unit Tests: FAILED

@timvandermeij timvandermeij merged commit 7cdd03a into mozilla:master Jan 29, 2026
10 checks passed
@timvandermeij
Copy link
Contributor

Nice improvement; thanks!

@timvandermeij timvandermeij removed the request for review from calixteman January 29, 2026 20:57
@Snuffleupagus Snuffleupagus deleted the NetworkManager-simplify branch February 1, 2026 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants