e 0: case 200: // All good :) return; default: this.#emitProxyHTTPError(this.#classifyLoad(chan), key, proxycode); } } catch (err) { // If the channel is not an nsIHttpChannel or not proxied - all good. } } /** * Checks if a channel should be counted. * * @param {nsIHttpChannel} channel * @returns {boolean} true if the channel should be counted. */ getKey(channel) { try { const proxiedChannel = channel.QueryInterface(Ci.nsIProxiedChannel); const proxyInfo = proxiedChannel.proxyInfo; if (!proxyInfo) { // No proxy info, nothing to do. return null; } const isolationKey = proxyInfo.connectionIsolationKey; if (!isolationKey || !this.#isolationKeys.has(isolationKey)) { return null; } return isolationKey; } catch (err) { // If the channel is not an nsIHttpChannel or nsIProxiedChannel, as it's irrelevant // for this class. } return null; } #classifyLoad(channel) { try { if (channel.isMainDocumentChannel) { return "error"; } return "warning"; } catch (_) {} return "unknown"; } #emitProxyHTTPError(level, isolationKey, httpStatus) { this._event.dispatchEvent( new CustomEvent("proxy-http-error", { detail: { level, isolationKey, httpStatus }, }) ); } _event = new EventTarget(); #active = false; #isolationKeys = new Set(); } IPPNetworkErrorObserver.prototype.QueryInterface = ChromeUtils.generateQI([ Ci.nsIObserver, ]); PK