mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1264885 - Use the table name to decide how to build update request. r=francois
This commit is contained in:
parent
ac71a5c4d7
commit
7bd7597d1d
@ -5113,6 +5113,13 @@ pref("browser.safebrowsing.provider.google.updateURL", "https://safebrowsing.goo
|
||||
pref("browser.safebrowsing.provider.google.gethashURL", "https://safebrowsing.google.com/safebrowsing/gethash?client=SAFEBROWSING_ID&appver=%MAJOR_VERSION%&pver=2.2");
|
||||
pref("browser.safebrowsing.provider.google.reportURL", "https://safebrowsing.google.com/safebrowsing/diagnostic?client=%NAME%&hl=%LOCALE%&site=");
|
||||
|
||||
// Prefs for v4.
|
||||
pref("browser.safebrowsing.provider.google4.pver", "4");
|
||||
pref("browser.safebrowsing.provider.google4.lists", "goog-phish-proto,goog-malware-proto,goog-unwanted-proto");
|
||||
pref("browser.safebrowsing.provider.google4.updateURL", "https://safebrowsing.googleapis.com/v4/threatListUpdates:fetch?$req=%REQUEST_BASE64%&$ct=application/x-protobuf&key=%GOOGLE_API_KEY%");
|
||||
pref("browser.safebrowsing.provider.google4.gethashURL", "https://safebrowsing.googleapis.com/v4/fullHashes:find?$req=%REQUEST_BASE64%&$ct=application/x-protobuf&key=%GOOGLE_API_KEY%");
|
||||
pref("browser.safebrowsing.provider.google4.reportURL", "https://safebrowsing.google.com/safebrowsing/diagnostic?client=%NAME%&hl=%LOCALE%&site=");
|
||||
|
||||
pref("browser.safebrowsing.reportPhishMistakeURL", "https://%LOCALE%.phish-error.mozilla.com/?hl=%LOCALE%&url=");
|
||||
pref("browser.safebrowsing.reportPhishURL", "https://%LOCALE%.phish-report.mozilla.com/?hl=%LOCALE%&url=");
|
||||
pref("browser.safebrowsing.reportMalwareMistakeURL", "https://%LOCALE%.malware-error.mozilla.com/?hl=%LOCALE%&url=");
|
||||
|
@ -353,11 +353,23 @@ PROT_ListManager.prototype.makeUpdateRequest_ = function(updateUrl, tableData) {
|
||||
// request: list of tables and existing chunk ranges from tableData
|
||||
// }
|
||||
var streamerMap = { tableList: null, tableNames: {}, request: "" };
|
||||
let useProtobuf = false;
|
||||
for (var tableName in this.tablesData) {
|
||||
// Skip tables not matching this update url
|
||||
if (this.tablesData[tableName].updateUrl != updateUrl) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if |updateURL| is for 'proto'. (only v4 uses protobuf for now.)
|
||||
// We use the table name 'goog-*-proto' and an additional provider "google4"
|
||||
// to describe the v4 settings.
|
||||
let isCurTableProto = tableName.endsWith('-proto');
|
||||
if (useProtobuf && !isCurTableProto) {
|
||||
log('ERROR: Tables for the same updateURL should all be "proto" or none. ' +
|
||||
'Check "browser.safebrowsing.provider.google4.lists"');
|
||||
}
|
||||
useProtobuf = isCurTableProto;
|
||||
|
||||
if (this.needsUpdate_[this.tablesData[tableName].updateUrl][tableName]) {
|
||||
streamerMap.tableNames[tableName] = true;
|
||||
}
|
||||
@ -367,21 +379,27 @@ PROT_ListManager.prototype.makeUpdateRequest_ = function(updateUrl, tableData) {
|
||||
streamerMap.tableList += "," + tableName;
|
||||
}
|
||||
}
|
||||
// Build the request. For each table already in the database, include the
|
||||
// chunk data from the database
|
||||
var lines = tableData.split("\n");
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var fields = lines[i].split(";");
|
||||
var name = fields[0];
|
||||
if (streamerMap.tableNames[name]) {
|
||||
streamerMap.request += lines[i] + "\n";
|
||||
delete streamerMap.tableNames[name];
|
||||
|
||||
if (useProtobuf) {
|
||||
// TODO: Bug 1275507 - XPCOM API to build v4 update request.
|
||||
streamerMap.request = "";
|
||||
} else {
|
||||
// Build the request. For each table already in the database, include the
|
||||
// chunk data from the database
|
||||
var lines = tableData.split("\n");
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var fields = lines[i].split(";");
|
||||
var name = fields[0];
|
||||
if (streamerMap.tableNames[name]) {
|
||||
streamerMap.request += lines[i] + "\n";
|
||||
delete streamerMap.tableNames[name];
|
||||
}
|
||||
}
|
||||
// For each requested table that didn't have chunk data in the database,
|
||||
// request it fresh
|
||||
for (let tableName in streamerMap.tableNames) {
|
||||
streamerMap.request += tableName + ";\n";
|
||||
}
|
||||
}
|
||||
// For each requested table that didn't have chunk data in the database,
|
||||
// request it fresh
|
||||
for (let tableName in streamerMap.tableNames) {
|
||||
streamerMap.request += tableName + ";\n";
|
||||
}
|
||||
|
||||
log("update request: " + JSON.stringify(streamerMap, undefined, 2) + "\n");
|
||||
|
Loading…
Reference in New Issue
Block a user