Bug 1210302 - Part 1: Rename nsINetUtil.parseContentType() to parseResponseContentType(); r=mcmanus
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 01 Oct 2015 12:50:13 -0400
changeset 289562 82cc6b6e6eaa
parent 289561 645e5fe8f354
child 289563 71966c03aef5
push id5189
push usereakhgari@mozilla.com
push date2015-10-15 19:05 +0000
treeherdermozilla-beta@c1cd30406136 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs1210302
milestone42.0
Bug 1210302 - Part 1: Rename nsINetUtil.parseContentType() to parseResponseContentType(); r=mcmanus
dom/apps/AppsUtils.jsm
netwerk/base/nsINetUtil.idl
netwerk/base/nsIOService.cpp
netwerk/base/nsNetUtil.cpp
netwerk/test/unit/test_parse_content_type.js
--- a/dom/apps/AppsUtils.jsm
+++ b/dom/apps/AppsUtils.jsm
@@ -499,17 +499,17 @@ this.AppsUtils = {
     return true;
   },
 
   checkManifestContentType: function
      checkManifestContentType(aInstallOrigin, aWebappOrigin, aContentType) {
     let hadCharset = { };
     let charset = { };
     let netutil = Cc["@mozilla.org/network/util;1"].getService(Ci.nsINetUtil);
-    let contentType = netutil.parseContentType(aContentType, charset, hadCharset);
+    let contentType = netutil.parseResponseContentType(aContentType, charset, hadCharset);
     if (aInstallOrigin != aWebappOrigin &&
         !(contentType == "application/x-web-app-manifest+json" ||
           contentType == "application/manifest+json")) {
       return false;
     }
     return true;
   },
 
--- a/netwerk/base/nsINetUtil.idl
+++ b/netwerk/base/nsINetUtil.idl
@@ -6,32 +6,32 @@
 #include "nsISupports.idl"
 
 interface nsIURI;
 interface nsIPrefBranch;
 
 /**
  * nsINetUtil provides various network-related utility methods.
  */
-[scriptable, uuid(885d6940-1001-46e7-92ec-d494a78d7784)]
+[scriptable, uuid(ff0b3233-7ec5-4bf4-830f-6b2edaa53661)]
 interface nsINetUtil : nsISupports
 {
   /**
    * Parse a content-type header and return the content type and
    * charset (if any).
    *
    * @param aTypeHeader the header string to parse
    * @param [out] aCharset the charset parameter specified in the
    *              header, if any.
    * @param [out] aHadCharset whether a charset was explicitly specified.
    * @return the MIME type specified in the header, in lower-case.
    */
-  AUTF8String parseContentType(in AUTF8String aTypeHeader,
-                               out AUTF8String aCharset,
-                               out boolean aHadCharset);
+  AUTF8String parseResponseContentType(in AUTF8String aTypeHeader,
+                                       out AUTF8String aCharset,
+                                       out boolean aHadCharset);
 
   /**
    * Test whether the given URI's handler has the given protocol flags.
    *
    * @param aURI the URI in question
    * @param aFlags the flags we're testing for.
    *
    * @return whether the protocol handler for aURI has all the flags
--- a/netwerk/base/nsIOService.cpp
+++ b/netwerk/base/nsIOService.cpp
@@ -1489,20 +1489,20 @@ nsIOService::Observe(nsISupports *subjec
 #endif
     }
 
     return NS_OK;
 }
 
 // nsINetUtil interface
 NS_IMETHODIMP
-nsIOService::ParseContentType(const nsACString &aTypeHeader,
-                              nsACString &aCharset,
-                              bool *aHadCharset,
-                              nsACString &aContentType)
+nsIOService::ParseResponseContentType(const nsACString &aTypeHeader,
+                                      nsACString &aCharset,
+                                      bool *aHadCharset,
+                                      nsACString &aContentType)
 {
     net_ParseContentType(aTypeHeader, aContentType, aCharset, aHadCharset);
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsIOService::ProtocolHasFlags(nsIURI   *uri,
                               uint32_t  flags,
--- a/netwerk/base/nsNetUtil.cpp
+++ b/netwerk/base/nsNetUtil.cpp
@@ -919,18 +919,18 @@ NS_ParseContentType(const nsACString &ra
                     nsCString        &contentCharset)
 {
     // contentCharset is left untouched if not present in rawContentType
     nsresult rv;
     nsCOMPtr<nsINetUtil> util = do_GetNetUtil(&rv);
     NS_ENSURE_SUCCESS(rv, rv);
     nsCString charset;
     bool hadCharset;
-    rv = util->ParseContentType(rawContentType, charset, &hadCharset,
-                                contentType);
+    rv = util->ParseResponseContentType(rawContentType, charset, &hadCharset,
+                                        contentType);
     if (NS_SUCCEEDED(rv) && hadCharset)
         contentCharset = charset;
     return rv;
 }
 
 nsresult
 NS_ExtractCharsetFromContentType(const nsACString &rawContentType,
                                  nsCString        &contentCharset,
--- a/netwerk/test/unit/test_parse_content_type.js
+++ b/netwerk/test/unit/test_parse_content_type.js
@@ -20,100 +20,100 @@ function check(aType, aCharset, aHadChar
   do_check_eq(aHadCharset, hadCharset.value);
   reset();
 }
 
 function run_test() {
   var netutil = Components.classes["@mozilla.org/network/util;1"]
                           .getService(Components.interfaces.nsINetUtil);
 
-  type = netutil.parseContentType("text/html", charset, hadCharset);
+  type = netutil.parseResponseContentType("text/html", charset, hadCharset);
   check("text/html", "", false);
 
-  type = netutil.parseContentType("TEXT/HTML", charset, hadCharset);
+  type = netutil.parseResponseContentType("TEXT/HTML", charset, hadCharset);
   check("text/html", "", false);
 
-  type = netutil.parseContentType("text/html, text/html", charset, hadCharset);
+  type = netutil.parseResponseContentType("text/html, text/html", charset, hadCharset);
   check("text/html", "", false);
 
-  type = netutil.parseContentType("text/html, text/plain",
+  type = netutil.parseResponseContentType("text/html, text/plain",
 				  charset, hadCharset);
   check("text/plain", "", false);
 
-  type = netutil.parseContentType('text/html, ', charset, hadCharset);
+  type = netutil.parseResponseContentType('text/html, ', charset, hadCharset);
   check("text/html", "", false);
 
-  type = netutil.parseContentType('text/html, */*', charset, hadCharset);
+  type = netutil.parseResponseContentType('text/html, */*', charset, hadCharset);
   check("text/html", "", false);
 
-  type = netutil.parseContentType('text/html, foo', charset, hadCharset);
+  type = netutil.parseResponseContentType('text/html, foo', charset, hadCharset);
   check("text/html", "", false);
 
-  type = netutil.parseContentType("text/html; charset=ISO-8859-1",
+  type = netutil.parseResponseContentType("text/html; charset=ISO-8859-1",
 				  charset, hadCharset);
   check("text/html", "ISO-8859-1", true);
 
-  type = netutil.parseContentType('text/html; charset="ISO-8859-1"',
+  type = netutil.parseResponseContentType('text/html; charset="ISO-8859-1"',
 				  charset, hadCharset);
   check("text/html", "ISO-8859-1", true);
 
-  type = netutil.parseContentType("text/html; charset='ISO-8859-1'",
+  type = netutil.parseResponseContentType("text/html; charset='ISO-8859-1'",
 				  charset, hadCharset);
   check("text/html", "'ISO-8859-1'", true);
 
-  type = netutil.parseContentType("text/html; charset=\"ISO-8859-1\", text/html",
+  type = netutil.parseResponseContentType("text/html; charset=\"ISO-8859-1\", text/html",
 				  charset, hadCharset);
   check("text/html", "ISO-8859-1", true);
 
-  type = netutil.parseContentType("text/html; charset=\"ISO-8859-1\", text/html; charset=UTF8",
+  type = netutil.parseResponseContentType("text/html; charset=\"ISO-8859-1\", text/html; charset=UTF8",
 				  charset, hadCharset);
   check("text/html", "UTF8", true);
 
-  type = netutil.parseContentType("text/html; charset=ISO-8859-1, TEXT/HTML", charset, hadCharset);
+  type = netutil.parseResponseContentType("text/html; charset=ISO-8859-1, TEXT/HTML", charset, hadCharset);
   check("text/html", "ISO-8859-1", true);
 
-  type = netutil.parseContentType("text/html; charset=ISO-8859-1, TEXT/plain", charset, hadCharset);
+  type = netutil.parseResponseContentType("text/html; charset=ISO-8859-1, TEXT/plain", charset, hadCharset);
   check("text/plain", "", true);
 
-  type = netutil.parseContentType("text/plain, TEXT/HTML; charset=ISO-8859-1, text/html, TEXT/HTML", charset, hadCharset);
+  type = netutil.parseResponseContentType("text/plain, TEXT/HTML; charset=ISO-8859-1, text/html, TEXT/HTML", charset, hadCharset);
   check("text/html", "ISO-8859-1", true);
 
-  type = netutil.parseContentType('text/plain, TEXT/HTML; param="charset=UTF8"; charset="ISO-8859-1"; param2="charset=UTF16", text/html, TEXT/HTML', charset, hadCharset);
+  type = netutil.parseResponseContentType('text/plain, TEXT/HTML; param="charset=UTF8"; charset="ISO-8859-1"; param2="charset=UTF16", text/html, TEXT/HTML', charset, hadCharset);
   check("text/html", "ISO-8859-1", true);
 
-  type = netutil.parseContentType('text/plain, TEXT/HTML; param=charset=UTF8; charset="ISO-8859-1"; param2=charset=UTF16, text/html, TEXT/HTML', charset, hadCharset);
+  type = netutil.parseResponseContentType('text/plain, TEXT/HTML; param=charset=UTF8; charset="ISO-8859-1"; param2=charset=UTF16, text/html, TEXT/HTML', charset, hadCharset);
   check("text/html", "ISO-8859-1", true);  
 
-  type = netutil.parseContentType("text/plain; param= , text/html", charset, hadCharset);
+  type = netutil.parseResponseContentType("text/plain; param= , text/html", charset, hadCharset);
   check("text/html", "", false);
 
-  type = netutil.parseContentType('text/plain; param=", text/html"', charset, hadCharset);
+  type = netutil.parseResponseContentType('text/plain; param=", text/html"', charset, hadCharset);
   check("text/plain", "", false);
 
-  type = netutil.parseContentType('text/plain; param=", \\" , text/html"', charset, hadCharset);
+  type = netutil.parseResponseContentType('text/plain; param=", \\" , text/html"', charset, hadCharset);
   check("text/plain", "", false);
 
-  type = netutil.parseContentType('text/plain; param=", \\" , text/html , "', charset, hadCharset);
+  type = netutil.parseResponseContentType('text/plain; param=", \\" , text/html , "', charset, hadCharset);
   check("text/plain", "", false);
 
-  type = netutil.parseContentType('text/plain param=", \\" , text/html , "', charset, hadCharset);
+  type = netutil.parseResponseContentType('text/plain param=", \\" , text/html , "', charset, hadCharset);
   check("text/plain", "", false);
 
-  type = netutil.parseContentType('text/plain charset=UTF8', charset, hadCharset);
+  type = netutil.parseResponseContentType('text/plain charset=UTF8', charset, hadCharset);
   check("text/plain", "", false);
 
-  type = netutil.parseContentType('text/plain, TEXT/HTML; param="charset=UTF8"; ; param2="charset=UTF16", text/html, TEXT/HTML', charset, hadCharset);
+  type = netutil.parseResponseContentType('text/plain, TEXT/HTML; param="charset=UTF8"; ; param2="charset=UTF16", text/html, TEXT/HTML', charset, hadCharset);
   check("text/html", "", false);
 
   // Bug 562915 - correctness: "\x" is "x"
-  type = netutil.parseContentType('text/plain; charset="UTF\\-8"', charset, hadCharset);
+  type = netutil.parseResponseContentType('text/plain; charset="UTF\\-8"', charset, hadCharset);
   check("text/plain", "UTF-8", true);
 
   // Bug 700589
 
   // check that single quote doesn't confuse parsing of subsequent parameters
-  type = netutil.parseContentType("text/plain; x='; charset=\"UTF-8\"", charset, hadCharset);
+  type = netutil.parseResponseContentType("text/plain; x='; charset=\"UTF-8\"", charset, hadCharset);
   check("text/plain", "UTF-8", true);
 
   // check that single quotes do not get removed from extracted charset
-  type = netutil.parseContentType("text/plain; charset='UTF-8'", charset, hadCharset);
+  type = netutil.parseResponseContentType("text/plain; charset='UTF-8'", charset, hadCharset);
   check("text/plain", "'UTF-8'", true);
 }