Bug 1432908 - Port bug 1432257 to C-C: Replace use of nsIStandardURL::Init. r=valentin,philipp
authorJorg K <jorgk@jorgk.com>
Sun, 28 Jan 2018 22:45:51 +0100
changeset 30990 c5f308f257ebd17b38f1ebd4c1fa1015f200377d
parent 30989 8e9463f5d78ab718cead4ef4d023e635dda7bfaa
child 30991 22741bece2a7663485b49b1003d418d0ef781000
push id383
push userclokep@gmail.com
push dateMon, 07 May 2018 21:52:48 +0000
reviewersvalentin, philipp
bugs1432908, 1432257
Bug 1432908 - Port bug 1432257 to C-C: Replace use of nsIStandardURL::Init. r=valentin,philipp
calendar/base/src/calProtocolHandler.js
calendar/lightning/components/calItipProtocolHandler.js
ldap/xpcom/src/nsLDAPURL.cpp
--- a/calendar/base/src/calProtocolHandler.js
+++ b/calendar/base/src/calProtocolHandler.js
@@ -26,21 +26,23 @@ function calProtocolHandler(scheme) {
     this.wrappedJSObject = this;
 }
 
 calProtocolHandler.prototype = {
     get defaultPort() { return this.mHttpProtocol.defaultPort; },
     get protocolFlags() { return this.mHttpProtocol.protocolFlags; },
 
     newURI: function(aSpec, anOriginalCharset, aBaseURI) {
-        let uri = Components.classes["@mozilla.org/network/standard-url;1"]
-                            .createInstance(Components.interfaces.nsIStandardURL);
-        uri.init(Components.interfaces.nsIStandardURL.URLTYPE_STANDARD,
-                 this.mHttpProtocol.defaultPort, aSpec, anOriginalCharset, aBaseURI);
-        return uri;
+        return Components.classes["@mozilla.org/network/standard-url-mutator;1"]
+                         .createInstance(Components.interfaces.nsIStandardURLMutator)
+                         .init(Components.interfaces.nsIStandardURL.URLTYPE_STANDARD,
+                               this.mHttpProtocol.defaultPort,
+                               aSpec, anOriginalCharset, aBaseURI)
+                         .finalize()
+                         .QueryInterface(Components.interfaces.nsIStandardURL);
     },
 
     newChannel: function(aUri) {
         return this.newChannel2(aUri, null);
     },
 
     newChannel2: function(aUri, aLoadInfo) {
         // make sure to clone the uri, because we are about to change
--- a/calendar/lightning/components/calItipProtocolHandler.js
+++ b/calendar/lightning/components/calItipProtocolHandler.js
@@ -71,21 +71,22 @@ ItipProtocolHandler.prototype = {
         classDescription: "iTIP Protocol Handler",
         interfaces: ItipProtocolHandlerInterfaces
     }),
 
     protocolFlags: Ci.nsIProtocolHandler.URI_NORELATIVE | Ci.nsIProtocolHandler.URI_DANGEROUS_TO_LOAD,
     allowPort: () => false,
     isSecure: false,
     newURI: function(spec, charSet, baseURI) {
-        let cls = Components.classes["@mozilla.org/network/standard-url;1"];
-        let url = cls.createInstance(Ci.nsIStandardURL);
-        url.init(Ci.nsIStandardURL.URLTYPE_STANDARD, 0, spec, charSet, baseURI);
         dump("Creating new URI for " + spec + "\n");
-        return url.QueryInterface(Ci.nsIURI);
+        return Components.classes["@mozilla.org/network/standard-url-mutator;1"]
+                         .createInstance(Ci.nsIStandardURLMutator)
+                         .init(Ci.nsIStandardURL.URLTYPE_STANDARD, 0,
+                               spec, charSet, baseURI)
+                         .finalize();
     },
 
     newChannel: function(URI) {
         return this.newChannel2(URI, null);
     },
 
     newChannel2: function(URI, aLoadInfo) {
         dump("Creating new ItipChannel for " + URI + "\n");
--- a/ldap/xpcom/src/nsLDAPURL.cpp
+++ b/ldap/xpcom/src/nsLDAPURL.cpp
@@ -31,29 +31,23 @@ nsLDAPURL::~nsLDAPURL()
 {
 }
 
 nsresult
 nsLDAPURL::Init(uint32_t aUrlType, int32_t aDefaultPort,
                 const nsACString &aSpec, const char* aOriginCharset,
                 nsIURI *aBaseURI)
 {
-  if (!mBaseURL)
-  {
-    mBaseURL = do_CreateInstance(NS_STANDARDURL_CONTRACTID);
-    if (!mBaseURL)
-      return NS_ERROR_OUT_OF_MEMORY;
-  }
-
   nsresult rv;
-  nsCOMPtr<nsIStandardURL> standardURL(do_QueryInterface(mBaseURL, &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = standardURL->Init(aUrlType, aDefaultPort, aSpec, aOriginCharset,
-                         aBaseURI);
+  rv = NS_MutateURI(NS_STANDARDURLMUTATOR_CONTRACTID)
+         .Apply<nsIStandardURLMutator>(&nsIStandardURLMutator::Init,
+                                       nsIStandardURL::URLTYPE_STANDARD,
+                                       aDefaultPort, PromiseFlatCString(aSpec),
+                                       aOriginCharset, aBaseURI, nullptr)
+         .Finalize(mBaseURL);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Now get the spec from the mBaseURL in case it was a relative one
   nsCString spec;
   rv = mBaseURL->GetSpec(spec);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return SetSpecInternal(spec);