fix: switch to mojo proxy resolver (3-1-x) (#15813)

This commit is contained in:
Robo 2018-11-27 05:08:33 +05:30 committed by Michelle Tilley
parent d5a6bb665b
commit 4abf55801f
65 changed files with 1838 additions and 1797 deletions

View file

@ -1,16 +1,28 @@
'use strict'
const {netLog, NetLog} = process.atomBinding('net_log')
// TODO(deepak1556): Deprecate and remove standalone netLog module,
// it is now a property of sessio module.
const { app, session } = require('electron')
NetLog.prototype.stopLogging = function (callback) {
if (callback && typeof callback !== 'function') {
throw new Error('Invalid callback function')
// Fallback to default session.
Object.setPrototypeOf(module.exports, new Proxy({}, {
get (target, property) {
if (!app.isReady()) return
const netLog = session.defaultSession.netLog
if (!Object.getPrototypeOf(netLog).hasOwnProperty(property)) return
// Returning a native function directly would throw error.
return (...args) => netLog[property](...args)
},
ownKeys () {
if (!app.isReady()) return []
return Object.getOwnPropertyNames(Object.getPrototypeOf(session.defaultSession.netLog))
},
getOwnPropertyDescriptor (target) {
return { configurable: true, enumerable: true }
}
const path = this.currentlyLoggingPath
this._stopLogging(() => {
if (callback) callback(path)
})
}
module.exports = netLog
}))