From 517f335b436cc876fc8b6bea015343a5d33b33d8 Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Tue, 7 Jun 2022 04:31:00 +0000 Subject: [PATCH] Bug 1772101 - Part 27: Use plain object for lazy getter in toolkit/components/osfile/. r=mossop Differential Revision: https://phabricator.services.mozilla.com/D147968 --- toolkit/components/osfile/modules/osfile_async_front.jsm | 6 ++++-- toolkit/components/osfile/modules/osfile_native.jsm | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/toolkit/components/osfile/modules/osfile_async_front.jsm b/toolkit/components/osfile/modules/osfile_async_front.jsm index 81bd99e481c4..69b789cef2b1 100644 --- a/toolkit/components/osfile/modules/osfile_async_front.jsm +++ b/toolkit/components/osfile/modules/osfile_async_front.jsm @@ -51,9 +51,11 @@ var Type = SysAll.Type; var Path = ChromeUtils.import("resource://gre/modules/osfile/ospath.jsm"); +const lazy = {}; + // The library of promises. ChromeUtils.defineModuleGetter( - this, + lazy, "PromiseUtils", "resource://gre/modules/PromiseUtils.jsm" ); @@ -293,7 +295,7 @@ var Scheduler = { // to an obsolete worker (we reactivate it in the `finally`). // This needs to be done right now so that we maintain relative // ordering with calls to post(), etc. - let deferred = PromiseUtils.defer(); + let deferred = lazy.PromiseUtils.defer(); let savedQueue = this.queue; this.queue = deferred.promise; diff --git a/toolkit/components/osfile/modules/osfile_native.jsm b/toolkit/components/osfile/modules/osfile_native.jsm index 41725aacd641..652455a458cb 100644 --- a/toolkit/components/osfile/modules/osfile_native.jsm +++ b/toolkit/components/osfile/modules/osfile_native.jsm @@ -30,11 +30,13 @@ var { XPCOMUtils } = ChromeUtils.import( "resource://gre/modules/XPCOMUtils.jsm" ); +const lazy = {}; + /** * The native service holding the implementation of the functions. */ XPCOMUtils.defineLazyServiceGetter( - this, + lazy, "Internals", "@mozilla.org/toolkit/osfile/native-internals;1", "nsINativeOSFileInternalsService" @@ -58,7 +60,7 @@ var read = function(path, options = {}) { } return new Promise((resolve, reject) => { - Internals.read( + lazy.Internals.read( path, options, function onSuccess(success) { @@ -105,7 +107,7 @@ var writeAtomic = function(path, buffer, options = {}) { } return new Promise((resolve, reject) => { - Internals.writeAtomic( + lazy.Internals.writeAtomic( path, buffer, options,