Bug 566799 - e10s: Make IPC::URI the go-to for all IPC URI action. r=dwitte
authorJosh Matthews <josh@joshmatthews.net>
Tue, 29 Jun 2010 15:00:25 -0700
changeset 46934 84eb81208a4acd48696bdb82f0c90e7697807a19
parent 46933 babd27e4a8c412eb11e10199aad9626230cdbd24
child 46935 e6d93fff753b1bab26cbd64f13dd331168e4f412
push id14210
push userdougt@mozilla.com
push dateThu, 01 Jul 2010 06:28:42 +0000
treeherdermozilla-central@3aff97777291 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdwitte
bugs566799
milestone2.0b2pre
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 566799 - e10s: Make IPC::URI the go-to for all IPC URI action. r=dwitte
netwerk/ipc/NeckoMessageUtils.h
--- a/netwerk/ipc/NeckoMessageUtils.h
+++ b/netwerk/ipc/NeckoMessageUtils.h
@@ -40,16 +40,17 @@
 #define mozilla_net_NeckoMessageUtils_h
 
 #include "IPC/IPCMessageUtils.h"
 #include "nsStringGlue.h"
 #include "nsIURI.h"
 #include "nsIIPCSerializable.h"
 #include "nsIClassInfo.h"
 #include "nsComponentManagerUtils.h"
+#include "nsNetUtil.h"
 
 namespace IPC {
 
 // Since IPDL doesn't have any knowledge of pointers, there's no easy way to
 // pass around nsIURI pointers.  This is a very thin wrapper that IPDL can
 // easily work with, allowing for conversion to and from an nsIURI pointer.
 
 class URI {
@@ -75,17 +76,34 @@ struct ParamTraits<URI>
   static void Write(Message* aMsg, const paramType& aParam)
   {
     bool isNull = !aParam.mURI;
     WriteParam(aMsg, isNull);
     if (isNull)
       return;
     
     nsCOMPtr<nsIIPCSerializable> serializable = do_QueryInterface(aParam.mURI);
-    NS_ABORT_IF_FALSE(serializable, "All IPDL URIs must be serializable");
+    if (!serializable) {
+      nsCString scheme;
+      aParam.mURI->GetScheme(scheme);
+      NS_ABORT_IF_FALSE(scheme.EqualsASCII("about:"),
+                        "All IPDL URIs must be serializable or an allowed scheme");
+    }
+    
+    bool isSerialized = !!serializable;
+    WriteParam(aMsg, isSerialized);
+    if (!isSerialized) {
+      nsCString spec, charset;
+      aParam.mURI->GetSpec(spec);
+      aParam.mURI->GetOriginCharset(charset);
+      WriteParam(aMsg, spec);
+      WriteParam(aMsg, charset);
+      return;
+    }
+    
     nsCOMPtr<nsIClassInfo> classInfo = do_QueryInterface(aParam.mURI);
     char cidStr[NSID_LENGTH];
     nsCID cid;
     nsresult rv = classInfo->GetClassIDNoAlloc(&cid);
     NS_ABORT_IF_FALSE(NS_SUCCEEDED(rv), "All IPDL URIs must report a valid class ID");
     
     cid.ToProvidedString(cidStr);
     WriteParam(aMsg, nsCAutoString(cidStr));
@@ -96,16 +114,34 @@ struct ParamTraits<URI>
   {
     bool isNull;
     if (!ReadParam(aMsg, aIter, &isNull))
       return false;
     if (isNull) {
       aResult->mURI = nsnull;
       return true;
     }
+
+    bool isSerialized;
+    if (!ReadParam(aMsg, aIter, &isSerialized))
+      return false;
+    if (!isSerialized) {
+      nsCString spec, charset;
+      if (!ReadParam(aMsg, aIter, &spec) ||
+          !ReadParam(aMsg, aIter, &charset))
+        return false;
+      
+      nsCOMPtr<nsIURI> uri;
+      nsresult rv = NS_NewURI(getter_AddRefs(uri), spec, charset.get());
+      if (NS_FAILED(rv))
+        return false;
+      
+      uri.forget(&aResult->mURI);
+      return true;
+    }
     
     nsCAutoString cidStr;
     nsCID cid;
     if (!ReadParam(aMsg, aIter, &cidStr) ||
         !cid.Parse(cidStr.get()))
       return false;
 
     nsCOMPtr<nsIURI> uri = do_CreateInstance(cid);