Bug 541174 - e10s HTTP: Improve how URIs are serialized (part2). r=dwitte
authorJosh Matthews <josh@joshmatthews.net>
Mon, 26 Apr 2010 11:24:21 -0400
changeset 46810 cc46a878de23d87416637072d56b81e53eca39e5
parent 46809 7b2da3a79e359028a82ee7e2ceb8bbdf849ea853
child 46811 a912b6efbb98c1fd919b35ca15dd0b5f0ffb57eb
push idunknown
push userunknown
push dateunknown
reviewersdwitte
bugs541174
milestone1.9.3a5pre
Bug 541174 - e10s HTTP: Improve how URIs are serialized (part2). r=dwitte
netwerk/protocol/http/src/HttpChannelChild.cpp
netwerk/protocol/http/src/HttpChannelParent.cpp
netwerk/protocol/http/src/HttpChannelParent.h
netwerk/protocol/http/src/PHttpChannel.ipdl
--- a/netwerk/protocol/http/src/HttpChannelChild.cpp
+++ b/netwerk/protocol/http/src/HttpChannelChild.cpp
@@ -233,43 +233,20 @@ HttpChannelChild::AsyncOpen(nsIStreamLis
   // the new channel somehow?
 
   // TODO: need to dupe cookies logic from nsHttpChannel.cpp?
 
   // TODO: need to notify (child-side) http-on-modify-req observers 
 
   // TODO: add self to loadgroup? 
 
-  // TODO: smartest way to pass nsURI == (spec, charset)? 
-  nsCAutoString charset;
-  mURI->GetOriginCharset(charset);
-  nsCAutoString originalSpec;
-  mOriginalURI->GetSpec(originalSpec);
-  nsCAutoString originalCharset;
-  mOriginalURI->GetOriginCharset(originalCharset);
-
-  nsCAutoString docSpec;
-  nsCAutoString docCharset;
-  if (mDocumentURI) {
-    mDocumentURI->GetSpec(docSpec);
-    mDocumentURI->GetOriginCharset(docCharset);
-  }
-
-  nsCAutoString referrerSpec;
-  nsCAutoString referrerCharset;
-  if (mReferrer) {
-    mReferrer->GetSpec(referrerSpec);
-    mReferrer->GetOriginCharset(referrerCharset);
-  }
-
-  SendAsyncOpen(mSpec, charset, originalSpec, originalCharset, docSpec,
-                docCharset, referrerSpec, referrerCharset, mLoadFlags,
-                mRequestHeaders, mRequestHead.Method(), mPriority,
-                mRedirectionLimit, mAllowPipelining,
-                mForceAllowThirdPartyCookie);
+  SendAsyncOpen(IPC::URI(mURI), IPC::URI(mOriginalURI), IPC::URI(mDocumentURI),
+                IPC::URI(mReferrer), mLoadFlags, mRequestHeaders,
+                mRequestHead.Method(), mPriority, mRedirectionLimit,
+                mAllowPipelining, mForceAllowThirdPartyCookie);
 
   mIsPending = PR_TRUE;
   mWasOpened = PR_TRUE;
   mState = HCC_OPENED;
 
   return NS_OK;
 }
 
--- a/netwerk/protocol/http/src/HttpChannelParent.cpp
+++ b/netwerk/protocol/http/src/HttpChannelParent.cpp
@@ -70,76 +70,57 @@ NS_IMPL_ISUPPORTS3(HttpChannelParent,
                    nsIStreamListener,
                    nsIInterfaceRequestor);
 
 //-----------------------------------------------------------------------------
 // HttpChannelParent::PHttpChannelParent
 //-----------------------------------------------------------------------------
 
 bool 
-HttpChannelParent::RecvAsyncOpen(const nsCString&           uriSpec, 
-                                 const nsCString&           charset,
-                                 const nsCString&           originalUriSpec, 
-                                 const nsCString&           originalCharset,
-                                 const nsCString&           docUriSpec, 
-                                 const nsCString&           docCharset,
-                                 const nsCString&           referrerSpec,
-                                 const nsCString&           referrerCharset,
+HttpChannelParent::RecvAsyncOpen(const IPC::URI&            aURI,
+                                 const IPC::URI&            aOriginalURI,
+                                 const IPC::URI&            aDocURI,
+                                 const IPC::URI&            aReferrerURI,
                                  const PRUint32&            loadFlags,
                                  const RequestHeaderTuples& requestHeaders,
                                  const nsHttpAtom&          requestMethod,
                                  const PRUint16&            priority,
                                  const PRUint8&             redirectionLimit,
                                  const PRBool&              allowPipelining,
                                  const PRBool&              forceAllowThirdPartyCookie)
 {
-  LOG(("HttpChannelParent RecvAsyncOpen [this=%x uri=%s (%s)]\n", 
-       this, uriSpec.get(), charset.get()));
+  nsCOMPtr<nsIURI> uri = aURI;
+  nsCOMPtr<nsIURI> originalUri = aOriginalURI;
+  nsCOMPtr<nsIURI> docUri = aDocURI;
+  nsCOMPtr<nsIURI> referrerUri = aReferrerURI;
+  
+  nsCString uriSpec;
+  uri->GetSpec(uriSpec);
+  LOG(("HttpChannelParent RecvAsyncOpen [this=%x uri=%s]\n", 
+       this, uriSpec.get()));
 
   nsresult rv;
 
   nsCOMPtr<nsIIOService> ios(do_GetIOService(&rv));
   if (NS_FAILED(rv))
     return false;       // TODO: send fail msg to child, return true
 
-  nsCOMPtr<nsIURI> uri;
-  rv = NS_NewURI(getter_AddRefs(uri), uriSpec, charset.get(), nsnull, ios);
-  if (NS_FAILED(rv))
-    return false;       // TODO: send fail msg to child, return true
-
   nsCOMPtr<nsIChannel> chan;
   rv = NS_NewChannel(getter_AddRefs(chan), uri, ios, nsnull, nsnull, loadFlags);
   if (NS_FAILED(rv))
     return false;       // TODO: send fail msg to child, return true
 
   nsHttpChannel *httpChan = static_cast<nsHttpChannel *>(chan.get());
 
-  if (!originalUriSpec.IsEmpty()) {
-    nsCOMPtr<nsIURI> originalUri;
-    rv = NS_NewURI(getter_AddRefs(originalUri), originalUriSpec, 
-                   originalCharset.get(), nsnull, ios);
-    if (!NS_FAILED(rv))
-      httpChan->SetOriginalURI(originalUri);
-  }
-  if (!docUriSpec.IsEmpty()) {
-    nsCOMPtr<nsIURI> docUri;
-    rv = NS_NewURI(getter_AddRefs(docUri), docUriSpec, 
-                   docCharset.get(), nsnull, ios);
-    if (!NS_FAILED(rv)) {
-      httpChan->SetDocumentURI(docUri);
-    }
-  }
-  if (!referrerSpec.IsEmpty()) {
-    nsCOMPtr<nsIURI> referrerUri;
-    rv = NS_NewURI(getter_AddRefs(referrerUri), referrerSpec,
-                   referrerCharset.get(), nsnull, ios);
-    if (!NS_FAILED(rv)) {
-      httpChan->SetReferrerInternal(referrerUri);
-    }
-  }
+  if (originalUri)
+    httpChan->SetOriginalURI(originalUri);
+  if (docUri)
+    httpChan->SetDocumentURI(docUri);
+  if (referrerUri)
+    httpChan->SetReferrerInternal(referrerUri);
   if (loadFlags != nsIRequest::LOAD_NORMAL)
     httpChan->SetLoadFlags(loadFlags);
 
   for (PRUint32 i = 0; i < requestHeaders.Length(); i++)
     httpChan->SetRequestHeader(requestHeaders[i].mHeader,
                                requestHeaders[i].mValue,
                                requestHeaders[i].mMerge);
 
--- a/netwerk/protocol/http/src/HttpChannelParent.h
+++ b/netwerk/protocol/http/src/HttpChannelParent.h
@@ -60,24 +60,20 @@ public:
   NS_DECL_NSIREQUESTOBSERVER
   NS_DECL_NSISTREAMLISTENER
   NS_DECL_NSIINTERFACEREQUESTOR
 
   HttpChannelParent();
   virtual ~HttpChannelParent();
 
 protected:
-  virtual bool RecvAsyncOpen(const nsCString&           uriSpec, 
-                             const nsCString&           charset,
-                             const nsCString&           originalUriSpec, 
-                             const nsCString&           originalCharset,
-                             const nsCString&           docUriSpec, 
-                             const nsCString&           docCharset,
-                             const nsCString&           referrerSpec,
-                             const nsCString&           referrerCharset,
+  virtual bool RecvAsyncOpen(const IPC::URI&            uri,
+                             const IPC::URI&            originalUri,
+                             const IPC::URI&            docUri,
+                             const IPC::URI&            referrerUri,
                              const PRUint32&            loadFlags,
                              const RequestHeaderTuples& requestHeaders,
                              const nsHttpAtom&          requestMethod,
                              const PRUint16&            priority,
                              const PRUint8&             redirectionLimit,
                              const PRBool&              allowPipelining,
                              const PRBool&              forceAllowThirdPartyCookie);
 
--- a/netwerk/protocol/http/src/PHttpChannel.ipdl
+++ b/netwerk/protocol/http/src/PHttpChannel.ipdl
@@ -36,44 +36,41 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 include protocol "PNecko.ipdl";
 
 include "mozilla/net/PHttpChannelParams.h";
+include "mozilla/net/NeckoMessageUtils.h";
 
 using RequestHeaderTuples;
 using nsHttpResponseHead;
 using nsHttpAtom;
+using IPC::URI;
 
 namespace mozilla {
 namespace net {
 
 //-------------------------------------------------------------------
 protocol PHttpChannel
 {
   manager PNecko;
 
 parent:
   __delete__();
 
-  AsyncOpen(nsCString           uriSpec, 
-            nsCString           charset, 
+  AsyncOpen(URI                 uri,
             // - TODO: unclear if any HTTP channel clients ever set
             // originalURI != uri (about:credits?); also not clear if chrome
-            // channel would ever need to know.  Can we get rid of next two
-            // args?
-            nsCString           originalUriSpec, 
-            nsCString           originalCharset, 
-            nsCString           docUriSpec, 
-            nsCString           docCharset, 
-            nsCString           referrerSpec,
-            nsCString           referrerCharset,
+            // channel would ever need to know.  Can we get rid of next arg?
+            URI                 original,
+            URI                 doc,
+            URI                 referrer,
             PRUint32            loadFlags,
             RequestHeaderTuples requestHeaders,
             nsHttpAtom          requestMethod,
             PRUint16            priority,
             PRUint8             redirectionLimit,
             PRBool              allowPipelining,
             PRBool              forceAllowThirdPartyCookie);