Bug 623134: Add HTTP logging to track down the intermittent request timeouts. r=robstrong
authorDave Townsend <dtownsend@oxymoronical.com>
Mon, 16 May 2011 11:46:55 -0700
changeset 69830 b54fc6516c0c13af51508a89a9f3321b7e120243
parent 69829 db4ba8614fb65e3951f99e3f10ee90734d72def3
child 69831 3e7a21049b6cef347c1b7307507cbaf2965f9b4a
push id76
push userbzbarsky@mozilla.com
push dateTue, 05 Jul 2011 17:00:57 +0000
treeherdermozilla-beta@d3a2732c35f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrobstrong
bugs623134
milestone6.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 623134: Add HTTP logging to track down the intermittent request timeouts. r=robstrong
toolkit/mozapps/extensions/AddonUpdateChecker.jsm
toolkit/mozapps/extensions/test/browser/browser_updatessl.js
--- a/toolkit/mozapps/extensions/AddonUpdateChecker.jsm
+++ b/toolkit/mozapps/extensions/AddonUpdateChecker.jsm
@@ -435,26 +435,31 @@ function UpdateParser(aId, aType, aUpdat
   let requireBuiltIn = true;
   try {
     requireBuiltIn = Services.prefs.getBoolPref(PREF_UPDATE_REQUIREBUILTINCERTS);
   }
   catch (e) {
   }
 
   LOG("Requesting " + aUrl);
-  this.request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
-                 createInstance(Ci.nsIXMLHttpRequest);
-  this.request.open("GET", aUrl, true);
-  this.request.channel.notificationCallbacks = new BadCertHandler(!requireBuiltIn);
-  this.request.channel.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE;
-  this.request.overrideMimeType("text/xml");
-  var self = this;
-  this.request.onload = function(event) { self.onLoad() };
-  this.request.onerror = function(event) { self.onError() };
-  this.request.send(null);
+  try {
+    this.request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
+                   createInstance(Ci.nsIXMLHttpRequest);
+    this.request.open("GET", aUrl, true);
+    this.request.channel.notificationCallbacks = new BadCertHandler(!requireBuiltIn);
+    this.request.channel.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE;
+    this.request.overrideMimeType("text/xml");
+    var self = this;
+    this.request.onload = function(event) { self.onLoad() };
+    this.request.onerror = function(event) { self.onError() };
+    this.request.send(null);
+  }
+  catch (e) {
+    ERROR("Failed to request update manifest", e);
+  }
 }
 
 UpdateParser.prototype = {
   id: null,
   type: null,
   updateKey: null,
   observer: null,
   request: null,
--- a/toolkit/mozapps/extensions/test/browser/browser_updatessl.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_updatessl.js
@@ -17,21 +17,39 @@ const UNTRUSTED = "https://untrusted.exa
 const EXPIRED = "https://expired.example.com/";
 
 const PREF_UPDATE_REQUIREBUILTINCERTS = "extensions.update.requireBuiltInCerts";
 
 var gTests = [];
 var gStart = 0;
 var gLast = 0;
 
+var HTTPObserver = {
+  observeActivity: function(aChannel, aType, aSubtype, aTimestamp, aSizeData,
+                            aStringData) {
+    aChannel.QueryInterface(Ci.nsIChannel);
+
+    dump("*** HTTP Activity 0x" + aType.toString(16) + " 0x" + aSubtype.toString(16) +
+         " " + aChannel.URI.spec + "\n");
+  }
+};
+
 function test() {
   gStart = Date.now();
   requestLongerTimeout(4);
   waitForExplicitFinish();
 
+  let observerService = Cc["@mozilla.org/network/http-activity-distributor;1"].
+                        getService(Ci.nsIHttpActivityDistributor);
+  observerService.addObserver(HTTPObserver);
+
+  registerCleanupFunction(function() {
+    observerService.removeObserver(HTTPObserver);
+  });
+
   run_next_test();
 }
 
 function end_test() {
   Services.prefs.clearUserPref(PREF_UPDATE_REQUIREBUILTINCERTS);
 
   var cos = Cc["@mozilla.org/security/certoverride;1"].
             getService(Ci.nsICertOverrideService);