Bug 1389315 - Isolate cached completion by provider
MozReview-Commit-ID: INiuM5ydv2f
--- a/toolkit/components/url-classifier/nsUrlClassifierHashCompleter.js
+++ b/toolkit/components/url-classifier/nsUrlClassifierHashCompleter.js
@@ -315,16 +315,17 @@ function HashCompleterRequest(aCompleter
// nsIChannel that the hash completion query is transmitted over.
this._channel = null;
// Response body of hash completion. Created in onDataAvailable.
this._response = "";
// Whether we have been informed of a shutdown by the quit-application event.
this._shuttingDown = false;
this.gethashUrl = aGethashUrl;
+ this.provider = "";
// Multiple partial hashes can be associated with the same tables
// so we use a map here.
this.tableNames = new Map();
this.telemetryProvider = "";
this.telemetryClockStart = 0;
}
HashCompleterRequest.prototype = {
@@ -350,16 +351,20 @@ HashCompleterRequest.prototype = {
this.isV4 = isTableNameV4;
} else if (this.isV4 !== isTableNameV4) {
log('ERROR: Cannot mix "proto" tables with other types within ' +
"the same gethash URL.");
}
this.tableNames.set(aTableName);
// Assuming all tables with the same gethash URL have the same provider
+ if (this.provider == "") {
+ this.provider = gUrlUtil.getProvider(aTableName);
+ }
+
if (this.telemetryProvider == "") {
this.telemetryProvider = gUrlUtil.getTelemetryProvider(aTableName);
}
}
},
fillTableStatesBase64: function HCR_fillTableStatesBase64(aCallback) {
gDbService.getTables(aTableData => {
@@ -662,16 +667,23 @@ HashCompleterRequest.prototype = {
}
return aStart + newlineIndex + 1 + dataLength;
},
// This adds a complete hash to any entry in |this._requests| that matches
// the hash.
handleItem: function HCR_handleItem(aData) {
+ let provider = gUrlUtil.getProvider(aData.tableName);
+ if (provider != this.provider) {
+ log("Response contains table : " + aData.tableName +
+ " of a different provider " + provider);
+ return;
+ }
+
for (let i = 0; i < this._requests.length; i++) {
let request = this._requests[i];
if (aData.completeHash.startsWith(request.partialHash)) {
request.response.matches.push(aData);
}
}
},