Bug 1156065 - Send cloneable messages from SiteSpecificUserAgent.js to fix UA overrides r=billm

This commit is contained in:
Tim Taubert 2015-05-25 21:47:08 +02:00
Родитель 77fcecf9b0
Коммит 6f36e89b4d
2 изменённых файлов: 11 добавлений и 10 удалений

Просмотреть файл

@ -46,7 +46,7 @@ SiteSpecificUserAgent.prototype = {
return cachedResult;
}
let data = { uri: aURI };
let data = { host: aURI.asciiHost };
let result = cpmm.sendRpcMessage("Useragent:GetOverride", data)[0] || HTTP_PROTO_HANDLER.userAgent;
if (this.userAgentCache.size >= MAX_CACHE_SIZE) {

Просмотреть файл

@ -30,7 +30,9 @@ var gUpdatedOverrides;
var gOverrideForHostCache = new Map;
var gInitialized = false;
var gOverrideFunctions = [
function (aHttpChannel) { return UserAgentOverrides.getOverrideForURI(aHttpChannel.URI); }
function (aHttpChannel) {
return UserAgentOverrides.getOverrideForURI(aHttpChannel.URI.asciiHost);
}
];
var gBuiltUAs = new Map;
@ -71,20 +73,19 @@ this.UserAgentOverrides = {
gOverrideFunctions.unshift(callback);
},
getOverrideForURI: function uao_getOverrideForURI(aURI) {
let host = aURI.asciiHost;
getOverrideForURI: function uao_getOverrideForURI(aHost) {
if (!gInitialized ||
(!gOverrides.size && !gUpdatedOverrides) ||
!(host)) {
!(aHost)) {
return null;
}
let override = gOverrideForHostCache.get(host);
let override = gOverrideForHostCache.get(aHost);
if (override !== undefined)
return override;
function findOverride(overrides) {
let searchHost = host;
let searchHost = aHost;
let userAgent = overrides.get(searchHost);
while (!userAgent) {
@ -104,7 +105,7 @@ this.UserAgentOverrides = {
if (gOverrideForHostCache.size >= MAX_OVERRIDE_FOR_HOST_CACHE_SIZE) {
gOverrideForHostCache.clear();
}
gOverrideForHostCache.set(host, override);
gOverrideForHostCache.set(aHost, override);
return override;
},
@ -125,8 +126,8 @@ this.UserAgentOverrides = {
let name = aMessage.name;
switch (name) {
case OVERRIDE_MESSAGE:
let uri = aMessage.data.uri;
return this.getOverrideForURI(uri);
let host = aMessage.data.host;
return this.getOverrideForURI(host);
default:
throw("Wrong Message in UserAgentOverride: " + name);
}