зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1772101 - Part 27: Use plain object for lazy getter in toolkit/components/osfile/. r=mossop
Differential Revision: https://phabricator.services.mozilla.com/D147968
This commit is contained in:
Родитель
bef719c2d9
Коммит
517f335b43
|
@ -51,9 +51,11 @@ var Type = SysAll.Type;
|
||||||
|
|
||||||
var Path = ChromeUtils.import("resource://gre/modules/osfile/ospath.jsm");
|
var Path = ChromeUtils.import("resource://gre/modules/osfile/ospath.jsm");
|
||||||
|
|
||||||
|
const lazy = {};
|
||||||
|
|
||||||
// The library of promises.
|
// The library of promises.
|
||||||
ChromeUtils.defineModuleGetter(
|
ChromeUtils.defineModuleGetter(
|
||||||
this,
|
lazy,
|
||||||
"PromiseUtils",
|
"PromiseUtils",
|
||||||
"resource://gre/modules/PromiseUtils.jsm"
|
"resource://gre/modules/PromiseUtils.jsm"
|
||||||
);
|
);
|
||||||
|
@ -293,7 +295,7 @@ var Scheduler = {
|
||||||
// to an obsolete worker (we reactivate it in the `finally`).
|
// to an obsolete worker (we reactivate it in the `finally`).
|
||||||
// This needs to be done right now so that we maintain relative
|
// This needs to be done right now so that we maintain relative
|
||||||
// ordering with calls to post(), etc.
|
// ordering with calls to post(), etc.
|
||||||
let deferred = PromiseUtils.defer();
|
let deferred = lazy.PromiseUtils.defer();
|
||||||
let savedQueue = this.queue;
|
let savedQueue = this.queue;
|
||||||
this.queue = deferred.promise;
|
this.queue = deferred.promise;
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,13 @@ var { XPCOMUtils } = ChromeUtils.import(
|
||||||
"resource://gre/modules/XPCOMUtils.jsm"
|
"resource://gre/modules/XPCOMUtils.jsm"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const lazy = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The native service holding the implementation of the functions.
|
* The native service holding the implementation of the functions.
|
||||||
*/
|
*/
|
||||||
XPCOMUtils.defineLazyServiceGetter(
|
XPCOMUtils.defineLazyServiceGetter(
|
||||||
this,
|
lazy,
|
||||||
"Internals",
|
"Internals",
|
||||||
"@mozilla.org/toolkit/osfile/native-internals;1",
|
"@mozilla.org/toolkit/osfile/native-internals;1",
|
||||||
"nsINativeOSFileInternalsService"
|
"nsINativeOSFileInternalsService"
|
||||||
|
@ -58,7 +60,7 @@ var read = function(path, options = {}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
Internals.read(
|
lazy.Internals.read(
|
||||||
path,
|
path,
|
||||||
options,
|
options,
|
||||||
function onSuccess(success) {
|
function onSuccess(success) {
|
||||||
|
@ -105,7 +107,7 @@ var writeAtomic = function(path, buffer, options = {}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
Internals.writeAtomic(
|
lazy.Internals.writeAtomic(
|
||||||
path,
|
path,
|
||||||
buffer,
|
buffer,
|
||||||
options,
|
options,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче