fix: switch to mojo proxy resolver (3-1-x) (#15813)
This commit is contained in:
parent
d5a6bb665b
commit
4abf55801f
65 changed files with 1838 additions and 1797 deletions
|
@ -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
|
||||
}))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue