Bug 1325501 - move Telemetry from XHR to ServiceRequest r?gfritzsche draft
authorRobert Helmer <rhelmer@mozilla.com>
Thu, 22 Dec 2016 20:38:58 -0800
changeset 453693 d97d8c27fd04f0d5dcdd37eeb3a8d0b7374034a6
parent 453692 bc261b7ac65cf985e7df9d443692ac45a61ea929
child 540520 4fdafe367b358314a63cf1baf607ab31d4ba0738
push id39728
push userrhelmer@mozilla.com
push dateSat, 24 Dec 2016 09:51:56 +0000
reviewersgfritzsche
bugs1325501
milestone53.0a1
Bug 1325501 - move Telemetry from XHR to ServiceRequest r?gfritzsche MozReview-Commit-ID: 6ZyLQknPVFx
toolkit/components/telemetry/TelemetrySend.jsm
--- a/toolkit/components/telemetry/TelemetrySend.jsm
+++ b/toolkit/components/telemetry/TelemetrySend.jsm
@@ -17,16 +17,17 @@ this.EXPORTED_SYMBOLS = [
 
 const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
 Cu.import("resource://gre/modules/Task.jsm", this);
 Cu.import("resource://gre/modules/Log.jsm", this);
 Cu.import("resource://gre/modules/Preferences.jsm");
 Cu.import("resource://gre/modules/PromiseUtils.jsm");
+Cu.import("resource://gre/modules/ServiceRequest.jsm", this);
 Cu.import("resource://gre/modules/Services.jsm", this);
 Cu.import("resource://gre/modules/TelemetryUtils.jsm", this);
 Cu.import("resource://gre/modules/Timer.jsm", this);
 
 XPCOMUtils.defineLazyModuleGetter(this, "AsyncShutdown",
                                   "resource://gre/modules/AsyncShutdown.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "TelemetryStorage",
                                   "resource://gre/modules/TelemetryStorage.jsm");
@@ -899,18 +900,17 @@ var TelemetrySendImpl = {
 
     this._log.trace("_doPing - server: " + this._server + ", persisted: " + isPersisted +
                     ", id: " + id);
 
     const isNewPing = isV4PingFormat(ping);
     const version = isNewPing ? PING_FORMAT_VERSION : 1;
     const url = this._server + this._getSubmissionPath(ping) + "?v=" + version;
 
-    let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]
-                  .createInstance(Ci.nsIXMLHttpRequest);
+    let request = new ServiceRequest();
     request.mozBackgroundRequest = true;
     request.timeout = PING_SUBMIT_TIMEOUT_MS;
 
     request.open("POST", url, true);
     request.overrideMimeType("text/plain");
     request.setRequestHeader("Content-Type", "application/json; charset=UTF-8");
     request.setRequestHeader("Date", Policy.now().toUTCString());