From a429b716650509e5ce329984efdcd6fdf570b488 Mon Sep 17 00:00:00 2001 From: gorhill Date: Fri, 10 Jun 2016 13:18:32 -0400 Subject: [PATCH] code review re. #554: use channel data when available --- platform/firefox/vapi-background.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index 7e9397c..e59545d 100644 --- a/platform/firefox/vapi-background.js +++ b/platform/firefox/vapi-background.js @@ -1885,7 +1885,7 @@ var httpObserver = { channelDataFromChannel: function(channel) { if ( channel instanceof Ci.nsIWritablePropertyBag ) { try { - return channel.getProperty(this.REQDATAKEY); + return channel.getProperty(this.REQDATAKEY) || null; } catch (ex) { } } @@ -1957,10 +1957,9 @@ var httpObserver = { } var URI = channel.URI; - var channelData; + var channelData = this.channelDataFromChannel(channel); if ( topic.lastIndexOf('http-on-examine-', 0) === 0 ) { - channelData = this.channelDataFromChannel(channel); if ( channelData === null ) { return; } @@ -2000,6 +1999,14 @@ var httpObserver = { } // http-on-modify-request + + // The channel was previously serviced. + if ( channelData !== null ) { + this.handleRequest(channel, URI, channelData[0], channelData[1]); + return; + } + + // The channel was never serviced. var tabId; var pendingRequest = this.lookupPendingRequest(URI.asciiSpec); var rawType = 1;