mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
refactor: make CHROME_GET_MESSAGES handler async (#17148)
This commit is contained in:
committed by
Charles Kerr
parent
bfa07ec4be
commit
64078324bf
@@ -12,6 +12,9 @@ const path = require('path')
|
||||
const url = require('url')
|
||||
const util = require('util')
|
||||
|
||||
const readFile = util.promisify(fs.readFile)
|
||||
const writeFile = util.promisify(fs.writeFile)
|
||||
|
||||
// Mapping between extensionId(hostname) and manifest.
|
||||
const manifestMap = {} // extensionId => manifest
|
||||
const manifestNameMap = {} // name => manifest
|
||||
@@ -232,9 +235,9 @@ const getMessagesPath = (extensionId) => {
|
||||
}
|
||||
}
|
||||
|
||||
ipcMainUtils.handle('CHROME_GET_MESSAGES', function (event, extensionId) {
|
||||
ipcMainUtils.handle('CHROME_GET_MESSAGES', async function (event, extensionId) {
|
||||
const messagesPath = getMessagesPath(extensionId)
|
||||
return fs.readFileSync(messagesPath)
|
||||
return readFile(messagesPath)
|
||||
})
|
||||
|
||||
const validStorageTypes = new Set(['sync', 'local'])
|
||||
@@ -267,9 +270,6 @@ const mkdirp = util.promisify((dir, callback) => {
|
||||
})
|
||||
})
|
||||
|
||||
const readFile = util.promisify(fs.readFile)
|
||||
const writeFile = util.promisify(fs.writeFile)
|
||||
|
||||
ipcMainUtils.handle('CHROME_STORAGE_READ', async function (event, storageType, extensionId) {
|
||||
const filePath = getChromeStoragePath(storageType, extensionId)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user