refactor: netLog directly uses network service (#18289)

This commit is contained in:
Jeremy Apthorp
2019-05-23 15:31:38 -07:00
committed by GitHub
parent d57df5a4a1
commit 646f572b77
10 changed files with 220 additions and 141 deletions

View File

@@ -22,3 +22,31 @@ Object.setPrototypeOf(Cookies.prototype, EventEmitter.prototype)
Session.prototype._init = function () {
app.emit('session-created', this)
}
const _originalStartLogging = NetLog.prototype.startLogging
NetLog.prototype.startLogging = function (path) {
this._currentlyLoggingPath = path
try {
return _originalStartLogging.call(this, path)
} catch (e) {
this._currentlyLoggingPath = null
throw e
}
}
const _originalStopLogging = NetLog.prototype.stopLogging
NetLog.prototype.stopLogging = function () {
this._currentlyLoggingPath = null
return _originalStopLogging.call(this)
}
const currentlyLoggingPathDeprecated = deprecate.warnOnce('currentlyLoggingPath')
Object.defineProperties(NetLog.prototype, {
currentlyLoggingPath: {
enumerable: true,
get () {
currentlyLoggingPathDeprecated()
return this._currentlyLoggingPath == null ? '' : this._currentlyLoggingPath
}
}
})

View File

@@ -14,6 +14,7 @@ function warnOnce (oldName: string, newName?: string) {
}
const deprecate: ElectronInternal.DeprecationUtil = {
warnOnce,
setHandler: (handler) => { deprecationHandler = handler },
getHandler: () => deprecationHandler,
warn: (oldName, newName) => {