Bug 1063197 - Callsites of NS_NewInputStreamChannel in /content/base (r=jst)
authorChristoph Kerschbaumer <mozilla@christophkerschbaumer.com>
Thu, 16 Oct 2014 11:14:42 -0700
changeset 210805 7de43e0c3879ef70891663a8ffbdb51d2cceaf9b
parent 210804 a87d8dff37cabaa195c6aebfdabb96fdbd88af64
child 210806 7921e44f3544d21d1d3e688fa9762467f589e816
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersjst
bugs1063197
milestone36.0a1
Bug 1063197 - Callsites of NS_NewInputStreamChannel in /content/base (r=jst)
content/base/src/DOMParser.cpp
content/base/src/nsHostObjectProtocolHandler.cpp
--- a/content/base/src/DOMParser.cpp
+++ b/content/base/src/DOMParser.cpp
@@ -233,28 +233,25 @@ DOMParser::ParseFromStream(nsIInputStrea
 
   nsCOMPtr<nsIDOMDocument> domDocument;
   rv = SetUpDocument(svg ? DocumentFlavorSVG : DocumentFlavorLegacyGuess,
                      getter_AddRefs(domDocument));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Create a fake channel 
   nsCOMPtr<nsIChannel> parserChannel;
-  NS_NewInputStreamChannel(getter_AddRefs(parserChannel), mDocumentURI, nullptr,
-                           nsDependentCString(contentType), nullptr);
+  NS_NewInputStreamChannel(getter_AddRefs(parserChannel),
+                           mDocumentURI,
+                           nullptr, // aStream
+                           mOriginalPrincipal,
+                           nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL,
+                           nsIContentPolicy::TYPE_OTHER,
+                           nsDependentCString(contentType));
   NS_ENSURE_STATE(parserChannel);
 
-  // More principal-faking here
-  nsCOMPtr<nsILoadInfo> loadInfo =
-    new LoadInfo(mOriginalPrincipal,
-                 nullptr,
-                 nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL,
-                 nsIContentPolicy::TYPE_OTHER);
-  parserChannel->SetLoadInfo(loadInfo);
-
   if (charset) {
     parserChannel->SetContentCharset(nsDependentCString(charset));
   }
 
   // Tell the document to start loading
   nsCOMPtr<nsIStreamListener> listener;
 
   // Have to pass false for reset here, else the reset will remove
--- a/content/base/src/nsHostObjectProtocolHandler.cpp
+++ b/content/base/src/nsHostObjectProtocolHandler.cpp
@@ -514,17 +514,21 @@ nsHostObjectProtocolHandler::NewChannel(
   FileImpl* blob = static_cast<FileImpl*>(blobImpl.get());
   nsCOMPtr<nsIInputStream> stream;
   nsresult rv = blob->GetInternalStream(getter_AddRefs(stream));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIChannel> channel;
   rv = NS_NewInputStreamChannel(getter_AddRefs(channel),
                                 uri,
-                                stream);
+                                stream,
+                                info->mPrincipal,
+                                nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL,
+                                nsIContentPolicy::TYPE_OTHER);
+
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsString type;
   blob->GetType(type);
 
   if (blob->IsFile()) {
     nsString filename;
     blob->GetName(filename);
@@ -532,22 +536,16 @@ nsHostObjectProtocolHandler::NewChannel(
   }
 
   ErrorResult error;
   uint64_t size = blob->GetSize(error);
   if (NS_WARN_IF(error.Failed())) {
     return error.ErrorCode();
   }
 
-  nsCOMPtr<nsILoadInfo> loadInfo =
-    new mozilla::LoadInfo(info->mPrincipal,
-                          nullptr,
-                          nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL,
-                          nsIContentPolicy::TYPE_OTHER);
-  channel->SetLoadInfo(loadInfo);
   channel->SetOriginalURI(uri);
   channel->SetContentType(NS_ConvertUTF16toUTF8(type));
   channel->SetContentLength(size);
 
   channel.forget(result);
 
   return NS_OK;
 }