Bug 1118845 P2 Add optional base load group to NS_NewLoadGroup(). r=mcmanus
☠☠ backed out by 8d838801a16d ☠ ☠
authorBen Kelly <ben@wanderview.com>
Thu, 08 Jan 2015 19:52:22 -0500
changeset 222869 2bda66cf60fd98af7c82b0df55052d647d9d33b6
parent 222868 dd1fc46d4d5694418fa1071ab6231237f0949c24
child 222870 41d0ad0271a6693cab09ef2cfdd26d15fb3a9ce6
push id10731
push usercbook@mozilla.com
push dateFri, 09 Jan 2015 14:51:37 +0000
treeherderfx-team@e6756043d930 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs1118845
milestone37.0a1
Bug 1118845 P2 Add optional base load group to NS_NewLoadGroup(). r=mcmanus
netwerk/base/public/nsNetUtil.h
netwerk/base/src/nsNetUtil.cpp
--- a/netwerk/base/public/nsNetUtil.h
+++ b/netwerk/base/public/nsNetUtil.h
@@ -990,19 +990,22 @@ NS_NewLoadGroup(nsILoadGroup      **resu
         if (NS_SUCCEEDED(rv)) {
             *result = nullptr;
             group.swap(*result);
         }
     }
     return rv;
 }
 
-// Create a new nsILoadGroup that will match the given principal.
+// Create a new nsILoadGroup that will match the given principal.  Also,
+// if a base laod group is provided, populate the nsILoadContext of the
+// new group with information from the existing context.
 nsresult
-NS_NewLoadGroup(nsILoadGroup** aResult, nsIPrincipal* aPrincipal);
+NS_NewLoadGroup(nsILoadGroup** aResult, nsIPrincipal* aPrincipal,
+                nsILoadGroup* aOptionalBase = nullptr);
 
 // Determine if the given loadGroup/principal pair will produce a principal
 // with similar permissions when passed to NS_NewChannel().  This checks for
 // things like making sure the appId and browser element flags match.  Without
 // an appropriate load group these values can be lost when getting the result
 // principal back out of the channel.  Null principals are also always allowed
 // as they do not have permissions to actually use the load group.
 bool
--- a/netwerk/base/src/nsNetUtil.cpp
+++ b/netwerk/base/src/nsNetUtil.cpp
@@ -14,26 +14,37 @@ bool NS_IsReasonableHTTPHeaderValue(cons
 }
 
 bool NS_IsValidHTTPToken(const nsACString& aToken)
 {
   return mozilla::net::nsHttp::IsValidToken(aToken);
 }
 
 nsresult
-NS_NewLoadGroup(nsILoadGroup** aResult, nsIPrincipal* aPrincipal)
+NS_NewLoadGroup(nsILoadGroup** aResult, nsIPrincipal* aPrincipal,
+                nsILoadGroup* aOptionalBase)
 {
     using mozilla::LoadContext;
     nsresult rv;
 
+    nsCOMPtr<nsILoadContext> baseLoadContext;
+    if (aOptionalBase) {
+      nsCOMPtr<nsIInterfaceRequestor> cb;
+      rv = aOptionalBase->GetNotificationCallbacks(getter_AddRefs(cb));
+      NS_ENSURE_SUCCESS(rv, rv);
+
+      baseLoadContext = do_QueryInterface(cb);
+    }
+
     nsCOMPtr<nsILoadGroup> group =
         do_CreateInstance(NS_LOADGROUP_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    nsRefPtr<LoadContext> loadContext = new LoadContext(aPrincipal);
+    nsRefPtr<LoadContext> loadContext = new LoadContext(aPrincipal,
+                                                        baseLoadContext);
     rv = group->SetNotificationCallbacks(loadContext);
     NS_ENSURE_SUCCESS(rv, rv);
 
     group.forget(aResult);
     return rv;
 }
 
 bool