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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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
}
}
})