Provide API to cancel WebExtensionController.install
Categories
(GeckoView :: Extensions, enhancement, P1)
Tracking
(Not tracked)
People
(Reporter: csadilek, Assigned: twisniewski)
References
Details
(Whiteboard: [geckoview:m75][geckoview:m76])
Attachments
(2 files, 1 obsolete file)
This is so Fenix can display a cancel option while installing add-ons.
Updated•6 years ago
|
There are a couple ways to do this, but I think perhaps the most generally useful way would be to introduce a new GeckoCancelableResult
, and return that from install()
. It would look something like:
public abstract class GeckoCancelableResult extends GeckoResult {
public GeckoResult<boolean> cancel();
}
The semantics are where things get tricky, but I think we should try to be close to CompletableFuture
here. After all, we'd probably be using that directly if we could. CompletableFuture#cancel()
[1] causes the future to be completed with a CancelationException
if it has not already been completed. So a more complete impl would look like:
public abstract class GeckoCancelableResult extends GeckoResult {
public GeckoResult<boolean> cancel() {
completeExceptionally(new CancelationException());
return GeckoResult.fromValue(true);
}
}
I think we should keep this class abstract
so we don't have cancel()
methods that are noops that appear to succeed. We'll then need subclasses for individual cancelable operations, and the subclass would return super.cancel()
once they had completed the work necessary to cancel the operation. Nothing stops someone from doing super.cancel()
directly, I guess, but at least they will feel bad.
Assignee | ||
Comment 2•5 years ago
|
||
Unfortunately, the subclass approach in comment 1 won't be pretty, because GeckoResult internally instantiates GeckoResults (not the correct subclass) when calling methods like then
. As such, snorp and I decided to just add a cancel
method to GeckoResult for now and prevent that mess.
Assignee | ||
Comment 3•5 years ago
|
||
Assignee | ||
Comment 4•5 years ago
|
||
After quite a bit of back-and-forth with snorp, we've decided that using GeckoResult in this way just isn't tenable right now; it's not really designed to be used this way. For now, we'll just add a WebExtensionController.cancelInstall
method which accepts the GeckoResults returned by .install()
. A try-run of this approach seems fine: https://treeherder.mozilla.org/#/jobs?repo=try&revision=a948dbf2bfd9c6d73d56984b685b2074583e54b0
Updated•5 years ago
|
Assignee | ||
Comment 5•5 years ago
|
||
add WebExtensionController.cancelInstall(GeckoResult<WebExtension>), accepting the GeckoResults returned by .install()
Updated•5 years ago
|
Updated•5 years ago
|
Only part of this has landed, so adding leave-open
Comment 9•5 years ago
|
||
bugherder |
Updated•5 years ago
|
Comment 10•5 years ago
|
||
Comment 11•5 years ago
|
||
bugherder |
Updated•5 years ago
|
Updated•1 year ago
|
Description
•