Add a new FirefoxCom.requestAsync
method, to simplify the code in web/firefoxcom.js
#12802
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please note: I've tested this patch in a local Firefox build, to ensure that I didn't break anything here :-)
Convert
FirefoxCom
to a class, withstatic
methodsPlease note: It's highly recommended to ignore whitespace-only changes when looking at this patch.
Besides modernizing this code, by converting it to a standard class, the existing JSDoc comments are updated to actually agree better with the way that this functionality is used now. (The next patch will reduce usage of
FirefoxCom.request
significantly, hence the JSDocs for the optionalcallback
is removed to not unnecessarily advertise that functionality.)Finally, the unnecessary/unused
return
statement at the end ofFirefoxCom.request
is also removed.Add a new
FirefoxCom.requestAsync
method, to simplify the code inweb/firefoxcom.js
There's a fair number of cases where
FirefoxCom.request
-calls are manually wrapped in a Promise to make it asynchronous. We can reduce the amount of boilerplate code in these cases by introducing a newFirefoxCom.requestAsync
method instead.Furthermore, a couple of
FirefoxCom.request
-calls in theDownloadManager
are also changed to be asynchronous rather than using callback-functions.With this patch, we're thus able to replace a lot of direct usages of
FirefoxCom.request
with the newFirefoxCom.requestAsync
method instead.