mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1821299 - Convert toolkit/components/bitsdownload to ES modules. r=Standard8,application-update-reviewers,nalexander
Differential Revision: https://phabricator.services.mozilla.com/D172248
This commit is contained in:
parent
d38e6e9100
commit
b6a523e8e1
@ -14,14 +14,8 @@
|
||||
* provided by nsIBits via Promises rather than callbacks.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const { AppConstants } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/AppConstants.sys.mjs"
|
||||
);
|
||||
const { XPCOMUtils } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/XPCOMUtils.sys.mjs"
|
||||
);
|
||||
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
|
||||
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
|
||||
|
||||
const lazy = {};
|
||||
|
||||
@ -60,7 +54,7 @@ const kBitsMethodTimeoutMs = 10 * 60 * 1000; // 10 minutes
|
||||
* It may be null, a number (corresponding to an nsresult or hresult value),
|
||||
* a string, or an exception.
|
||||
*/
|
||||
class BitsError extends Error {
|
||||
export class BitsError extends Error {
|
||||
// If codeType == "none", code may be unspecified.
|
||||
constructor(type, action, stage, codeType, code) {
|
||||
let message =
|
||||
@ -101,7 +95,7 @@ class BitsError extends Error {
|
||||
|
||||
// These specializations exist to make them easier to construct since they may
|
||||
// need to be constructed outside of this file.
|
||||
class BitsVerificationError extends BitsError {
|
||||
export class BitsVerificationError extends BitsError {
|
||||
constructor() {
|
||||
super(
|
||||
Ci.nsIBits.ERROR_TYPE_VERIFICATION_FAILURE,
|
||||
@ -111,7 +105,8 @@ class BitsVerificationError extends BitsError {
|
||||
);
|
||||
}
|
||||
}
|
||||
class BitsUnknownError extends BitsError {
|
||||
|
||||
export class BitsUnknownError extends BitsError {
|
||||
constructor() {
|
||||
super(
|
||||
Ci.nsIBits.ERROR_TYPE_UNKNOWN,
|
||||
@ -239,7 +234,7 @@ async function requestPromise(errorAction, actionFn) {
|
||||
* Getter methods (except loadGroup and loadFlags) should continue to be
|
||||
* accessible, even after shutdown.
|
||||
*/
|
||||
class BitsRequest {
|
||||
export class BitsRequest {
|
||||
constructor(request) {
|
||||
this._request = request;
|
||||
this._request.QueryInterface(Ci.nsIBitsRequest);
|
||||
@ -581,6 +576,7 @@ class BitsRequest {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
BitsRequest.prototype.QueryInterface = ChromeUtils.generateQI(["nsIRequest"]);
|
||||
|
||||
/**
|
||||
@ -762,7 +758,7 @@ async function servicePromise(errorAction, observer, actionFn) {
|
||||
});
|
||||
}
|
||||
|
||||
var Bits = {
|
||||
export var Bits = {
|
||||
/**
|
||||
* This function wraps nsIBits::initialized.
|
||||
*/
|
||||
@ -828,12 +824,3 @@ var Bits = {
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
const EXPORTED_SYMBOLS = [
|
||||
"Bits",
|
||||
"BitsError",
|
||||
"BitsRequest",
|
||||
"BitsSuccess",
|
||||
"BitsUnknownError",
|
||||
"BitsVerificationError",
|
||||
];
|
@ -19,7 +19,7 @@ if CONFIG["MOZ_BITS_DOWNLOAD"]:
|
||||
UNIFIED_SOURCES += ["Bits.cpp"]
|
||||
|
||||
EXTRA_JS_MODULES += [
|
||||
"Bits.jsm",
|
||||
"Bits.sys.mjs",
|
||||
]
|
||||
|
||||
FINAL_LIBRARY = "xul"
|
||||
|
@ -25,7 +25,7 @@ typedef long nsBitsErrorStage;
|
||||
* It would be preferable for the functions in this interface to return
|
||||
* Promises, but this interface is implemented in Rust, which does not yet have
|
||||
* support for Promises. There is a JS wrapper around this class that should be
|
||||
* preferred over using this interface directly, located in Bits.jsm.
|
||||
* preferred over using this interface directly, located in Bits.sys.mjs.
|
||||
*
|
||||
* Methods of this class that take a nsIBitsNewRequestCallback do not return or
|
||||
* throw errors. All errors will be reported through the callback. The only
|
||||
@ -274,7 +274,7 @@ interface nsIBitsNewRequestCallback : nsISupports
|
||||
* It would be preferable for the functions in this interface to return
|
||||
* Promises, but this interface is implemented in Rust, which does not yet have
|
||||
* support for Promises. There is a JS wrapper around this class that should be
|
||||
* preferred over using this interface directly, located in Bits.jsm.
|
||||
* preferred over using this interface directly, located in Bits.sys.mjs.
|
||||
*
|
||||
* Methods of this class that take a nsIBitsCallback do not return or throw
|
||||
* errors. All errors will be reported through the callback. The only
|
||||
|
@ -7,12 +7,12 @@
|
||||
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
|
||||
import { AUSTLMY } from "resource://gre/modules/UpdateTelemetry.sys.mjs";
|
||||
|
||||
const {
|
||||
import {
|
||||
Bits,
|
||||
BitsRequest,
|
||||
BitsUnknownError,
|
||||
BitsVerificationError,
|
||||
} = ChromeUtils.import("resource://gre/modules/Bits.jsm");
|
||||
} from "resource://gre/modules/Bits.sys.mjs";
|
||||
import { FileUtils } from "resource://gre/modules/FileUtils.sys.mjs";
|
||||
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
|
||||
|
||||
|
@ -4,9 +4,10 @@
|
||||
|
||||
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
|
||||
|
||||
const { BitsError, BitsUnknownError } = ChromeUtils.import(
|
||||
"resource://gre/modules/Bits.jsm"
|
||||
);
|
||||
import {
|
||||
BitsError,
|
||||
BitsUnknownError,
|
||||
} from "resource://gre/modules/Bits.sys.mjs";
|
||||
|
||||
export var AUSTLMY = {
|
||||
// Telemetry for the application update background update check occurs when
|
||||
|
Loading…
Reference in New Issue
Block a user