Bug 1223231 - Use channel.asyncOpen2 in devtools/client/shared/AppCacheUtils.jsm (r=sicking)
authorChristoph Kerschbaumer <mozilla@christophkerschbaumer.com>
Mon, 14 Dec 2015 19:04:56 -0800
changeset 276406 653925f77eeca14a0fc44472da94fa8be0ed9e1a
parent 276405 ac81258fcf5c9a36d2330dea2c338fd6e656f622
child 276407 eec861bce6d4316ec12aa9a6c6685e479f994799
push id69157
push usermozilla@christophkerschbaumer.com
push dateTue, 15 Dec 2015 04:21:32 +0000
treeherdermozilla-inbound@653925f77eec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs1223231
milestone45.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 1223231 - Use channel.asyncOpen2 in devtools/client/shared/AppCacheUtils.jsm (r=sicking)
devtools/client/shared/AppCacheUtils.jsm
--- a/devtools/client/shared/AppCacheUtils.jsm
+++ b/devtools/client/shared/AppCacheUtils.jsm
@@ -24,16 +24,17 @@
  */
 
 "use strict";
 
 const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
 
 var { XPCOMUtils } = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {});
 var { Services }   = Cu.import("resource://gre/modules/Services.jsm", {});
+var { NetUtil }    = Cu.import("resource://gre/modules/NetUtil.jsm", {});
 var { LoadContextInfo } = Cu.import("resource://gre/modules/LoadContextInfo.jsm", {});
 var { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
 var promise = require("promise");
 
 this.EXPORTED_SYMBOLS = ["AppCacheUtils"];
 
 function AppCacheUtils(documentOrUri) {
   this._parseManifest = this._parseManifest.bind(this);
@@ -181,30 +182,27 @@ AppCacheUtils.prototype = {
     return deferred.promise;
   },
 
   _getURIInfo: function ACU__getURIInfo(uri) {
     let inputStream = Cc["@mozilla.org/scriptableinputstream;1"]
                         .createInstance(Ci.nsIScriptableInputStream);
     let deferred = promise.defer();
     let buffer = "";
-    let channel = Services.io.newChannel2(uri,
-                                          null,
-                                          null,
-                                          null,      // aLoadingNode
-                                          Services.scriptSecurityManager.getSystemPrincipal(),
-                                          null,      // aTriggeringPrincipal
-                                          Ci.nsILoadInfo.SEC_NORMAL,
-                                          Ci.nsIContentPolicy.TYPE_OTHER);
+    var channel = NetUtil.newChannel({
+                    uri: uri,
+                    loadUsingSystemPrincipal: true,
+                    securityFlags: Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL
+                  });
 
     // Avoid the cache:
     channel.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE;
     channel.loadFlags |= Ci.nsIRequest.INHIBIT_CACHING;
 
-    channel.asyncOpen({
+    channel.asyncOpen2({
       onStartRequest: function (request, context) {
         // This empty method is needed in order for onDataAvailable to be
         // called.
       },
 
       onDataAvailable: function (request, context, stream, offset, count) {
         request.QueryInterface(Ci.nsIHttpChannel);
         inputStream.init(stream);
@@ -240,17 +238,17 @@ AppCacheUtils.prototype = {
           deferred.resolve(result);
         } else {
           deferred.resolve({
             name: request.name,
             success: false
           });
         }
       }
-    }, null);
+    });
     return deferred.promise;
   },
 
   listEntries: function ACU_show(searchTerm) {
     if (!Services.prefs.getBoolPref("browser.cache.disk.enable")) {
       throw new Error(l10n.GetStringFromName("cacheDisabled"));
     }