Skip to content

Instantly share code, notes, and snippets.

@agi90
Created June 29, 2020 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save agi90/cd8fbd5dcfa8131db279ff9384c6ab5c to your computer and use it in GitHub Desktop.
Save agi90/cd8fbd5dcfa8131db279ff9384c6ab5c to your computer and use it in GitHub Desktop.
class AppDownload {
WebExtension.DownloadItem mExtensionDownload;
// Cancels the download
GeckoResult<Void> cancel() {
// Actually cancel the download
// Notifies extension
return mExtensionDownload.update().canceled(true).commit();
}
void setDownloadItem(DownloadItem item) {
mExtensionDownload = item;
}
}
class AppDownloadController {
// stuff ...
@Override
onCancel(DownloadItem item, WebExtension extension) {
AppDownload download = mDownloads.byDownloadItem(item);
// Update the download item in case it's out of date
download.setDownloadItem(item);
return download.cancel();
}
}
// UI Code
onClick() {
mDownload.cancel();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment