Use methodjit...

This commit is contained in:
Simon Kornblith 2012-07-30 02:37:39 -04:00
parent da6149b06f
commit bdfbfc10b2
2 changed files with 28 additions and 4 deletions

View file

@ -180,8 +180,10 @@ Zotero.HTTP = new function() {
// Don't cache GET requests
xmlhttp.channel.loadFlags |= Components.interfaces.nsIRequest.LOAD_BYPASS_CACHE;
var useMethodjit = Components.utils.methodjit;
/** @ignore */
xmlhttp.onreadystatechange = function() {
Components.utils.methodjit = useMethodjit;
_stateChange(xmlhttp, onDone, responseCharset);
};
@ -266,8 +268,10 @@ Zotero.HTTP = new function() {
xmlhttp.setRequestHeader(header, headers[header]);
}
var useMethodjit = Components.utils.methodjit;
/** @ignore */
xmlhttp.onreadystatechange = function(){
xmlhttp.onreadystatechange = function() {
Components.utils.methodjit = useMethodjit;
_stateChange(xmlhttp, onDone, responseCharset);
};
@ -328,8 +332,10 @@ Zotero.HTTP = new function() {
// Don't cache HEAD requests
xmlhttp.channel.loadFlags |= Components.interfaces.nsIRequest.LOAD_BYPASS_CACHE;
var useMethodjit = Components.utils.methodjit;
/** @ignore */
xmlhttp.onreadystatechange = function(){
xmlhttp.onreadystatechange = function() {
Components.utils.methodjit = useMethodjit;
_stateChange(xmlhttp, onDone);
};
@ -364,8 +370,11 @@ Zotero.HTTP = new function() {
// Prevent certificate/authentication dialogs from popping up
xmlhttp.mozBackgroundRequest = true;
xmlhttp.open('OPTIONS', uri.spec, true);
var useMethodjit = Components.utils.methodjit;
/** @ignore */
xmlhttp.onreadystatechange = function() {
Components.utils.methodjit = useMethodjit;
_stateChange(xmlhttp, callback);
};
xmlhttp.send(null);
@ -436,7 +445,10 @@ Zotero.HTTP = new function() {
xmlhttp.setRequestHeader("Content-Type", 'text/xml; charset="utf-8"');
var useMethodjit = Components.utils.methodjit;
/** @ignore */
xmlhttp.onreadystatechange = function() {
Components.utils.methodjit = useMethodjit;
_stateChange(xmlhttp, callback);
};
@ -469,7 +481,10 @@ Zotero.HTTP = new function() {
// Prevent certificate/authentication dialogs from popping up
xmlhttp.mozBackgroundRequest = true;
xmlhttp.open('MKCOL', uri.spec, true);
var useMethodjit = Components.utils.methodjit;
/** @ignore */
xmlhttp.onreadystatechange = function() {
Components.utils.methodjit = useMethodjit;
_stateChange(xmlhttp, callback);
};
xmlhttp.send(null);
@ -511,7 +526,10 @@ Zotero.HTTP = new function() {
// with Content-Length: 0, which triggers a "no element found" error
// in Firefox, so we override to text
xmlhttp.overrideMimeType("text/plain");
var useMethodjit = Components.utils.methodjit;
/** @ignore */
xmlhttp.onreadystatechange = function() {
Components.utils.methodjit = useMethodjit;
_stateChange(xmlhttp, callback);
};
xmlhttp.send(body);
@ -547,7 +565,10 @@ Zotero.HTTP = new function() {
// Firefox 3 throws a "no element found" error even with a
// 204 ("No Content") response, so we override to text
xmlhttp.overrideMimeType("text/plain");
var useMethodjit = Components.utils.methodjit;
/** @ignore */
xmlhttp.onreadystatechange = function() {
Components.utils.methodjit = useMethodjit;
_stateChange(xmlhttp, callback);
};
xmlhttp.send(null);

View file

@ -97,9 +97,12 @@
var _runningTimers = [];
return function setTimeout(func, ms) {
var timer = Components.classes["@mozilla.org/timer;1"].
createInstance(Components.interfaces.nsITimer);
var useMethodjit = Components.utils.methodjit,
timer = Components.classes["@mozilla.org/timer;1"].
createInstance(Components.interfaces.nsITimer);
timer.initWithCallback({"notify":function() {
Components.utils.methodjit = useMethodjit;
// Remove timer from array so it can be garbage collected
_runningTimers.splice(_runningTimers.indexOf(timer), 1);