Bug 1348442: Part 4 - Remove support for synchronously loading localized extension CSS. r=jdm
authorKris Maglione <maglione.k@gmail.com>
Fri, 17 Mar 2017 16:46:59 -0700
changeset 349380 dda3d09783a5b5fe61c6591aa53d77105147b123
parent 349379 9b0898770b8f174f9edeca40267348801fa23a02
child 349381 f2eebe34cd1aa205570f0ff30734c3f0a8cab705
push id88409
push usermaglione.k@gmail.com
push dateFri, 24 Mar 2017 03:23:47 +0000
treeherdermozilla-inbound@dda3d09783a5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdm
bugs1348442
milestone55.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 1348442: Part 4 - Remove support for synchronously loading localized extension CSS. r=jdm After switching to loading content stylesheets asynchronously, there are no longer any consumers that require a synchronous channel to load localized CSS, so these workarounds are no longer necessary. MozReview-Commit-ID: AwLSmYf9qL3
netwerk/protocol/res/ExtensionProtocolHandler.cpp
--- a/netwerk/protocol/res/ExtensionProtocolHandler.cpp
+++ b/netwerk/protocol/res/ExtensionProtocolHandler.cpp
@@ -133,54 +133,36 @@ ExtensionProtocolHandler::SubstituteChan
   nsCOMPtr<nsIStreamConverterService> convService =
     do_GetService(NS_STREAMCONVERTERSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   const char* kFromType = "application/vnd.mozilla.webext.unlocalized";
   const char* kToType = "text/css";
 
   nsCOMPtr<nsIInputStream> inputStream;
-  if (aLoadInfo &&
-      aLoadInfo->GetSecurityMode() == nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS) {
-    // If the channel needs to enforce CORS, we need to open the channel async.
-
-    nsCOMPtr<nsIOutputStream> outputStream;
-    rv = NS_NewPipe(getter_AddRefs(inputStream), getter_AddRefs(outputStream),
-                    0, UINT32_MAX, true, false);
-    NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIOutputStream> outputStream;
+  rv = NS_NewPipe(getter_AddRefs(inputStream), getter_AddRefs(outputStream),
+                  0, UINT32_MAX, true, false);
+  NS_ENSURE_SUCCESS(rv, rv);
 
-    nsCOMPtr<nsIStreamListener> listener;
-    nsCOMPtr<nsIRequestObserver> observer = new PipeCloser(outputStream);
-    rv = NS_NewSimpleStreamListener(getter_AddRefs(listener), outputStream, observer);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    nsCOMPtr<nsIStreamListener> converter;
-    rv = convService->AsyncConvertData(kFromType, kToType, listener,
-                                       aURI, getter_AddRefs(converter));
-    NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIStreamListener> listener;
+  nsCOMPtr<nsIRequestObserver> observer = new PipeCloser(outputStream);
+  rv = NS_NewSimpleStreamListener(getter_AddRefs(listener), outputStream, observer);
+  NS_ENSURE_SUCCESS(rv, rv);
 
-    nsCOMPtr<nsILoadInfo> loadInfo =
-      static_cast<LoadInfo*>(aLoadInfo)->CloneForNewRequest();
-    (*result)->SetLoadInfo(loadInfo);
-
-    rv = (*result)->AsyncOpen2(converter);
-  } else {
-    // Stylesheet loads for extension content scripts require a sync channel.
+  nsCOMPtr<nsIStreamListener> converter;
+  rv = convService->AsyncConvertData(kFromType, kToType, listener,
+                                     aURI, getter_AddRefs(converter));
+  NS_ENSURE_SUCCESS(rv, rv);
 
-    nsCOMPtr<nsIInputStream> sourceStream;
-    if (aLoadInfo && aLoadInfo->GetEnforceSecurity()) {
-      rv = (*result)->Open2(getter_AddRefs(sourceStream));
-    } else {
-      rv = (*result)->Open(getter_AddRefs(sourceStream));
-    }
-    NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsILoadInfo> loadInfo =
+    static_cast<LoadInfo*>(aLoadInfo)->CloneForNewRequest();
+  (*result)->SetLoadInfo(loadInfo);
 
-    rv = convService->Convert(sourceStream, kFromType, kToType,
-                              aURI, getter_AddRefs(inputStream));
-  }
+  rv = (*result)->AsyncOpen2(converter);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIChannel> channel;
   rv = NS_NewInputStreamChannelInternal(getter_AddRefs(channel), aURI, inputStream,
                                         NS_LITERAL_CSTRING("text/css"),
                                         NS_LITERAL_CSTRING("utf-8"),
                                         aLoadInfo);
   NS_ENSURE_SUCCESS(rv, rv);